PAPI  5.6.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
linux-nvml.c File Reference

This is an NVML component, it demos the component interface and implements a number of counters from the Nvidia Management Library. Please refer to NVML documentation for details about nvmlDeviceGetPowerUsage, nvmlDeviceGetTemperature. Power is reported in mW and temperature in Celcius. The counter descriptions should contain the units that the measurement returns. More...

Include dependency graph for linux-nvml.c:

Go to the source code of this file.

Data Structures

struct  nvml_context_t
 

Macros

#define CUDAAPI   __attribute__((weak))
 
#define CUDARTAPI   __attribute__((weak))
 
#define DECLDIR   __attribute__((weak))
 
#define NVML_MAX_COUNTERS   100
 

Functions

unsigned long long getClockSpeed (nvmlDevice_t dev, nvmlClockType_t which_one)
 
unsigned long long getEccLocalErrors (nvmlDevice_t dev, nvmlEccBitType_t bits, int which_one)
 
unsigned long long getFanSpeed (nvmlDevice_t dev)
 
unsigned long long getMaxClockSpeed (nvmlDevice_t dev, nvmlClockType_t which_one)
 
unsigned long long getMemoryInfo (nvmlDevice_t dev, int which_one)
 
unsigned long long getPState (nvmlDevice_t dev)
 
unsigned long long getPowerUsage (nvmlDevice_t dev)
 
unsigned long long getTemperature (nvmlDevice_t dev)
 
unsigned long long getTotalEccErrors (nvmlDevice_t dev, nvmlEccBitType_t bits)
 
unsigned long long getUtilization (nvmlDevice_t dev, int which_one)
 
unsigned long long getPowerManagementLimit (nvmlDevice_t dev)
 
static void nvml_hardware_reset ()
 
 switch (entry->type)
 
static int nvml_hardware_write (long long *value, int which_one)
 
int _papi_nvml_init_thread (hwd_context_t *ctx)
 
static int detectDevices ()
 
static void createNativeEvents ()
 
int _papi_nvml_init_component (int cidx)
 
static int linkCudaLibraries ()
 
int _papi_nvml_init_control_state (hwd_control_state_t *ctl)
 
int _papi_nvml_update_control_state (hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
 
int _papi_nvml_start (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
int _papi_nvml_stop (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
int _papi_nvml_read (hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags)
 
int _papi_nvml_write (hwd_context_t *ctx, hwd_control_state_t *ctl, long long *events)
 
int _papi_nvml_reset (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
int _papi_nvml_shutdown_component ()
 
int _papi_nvml_shutdown_thread (hwd_context_t *ctx)
 
int _papi_nvml_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
 
int _papi_nvml_set_domain (hwd_control_state_t *cntrl, int domain)
 
int _papi_nvml_ntv_enum_events (unsigned int *EventCode, int modifier)
 
int _papi_nvml_ntv_code_to_name (unsigned int EventCode, char *name, int len)
 
int _papi_nvml_ntv_code_to_descr (unsigned int EventCode, char *descr, int len)
 
int _papi_nvml_ntv_code_to_info (unsigned int EventCode, PAPI_event_info_t *info)
 

Variables

void(* _dl_non_dynamic_init )(void)
 
 nvml_control_state_t
 
static nvml_native_event_entry_tnvml_native_table = NULL
 
static int device_count = 0
 
static int num_events = 0
 
static nvmlDevice_t * devices = NULL
 
static intfeatures = NULL
 
static unsigned intpower_management_initial_limit = NULL
 
static unsigned intpower_management_limit_constraint_min = NULL
 
static unsigned intpower_management_limit_constraint_max = NULL
 
static int
 
nvmlDevice_t handle = devices[cudaIdx]
 
int cudaIdx = -1
 
 entry = &nvml_native_table[which_one]
 
value = (long long) - 1
 
return PAPI_EINVAL
 
return PAPI_OK
 
papi_vector_t _nvml_vector
 

Detailed Description

Author
Kiran Kumar Kasichayanula kkasi.nosp@m.cha@.nosp@m.utk.e.nosp@m.du
James Ralph ralph.nosp@m.@eec.nosp@m.s.utk.nosp@m..edu

Definition in file linux-nvml.c.

Macro Definition Documentation

#define CUDAAPI   __attribute__((weak))
#define CUDARTAPI   __attribute__((weak))
#define DECLDIR   __attribute__((weak))
#define NVML_MAX_COUNTERS   100

Function Documentation

int _papi_nvml_ctl ( hwd_context_t ctx,
int  code,
_papi_int_option_t option 
)

This function sets various options in the component

Parameters
codevalid are PAPI_SET_DEFDOM, PAPI_SET_DOMAIN, PAPI_SETDEFGRN, PAPI_SET_GRANUL and PAPI_SET_INHERIT

Definition at line 1444 of file linux-nvml.c.

1445 {
1446  SUBDBG("Enter: ctx: %p, code: %d\n", ctx, code);
1447 
1448  (void) ctx;
1449  (void) code;
1450  (void) option;
1451 
1452  /* FIXME. This should maybe set up more state, such as which counters are active and */
1453  /* counter mappings. */
1454 
1455  return PAPI_OK;
1456 }
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
int _papi_nvml_init_component ( int  cidx)

Initialize hardware counters, setup the function vector table and get hardware information, this routine is called when the PAPI process is initialized (IE PAPI_library_init)

Definition at line 1005 of file linux-nvml.c.

1006 {
1007  SUBDBG("Entry: cidx: %d\n", cidx);
1008  nvmlReturn_t ret;
1009  cudaError_t cuerr;
1010  int papi_errorcode;
1011 
1012  int cuda_count = 0;
1013  unsigned int nvml_count = 0;
1014 
1015  /* link in the cuda and nvml libraries and resolve the symbols we need to use */
1016  if (linkCudaLibraries() != PAPI_OK) {
1017  SUBDBG("Dynamic link of CUDA libraries failed, component will be disabled.\n");
1018  SUBDBG("See disable reason in papi_component_avail output for more details.\n");
1019  return (PAPI_ENOSUPP);
1020  }
1021 
1022  ret = (*nvmlInitPtr)();
1023  if (NVML_SUCCESS != ret) {
1024  strcpy(_nvml_vector.cmp_info.disabled_reason, "The NVIDIA managament library failed to initialize.");
1025  return PAPI_ENOSUPP;
1026  }
1027 
1028  cuerr = (*cuInitPtr)(0);
1029  if (cudaSuccess != cuerr) {
1030  strcpy(_nvml_vector.cmp_info.disabled_reason, "The CUDA library failed to initialize.");
1031  return PAPI_ENOSUPP;
1032  }
1033 
1034  /* Figure out the number of CUDA devices in the system */
1035  ret = (*nvmlDeviceGetCountPtr)(&nvml_count);
1036  if (NVML_SUCCESS != ret) {
1037  strcpy(_nvml_vector.cmp_info.disabled_reason, "Unable to get a count of devices from the NVIDIA managament library.");
1038  return PAPI_ENOSUPP;
1039  }
1040 
1041  cuerr = (*cudaGetDeviceCountPtr)(&cuda_count);
1042  if (cudaSuccess != cuerr) {
1043  strcpy(_nvml_vector.cmp_info.disabled_reason, "Unable to get a device count from CUDA.");
1044  return PAPI_ENOSUPP;
1045  }
1046 
1047  /* We can probably recover from this, when we're clever */
1048  if ((cuda_count > 0) && (nvml_count != (unsigned int)cuda_count)) {
1049  strcpy(_nvml_vector.cmp_info.disabled_reason, "CUDA and the NVIDIA managament library have different device counts.");
1050  return PAPI_ENOSUPP;
1051  }
1052 
1053  device_count = cuda_count;
1054  SUBDBG("Need to setup NVML with %d devices\n", device_count);
1055 
1056  /* A per device representation of what events are present */
1057  features = (int*)papi_malloc(sizeof(int) * device_count);
1058 
1059  /* Handles to each device */
1060  devices = (nvmlDevice_t*)papi_malloc(sizeof(nvmlDevice_t) * device_count);
1061 
1062  /* For each device, store the intial power value to enable reset if power is altered */
1063  power_management_initial_limit = (unsigned int*)papi_malloc(sizeof(unsigned int) * device_count);
1064  power_management_limit_constraint_min = (unsigned int*)papi_malloc(sizeof(unsigned int) * device_count);
1065  power_management_limit_constraint_max = (unsigned int*)papi_malloc(sizeof(unsigned int) * device_count);
1066 
1067  /* Figure out what events are supported on each card. */
1068  if ((papi_errorcode = detectDevices()) != PAPI_OK) {
1070  papi_free(devices);
1071  sprintf(_nvml_vector.cmp_info.disabled_reason, "An error occured in device feature detection, please check your NVIDIA Management Library and CUDA install.");
1072  return PAPI_ENOSUPP;
1073  }
1074 
1075  /* The assumption is that if everything went swimmingly in detectDevices,
1076  all nvml calls here should be fine. */
1078 
1079  /* Export the total number of events available */
1081 
1082  /* Export the component id */
1084 
1085  /* Export the number of 'counters' */
1088 
1089  return PAPI_OK;
1090 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
static unsigned int * power_management_limit_constraint_min
Definition: linux-nvml.c:166
static unsigned int * power_management_initial_limit
Definition: linux-nvml.c:165
static int linkCudaLibraries()
Definition: linux-nvml.c:1099
#define papi_free(a)
Definition: papi_memory.h:35
#define papi_malloc(a)
Definition: papi_memory.h:34
#define PAPI_ENOSUPP
Definition: papi.h:271
static int num_events
Definition: linux-nvml.c:161
return PAPI_OK
Definition: linux-nvml.c:497
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
papi_vector_t _nvml_vector
Definition: linux-nvml.c:1610
long long ret
Definition: iozone.c:1346
static int cidx
char disabled_reason[PAPI_MAX_STR_LEN]
Definition: papi.h:636
static nvmlDevice_t * devices
Definition: linux-nvml.c:163
static int device_count
Definition: linux-nvml.c:158
static unsigned int * power_management_limit_constraint_max
Definition: linux-nvml.c:167
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static int * features
Definition: linux-nvml.c:164
strcpy(filename, default_filename)
static int detectDevices()
Definition: linux-nvml.c:564
static void createNativeEvents()
Definition: linux-nvml.c:736

Here is the call graph for this function:

int _papi_nvml_init_control_state ( hwd_control_state_t ctl)

Setup a counter control state. In general a control state holds the hardware info for an EventSet.

Definition at line 1259 of file linux-nvml.c.

1260 {
1261  SUBDBG("nvml_init_control_state... %p\n", ctl);
1262  nvml_control_state_t *nvml_ctl = (nvml_control_state_t *) ctl;
1263  memset(nvml_ctl, 0, sizeof(nvml_control_state_t));
1264 
1265  return PAPI_OK;
1266 }
return PAPI_OK
Definition: linux-nvml.c:497
nvml_control_state_t
Definition: linux-nvml.c:147
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
int _papi_nvml_init_thread ( hwd_context_t ctx)

This is called whenever a thread is initialized

Definition at line 554 of file linux-nvml.c.

555 {
556  (void) ctx;
557 
558  SUBDBG("Enter: ctx: %p\n", ctx);
559 
560  return PAPI_OK;
561 }
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
int _papi_nvml_ntv_code_to_descr ( unsigned int  EventCode,
char *  descr,
int  len 
)

Takes a native event code and passes back the event description

Parameters
EventCodeis the native event code
descris a pointer for the description to be copied to
lenis the size of the descr string

Definition at line 1571 of file linux-nvml.c.

1572 {
1573  int index;
1574  index = EventCode;
1575 
1576  if (index >= num_events) return PAPI_ENOEVNT;
1577 
1578  strncpy(descr, nvml_native_table[index].description, len);
1579 
1580  return PAPI_OK;
1581 }
#define PAPI_ENOEVNT
Definition: papi.h:260
static int num_events
Definition: linux-nvml.c:161
return PAPI_OK
Definition: linux-nvml.c:497
static nvml_native_event_entry_t * nvml_native_table
Definition: linux-nvml.c:155
char description[PAPI_MAX_STR_LEN]
int _papi_nvml_ntv_code_to_info ( unsigned int  EventCode,
PAPI_event_info_t info 
)

Takes a native event code and passes back the event info

Parameters
EventCodeis the native event code
infois a pointer for the info to be copied to

Definition at line 1588 of file linux-nvml.c.

1589 {
1590 
1591  int index = EventCode;
1592 
1593  if ((index < 0) || (index >= num_events)) return PAPI_ENOEVNT;
1594 
1595  strncpy(info->symbol, nvml_native_table[index].name, sizeof(info->symbol) - 1);
1596  info->symbol[sizeof(info->symbol) - 1] = '\0';
1597 
1598  strncpy(info->units, nvml_native_table[index].units, sizeof(info->units) - 1);
1599  info->units[sizeof(info->units) - 1] = '\0';
1600 
1601  strncpy(info->long_descr, nvml_native_table[index].description, sizeof(info->long_descr) - 1);
1602  info->long_descr[sizeof(info->long_descr) - 1] = '\0';
1603 
1604 // info->data_type = nvml_native_table[index].return_type;
1605 
1606  return PAPI_OK;
1607 }
#define PAPI_ENOEVNT
Definition: papi.h:260
static int num_events
Definition: linux-nvml.c:161
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:969
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:966
return PAPI_OK
Definition: linux-nvml.c:497
char name[PAPI_MAX_STR_LEN]
Definition: linux-nvml.h:50
static nvml_native_event_entry_t * nvml_native_table
Definition: linux-nvml.c:155
char units[PAPI_MIN_STR_LEN]
Definition: linux-nvml.h:51
char description[PAPI_MAX_STR_LEN]
Definition: linux-nvml.h:52
char units[PAPI_MIN_STR_LEN]
Definition: papi.h:975
int _papi_nvml_ntv_code_to_name ( unsigned int  EventCode,
char *  name,
int  len 
)

Takes a native event code and passes back the name

Parameters
EventCodeis the native event code
nameis a pointer for the name to be copied to
lenis the size of the name string

Definition at line 1550 of file linux-nvml.c.

1551 {
1552  SUBDBG("Entry: EventCode: %#x, name: %s, len: %d\n", EventCode, name, len);
1553  int index;
1554 
1555  index = EventCode;
1556 
1557  /* Make sure we are in range */
1558  if (index >= num_events) return PAPI_ENOEVNT;
1559 
1560  strncpy(name, nvml_native_table[index].name, len);
1561 
1562  return PAPI_OK;
1563 }
#define PAPI_ENOEVNT
Definition: papi.h:260
static int num_events
Definition: linux-nvml.c:161
return PAPI_OK
Definition: linux-nvml.c:497
static nvml_native_event_entry_t * nvml_native_table
Definition: linux-nvml.c:155
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
char * name
Definition: iozone.c:23648
int _papi_nvml_ntv_enum_events ( unsigned int EventCode,
int  modifier 
)

Enumerate Native Events

Parameters
EventCodeis the event of interest
modifieris one of PAPI_ENUM_FIRST, PAPI_ENUM_EVENTS If your component has attribute masks then these need to be handled here as well.

Definition at line 1509 of file linux-nvml.c.

1510 {
1511  int index;
1512 
1513  switch (modifier) {
1514 
1515  /* return EventCode of first event */
1516  case PAPI_ENUM_FIRST:
1517  /* return the first event that we support */
1518 
1519  *EventCode = 0;
1520  return PAPI_OK;
1521 
1522  /* return EventCode of next available event */
1523  case PAPI_ENUM_EVENTS:
1524  index = *EventCode;
1525 
1526  /* Make sure we are in range */
1527  if (index < num_events - 1) {
1528 
1529  /* This assumes a non-sparse mapping of the events */
1530  *EventCode = *EventCode + 1;
1531  return PAPI_OK;
1532  } else {
1533  return PAPI_ENOEVNT;
1534  }
1535  break;
1536 
1537  default:
1538  return PAPI_EINVAL;
1539  }
1540 
1541  return PAPI_EINVAL;
1542 }
#define PAPI_ENOEVNT
Definition: papi.h:260
static int num_events
Definition: linux-nvml.c:161
return PAPI_OK
Definition: linux-nvml.c:497
return PAPI_EINVAL
Definition: linux-nvml.c:436
int _papi_nvml_read ( hwd_context_t ctx,
hwd_control_state_t ctl,
long long **  events,
int  flags 
)

Triggered by PAPI_read()

Definition at line 1337 of file linux-nvml.c.

1339 {
1340  SUBDBG("Enter: ctx: %p, flags: %d\n", ctx, flags);
1341 
1342  (void) ctx;
1343  (void) flags;
1344  int i;
1345  int ret;
1346  nvml_control_state_t* nvml_ctl = (nvml_control_state_t*) ctl;
1347 
1348  for (i = 0; i < nvml_ctl->num_events; i++) {
1349  if (PAPI_OK !=
1350  (ret = nvml_hardware_read(&nvml_ctl->counter[i],
1351  nvml_ctl->which_counter[i])))
1352  return ret;
1353 
1354  }
1355  /* return pointer to the values we read */
1356  *events = nvml_ctl->counter;
1357  return PAPI_OK;
1358 }
long long flags
Definition: iozone.c:12330
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
char events[MAX_EVENTS][BUFSIZ]
nvml_control_state_t
Definition: linux-nvml.c:147
long long ret
Definition: iozone.c:1346
int i
Definition: fileop.c:140
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
int _papi_nvml_reset ( hwd_context_t ctx,
hwd_control_state_t ctl 
)

Triggered by PAPI_reset() but only if the EventSet is currently running

Definition at line 1389 of file linux-nvml.c.

1390 {
1391  SUBDBG("Enter: ctx: %p, ctl: %p\n", ctx, ctl);
1392 
1393  (void) ctx;
1394  (void) ctl;
1395 
1396  /* Reset the hardware */
1398 
1399  return PAPI_OK;
1400 }
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static void nvml_hardware_reset()
Definition: linux-nvml.c:390

Here is the call graph for this function:

int _papi_nvml_set_domain ( hwd_control_state_t cntrl,
int  domain 
)

This function has to set the bits needed to count different domains In particular: PAPI_DOM_USER, PAPI_DOM_KERNEL PAPI_DOM_OTHER By default return PAPI_EINVAL if none of those are specified and PAPI_OK with success PAPI_DOM_USER is only user context is counted PAPI_DOM_KERNEL is only the Kernel/OS context is counted PAPI_DOM_OTHER is Exception/transient mode (like user TLB misses) PAPI_DOM_ALL is all of the domains

Definition at line 1468 of file linux-nvml.c.

1469 {
1470  SUBDBG("Enter: cntrl: %p, domain: %d\n", cntrl, domain);
1471 
1472  (void) cntrl;
1473 
1474  int found = 0;
1475 
1476  if (PAPI_DOM_USER & domain) {
1477  SUBDBG(" PAPI_DOM_USER \n");
1478  found = 1;
1479  }
1480  if (PAPI_DOM_KERNEL & domain) {
1481  SUBDBG(" PAPI_DOM_KERNEL \n");
1482  found = 1;
1483  }
1484  if (PAPI_DOM_OTHER & domain) {
1485  SUBDBG(" PAPI_DOM_OTHER \n");
1486  found = 1;
1487  }
1488  if (PAPI_DOM_ALL & domain) {
1489  SUBDBG(" PAPI_DOM_ALL \n");
1490  found = 1;
1491  }
1492  if (!found)
1493  return (PAPI_EINVAL);
1494 
1495  return PAPI_OK;
1496 }
#define PAPI_DOM_KERNEL
Definition: papi.h:300
#define PAPI_DOM_ALL
Definition: papi.h:303
return PAPI_OK
Definition: linux-nvml.c:497
#define PAPI_DOM_USER
Definition: papi.h:298
void
Definition: iozone.c:18627
return PAPI_EINVAL
Definition: linux-nvml.c:436
long long found
Definition: libasync.c:735
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
#define PAPI_DOM_OTHER
Definition: papi.h:301
int _papi_nvml_shutdown_component ( )

Triggered by PAPI_shutdown()

Definition at line 1404 of file linux-nvml.c.

1405 {
1406  SUBDBG("Enter:\n");
1409  if (devices != NULL) papi_free(devices);
1410  if (features != NULL) papi_free(features);
1414  (*nvmlShutdownPtr)();
1415 
1416  device_count = 0;
1417  num_events = 0;
1418 
1419  // close the dynamic libraries needed by this component (opened in the init component call)
1420  if (dl3) dlclose(dl3); dl3=NULL;
1421  if (dl2) dlclose(dl2); dl2=NULL;
1422  if (dl1) dlclose(dl1); dl1=NULL;
1423 
1424  return PAPI_OK;
1425 }
static unsigned int * power_management_limit_constraint_min
Definition: linux-nvml.c:166
static unsigned int * power_management_initial_limit
Definition: linux-nvml.c:165
#define papi_free(a)
Definition: papi_memory.h:35
static int num_events
Definition: linux-nvml.c:161
return PAPI_OK
Definition: linux-nvml.c:497
static nvml_native_event_entry_t * nvml_native_table
Definition: linux-nvml.c:155
static void * dl1
Definition: linux-cuda.c:84
static void * dl2
Definition: linux-cuda.c:85
static nvmlDevice_t * devices
Definition: linux-nvml.c:163
static int device_count
Definition: linux-nvml.c:158
static unsigned int * power_management_limit_constraint_max
Definition: linux-nvml.c:167
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static int * features
Definition: linux-nvml.c:164
static void * dl3
Definition: linux-cuda.c:86
static void nvml_hardware_reset()
Definition: linux-nvml.c:390

Here is the call graph for this function:

int _papi_nvml_shutdown_thread ( hwd_context_t ctx)

Called at thread shutdown

Definition at line 1429 of file linux-nvml.c.

1430 {
1431  SUBDBG("Enter: ctx: %p\n", ctx);
1432 
1433  (void) ctx;
1434 
1435  /* Last chance to clean up thread */
1436 
1437  return PAPI_OK;
1438 }
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
int _papi_nvml_start ( hwd_context_t ctx,
hwd_control_state_t ctl 
)

Triggered by PAPI_start()

Definition at line 1296 of file linux-nvml.c.

1297 {
1298  SUBDBG("Enter: ctx: %p, ctl: %p\n", ctx, ctl);
1299 
1300  (void) ctx;
1301  (void) ctl;
1302 
1303  /* anything that would need to be set at counter start time */
1304 
1305  /* reset */
1306  /* start the counting */
1307 
1308  return PAPI_OK;
1309 }
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
int _papi_nvml_stop ( hwd_context_t ctx,
hwd_control_state_t ctl 
)

Triggered by PAPI_stop()

Definition at line 1313 of file linux-nvml.c.

1314 {
1315  SUBDBG("Enter: ctx: %p, ctl: %p\n", ctx, ctl);
1316 
1317  int i;
1318  (void) ctx;
1319  (void) ctl;
1320  int ret;
1321 
1322  nvml_control_state_t* nvml_ctl = (nvml_control_state_t*) ctl;
1323 
1324  for (i = 0; i < nvml_ctl->num_events; i++) {
1325  if (PAPI_OK !=
1326  (ret = nvml_hardware_read(&nvml_ctl->counter[i],
1327  nvml_ctl->which_counter[i])))
1328  return ret;
1329 
1330  }
1331 
1332  return PAPI_OK;
1333 }
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
nvml_control_state_t
Definition: linux-nvml.c:147
long long ret
Definition: iozone.c:1346
int i
Definition: fileop.c:140
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
int _papi_nvml_update_control_state ( hwd_control_state_t ctl,
NativeInfo_t native,
int  count,
hwd_context_t ctx 
)

Triggered by eventset operations like add or remove

Definition at line 1270 of file linux-nvml.c.

1274 {
1275  SUBDBG("Enter: ctl: %p, ctx: %p\n", ctl, ctx);
1276  int i, index;
1277 
1278  nvml_control_state_t *nvml_ctl = (nvml_control_state_t *) ctl;
1279  (void) ctx;
1280 
1281  /* if no events, return */
1282  if (count == 0) return PAPI_OK;
1283 
1284  for (i = 0; i < count; i++) {
1285  index = native[i].ni_event;
1286  nvml_ctl->which_counter[i] = index;
1287  /* We have no constraints on event position, so any event */
1288  /* can be in any slot. */
1289  native[i].ni_position = i;
1290  }
1291  nvml_ctl->num_events = count;
1292  return PAPI_OK;
1293 }
return PAPI_OK
Definition: linux-nvml.c:497
int count
Definition: iozone.c:22422
void
Definition: iozone.c:18627
nvml_control_state_t
Definition: linux-nvml.c:147
int i
Definition: fileop.c:140
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
int _papi_nvml_write ( hwd_context_t ctx,
hwd_control_state_t ctl,
long long events 
)

Triggered by PAPI_write(), but only if the counters are running

Definition at line 1363 of file linux-nvml.c.

1364 {
1365  SUBDBG("Enter: ctx: %p, ctl: %p\n", ctx, ctl);
1366  (void) ctx;
1367  nvml_control_state_t* nvml_ctl = (nvml_control_state_t*) ctl;
1368  int i;
1369  int ret;
1370 
1371  /* You can change ECC mode and compute exclusivity modes on the cards */
1372  /* But I don't see this as a function of a PAPI component at this time */
1373  /* All implementation issues aside. */
1374 
1375  // Currently POWER_MANAGEMENT can be written
1376  for (i = 0; i < nvml_ctl->num_events; i++) {
1377  if (PAPI_OK != (ret = nvml_hardware_write(&events[i], nvml_ctl->which_counter[i])))
1378  return ret;
1379  }
1380 
1381  /* return pointer to the values we read */
1382  return PAPI_OK;
1383 }
static int nvml_hardware_write(long long *value, int which_one)
Definition: linux-nvml.c:503
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
char events[MAX_EVENTS][BUFSIZ]
nvml_control_state_t
Definition: linux-nvml.c:147
long long ret
Definition: iozone.c:1346
int i
Definition: fileop.c:140
#define SUBDBG(format, args...)
Definition: papi_debug.h:63

Here is the call graph for this function:

static void createNativeEvents ( void  )
static

Definition at line 736 of file linux-nvml.c.

737 {
738  char name[64];
739  char sanitized_name[PAPI_MAX_STR_LEN];
740  char names[device_count][64];
741 
742  int i, nameLen = 0, j;
743 
745  nvmlReturn_t ret;
746 
750  entry = &nvml_native_table[0];
751 
752  for (i = 0; i < device_count; i++) {
753  memset(names[i], 0x0, 64);
754  ret = (*nvmlDeviceGetNamePtr)(devices[i], name, sizeof(name) - 1);
755  if (NVML_SUCCESS != ret) {
756  SUBDBG("nvmlDeviceGetName failed \n");
757  strncpy(name, "deviceNameUnknown", 17);
758  }
759  name[sizeof(name) - 1] = '\0'; // to safely use strlen operation below, the variable 'name' must be null terminated
760 
761  nameLen = strlen(name);
762  strncpy(sanitized_name, name, PAPI_MAX_STR_LEN);
763 
764  int retval = snprintf(sanitized_name, sizeof(name), "%s:device_%d", name, i);
765  if (retval > (int)sizeof(name)) {
766  SUBDBG("Device name is too long %s:device%d", name, i);
767  return;
768  }
769  sanitized_name[sizeof(name) - 1] = '\0';
770 
771  for (j = 0; j < nameLen; j++)
772  if (' ' == sanitized_name[j])
773  sanitized_name[j] = '_';
774 
776  sprintf(entry->name, "%s:graphics_clock", sanitized_name);
777  strncpy(entry->description, "Graphics clock domain (MHz).", PAPI_MAX_STR_LEN);
778  entry->options.clock = NVML_CLOCK_GRAPHICS;
779  entry->type = FEATURE_CLOCK_INFO;
780  entry++;
781 
782  sprintf(entry->name, "%s:sm_clock", sanitized_name);
783  strncpy(entry->description, "SM clock domain (MHz).", PAPI_MAX_STR_LEN);
784  entry->options.clock = NVML_CLOCK_SM;
785  entry->type = FEATURE_CLOCK_INFO;
786  entry++;
787 
788  sprintf(entry->name, "%s:memory_clock", sanitized_name);
789  strncpy(entry->description, "Memory clock domain (MHz).", PAPI_MAX_STR_LEN);
790  entry->options.clock = NVML_CLOCK_MEM;
791  entry->type = FEATURE_CLOCK_INFO;
792  entry++;
793  }
794 
796  sprintf(entry->name, "%s:l1_single_ecc_errors", sanitized_name);
797  strncpy(entry->description, "L1 cache single bit ECC", PAPI_MAX_STR_LEN);
798  entry->options.ecc_opts = (struct local_ecc) {
799  .bits = NVML_SINGLE_BIT_ECC,
800  .which_one = LOCAL_ECC_L1,
801  };
803  entry++;
804 
805  sprintf(entry->name, "%s:l2_single_ecc_errors", sanitized_name);
806  strncpy(entry->description, "L2 cache single bit ECC", PAPI_MAX_STR_LEN);
807  entry->options.ecc_opts = (struct local_ecc) {
808  .bits = NVML_SINGLE_BIT_ECC,
809  .which_one = LOCAL_ECC_L2,
810  };
812  entry++;
813 
814  sprintf(entry->name, "%s:memory_single_ecc_errors", sanitized_name);
815  strncpy(entry->description, "Device memory single bit ECC", PAPI_MAX_STR_LEN);
816  entry->options.ecc_opts = (struct local_ecc) {
817  .bits = NVML_SINGLE_BIT_ECC,
818  .which_one = LOCAL_ECC_MEM,
819  };
821  entry++;
822 
823  sprintf(entry->name, "%s:regfile_single_ecc_errors", sanitized_name);
824  strncpy(entry->description, "Register file single bit ECC", PAPI_MAX_STR_LEN);
825  entry->options.ecc_opts = (struct local_ecc) {
826  .bits = NVML_SINGLE_BIT_ECC,
827  .which_one = LOCAL_ECC_REGFILE,
828  };
830  entry++;
831 
832  sprintf(entry->name, "%s:1l_double_ecc_errors", sanitized_name);
833  strncpy(entry->description, "L1 cache double bit ECC", PAPI_MAX_STR_LEN);
834  entry->options.ecc_opts = (struct local_ecc) {
835  .bits = NVML_DOUBLE_BIT_ECC,
836  .which_one = LOCAL_ECC_L1,
837  };
839  entry++;
840 
841  sprintf(entry->name, "%s:l2_double_ecc_errors", sanitized_name);
842  strncpy(entry->description, "L2 cache double bit ECC", PAPI_MAX_STR_LEN);
843  entry->options.ecc_opts = (struct local_ecc) {
844  .bits = NVML_DOUBLE_BIT_ECC,
845  .which_one = LOCAL_ECC_L2,
846  };
848  entry++;
849 
850  sprintf(entry->name, "%s:memory_double_ecc_errors", sanitized_name);
851  strncpy(entry->description, "Device memory double bit ECC", PAPI_MAX_STR_LEN);
852  entry->options.ecc_opts = (struct local_ecc) {
853  .bits = NVML_DOUBLE_BIT_ECC,
854  .which_one = LOCAL_ECC_MEM,
855  };
857  entry++;
858 
859  sprintf(entry->name, "%s:regfile_double_ecc_errors", sanitized_name);
860  strncpy(entry->description, "Register file double bit ECC", PAPI_MAX_STR_LEN);
861  entry->options.ecc_opts = (struct local_ecc) {
862  .bits = NVML_DOUBLE_BIT_ECC,
863  .which_one = LOCAL_ECC_REGFILE,
864  };
866  entry++;
867  }
868 
870  sprintf(entry->name, "%s:fan_speed", sanitized_name);
871  strncpy(entry->description, "The fan speed expressed as a percent of the maximum, i.e. full speed is 100%", PAPI_MAX_STR_LEN);
872  entry->type = FEATURE_FAN_SPEED;
873  entry++;
874  }
875 
877  sprintf(entry->name, "%s:graphics_max_clock", sanitized_name);
878  strncpy(entry->description, "Maximal Graphics clock domain (MHz).", PAPI_MAX_STR_LEN);
879  entry->options.clock = NVML_CLOCK_GRAPHICS;
880  entry->type = FEATURE_MAX_CLOCK;
881  entry++;
882 
883  sprintf(entry->name, "%s:sm_max_clock", sanitized_name);
884  strncpy(entry->description, "Maximal SM clock domain (MHz).", PAPI_MAX_STR_LEN);
885  entry->options.clock = NVML_CLOCK_SM;
886  entry->type = FEATURE_MAX_CLOCK;
887  entry++;
888 
889  sprintf(entry->name, "%s:memory_max_clock", sanitized_name);
890  strncpy(entry->description, "Maximal Memory clock domain (MHz).", PAPI_MAX_STR_LEN);
891  entry->options.clock = NVML_CLOCK_MEM;
892  entry->type = FEATURE_MAX_CLOCK;
893  entry++;
894  }
895 
897  sprintf(entry->name, "%s:total_memory", sanitized_name);
898  strncpy(entry->description, "Total installed FB memory (in bytes).", PAPI_MAX_STR_LEN);
900  entry->type = FEATURE_MEMORY_INFO;
901  entry++;
902 
903  sprintf(entry->name, "%s:unallocated_memory", sanitized_name);
904  strncpy(entry->description, "Uncallocated FB memory (in bytes).", PAPI_MAX_STR_LEN);
906  entry->type = FEATURE_MEMORY_INFO;
907  entry++;
908 
909  sprintf(entry->name, "%s:allocated_memory", sanitized_name);
910  strncpy(entry->description, "Allocated FB memory (in bytes). Note that the driver/GPU always sets aside a small amount of memory for bookkeeping.", PAPI_MAX_STR_LEN);
912  entry->type = FEATURE_MEMORY_INFO;
913  entry++;
914  }
915 
917  sprintf(entry->name, "%s:pstate", sanitized_name);
918  strncpy(entry->description, "The performance state of the device.", PAPI_MAX_STR_LEN);
919  entry->type = FEATURE_PERF_STATES;
920  entry++;
921  }
922 
924  sprintf(entry->name, "%s:power", sanitized_name);
925  // set the power event units value to "mW" for miliwatts
926  strncpy(entry->units, "mW", PAPI_MIN_STR_LEN);
927  strncpy(entry->description, "Power usage reading for the device, in miliwatts. This is the power draw (+/-5 watts) for the entire board: GPU, memory, etc.", PAPI_MAX_STR_LEN);
928  entry->type = FEATURE_POWER;
929  entry++;
930  }
931 
932  if (HAS_FEATURE(features[i], FEATURE_TEMP)) {
933  sprintf(entry->name, "%s:temperature", sanitized_name);
934  strncpy(entry->description, "Current temperature readings for the device, in degrees C.", PAPI_MAX_STR_LEN);
935  entry->type = FEATURE_TEMP;
936  entry++;
937  }
938 
940  sprintf(entry->name, "%s:total_ecc_errors", sanitized_name);
941  strncpy(entry->description, "Total single bit errors.", PAPI_MAX_STR_LEN);
942  entry->options.ecc_opts = (struct local_ecc) {
943  .bits = NVML_SINGLE_BIT_ECC,
944  };
946  entry++;
947 
948  sprintf(entry->name, "%s:total_ecc_errors", sanitized_name);
949  strncpy(entry->description, "Total double bit errors.", PAPI_MAX_STR_LEN);
950  entry->options.ecc_opts = (struct local_ecc) {
951  .bits = NVML_DOUBLE_BIT_ECC,
952  };
954  entry++;
955  }
956 
958  sprintf(entry->name, "%s:gpu_utilization", sanitized_name);
959  strncpy(entry->description, "Percent of time over the past second during which one or more kernels was executing on the GPU.", PAPI_MAX_STR_LEN);
961  entry->type = FEATURE_UTILIZATION;
962  entry++;
963 
964  sprintf(entry->name, "%s:memory_utilization", sanitized_name);
965  strncpy(entry->description, "Percent of time over the past second during which global (device) memory was being read or written.", PAPI_MAX_STR_LEN);
967  entry->type = FEATURE_UTILIZATION;
968  entry++;
969  }
970 
972  sprintf(entry->name, "%s:power_management_limit", sanitized_name);
973  // set the power event units value to "mW" for milliwatts
974  strncpy(entry->units, "mW", PAPI_MIN_STR_LEN);
975  strncpy(entry->description, "Power management limit in milliwatts associated with the device. The power limit defines the upper boundary for the cards power draw. If the cards total power draw reaches this limit the power management algorithm kicks in. This should be writable (with appropriate privileges) on supported Kepler or later (unit milliWatts). ", PAPI_MAX_STR_LEN);
977  entry++;
978  }
980  sprintf(entry->name, "%s:power_management_limit_constraint_min", sanitized_name);
981  strncpy(entry->units, "mW", PAPI_MIN_STR_LEN);
982  strncpy(entry->description, "The minimum power management limit in milliwatts.", PAPI_MAX_STR_LEN);
984  entry++;
985  }
986 
988  sprintf(entry->name, "%s:power_management_limit_constraint_max", sanitized_name);
989  strncpy(entry->units, "mW", PAPI_MIN_STR_LEN);
990  strncpy(entry->description, "The maximum power management limit in milliwatts.", PAPI_MAX_STR_LEN);
992  entry++;
993  }
994 
995  strncpy(names[i], name, sizeof(names[0]) - 1);
996  names[i][sizeof(names[0]) - 1] = '\0';
997  }
998 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
#define FEATURE_NVML_POWER_MANAGEMENT_LIMIT_CONSTRAINT_MIN
Definition: linux-nvml.h:17
#define FEATURE_ECC_LOCAL_ERRORS
Definition: linux-nvml.h:7
int type
Definition: linux-nvml.h:53
#define papi_malloc(a)
Definition: papi_memory.h:34
#define MEMINFO_TOTAL_MEMORY
Definition: linux-nvml.h:22
#define FEATURE_ECC_TOTAL_ERRORS
Definition: linux-nvml.h:14
static int num_events
Definition: linux-nvml.c:161
struct local_ecc ecc_opts
Definition: linux-nvml.h:44
#define FEATURE_FAN_SPEED
Definition: linux-nvml.h:8
struct cache_ent * entry
Definition: libasync.c:1170
nvmlEccBitType_t bits
Definition: linux-nvml.h:38
#define LOCAL_ECC_MEM
Definition: linux-nvml.h:29
char name[PAPI_MAX_STR_LEN]
Definition: linux-nvml.h:50
static nvml_native_event_entry_t * nvml_native_table
Definition: linux-nvml.c:155
#define MEMINFO_ALLOCED
Definition: linux-nvml.h:24
long long ret
Definition: iozone.c:1346
#define FEATURE_UTILIZATION
Definition: linux-nvml.h:15
#define FEATURE_CLOCK_INFO
Definition: linux-nvml.h:6
nvml_resource_options_t options
Definition: linux-nvml.h:49
static nvmlDevice_t * devices
Definition: linux-nvml.c:163
#define FEATURE_MAX_CLOCK
Definition: linux-nvml.h:9
int i
Definition: fileop.c:140
Definition: linux-nvml.h:48
static int device_count
Definition: linux-nvml.c:158
#define MEMORY_UTILIZATION
Definition: linux-nvml.h:32
#define FEATURE_PERF_STATES
Definition: linux-nvml.h:11
nvmlClockType_t clock
Definition: linux-nvml.h:43
#define FEATURE_TEMP
Definition: linux-nvml.h:13
#define FEATURE_NVML_POWER_MANAGEMENT_LIMIT_CONSTRAINT_MAX
Definition: linux-nvml.h:18
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static int * features
Definition: linux-nvml.c:164
#define FEATURE_POWER
Definition: linux-nvml.h:12
char units[PAPI_MIN_STR_LEN]
Definition: linux-nvml.h:51
char description[PAPI_MAX_STR_LEN]
Definition: linux-nvml.h:52
char * name
Definition: iozone.c:23648
#define PAPI_MIN_STR_LEN
Definition: papi.h:464
#define LOCAL_ECC_L1
Definition: linux-nvml.h:27
#define HAS_FEATURE(features, query)
Definition: linux-nvml.h:20
#define PAPI_MAX_STR_LEN
Definition: papi.h:465
#define GPU_UTILIZATION
Definition: linux-nvml.h:31
#define FEATURE_POWER_MANAGEMENT
Definition: linux-nvml.h:16
#define LOCAL_ECC_REGFILE
Definition: linux-nvml.h:26
long j
Definition: iozone.c:19135
#define FEATURE_MEMORY_INFO
Definition: linux-nvml.h:10
ssize_t retval
Definition: libasync.c:338
#define LOCAL_ECC_L2
Definition: linux-nvml.h:28
const char * names[NUM_EVENTS]
#define MEMINFO_UNALLOCED
Definition: linux-nvml.h:23

Here is the call graph for this function:

Here is the caller graph for this function:

static int detectDevices ( )
static

Definition at line 564 of file linux-nvml.c.

565 {
566  nvmlReturn_t ret;
567  nvmlEnableState_t mode = NVML_FEATURE_DISABLED;
568 
569  char name[64];
570  char inforomECC[16];
571  char inforomPower[16];
572  char names[device_count][64];
573 
574  float ecc_version = 0.0;
575  float power_version = 0.0;
576 
577  int i = 0;
578  int isTesla = 0;
579  int isFermi = 0;
580 
581  unsigned int temp = 0;
582 
583  memset(names, 0x0, device_count * 64);
584 
585  /* So for each card, check whats querable */
586  for (i = 0; i < device_count; i++) {
587  isTesla = 0;
588  isFermi = 1;
589  features[i] = 0;
590 
591  ret = (*nvmlDeviceGetHandleByIndexPtr)(i, &devices[i]);
592  if (NVML_SUCCESS != ret) {
593  SUBDBG("nvmlDeviceGetHandleByIndex(%d, &devices[%d]) failed.\n", i, i);
594  return PAPI_ESYS;
595  }
596 
597  ret = (*nvmlDeviceGetNamePtr)(devices[i], name, sizeof(name) - 1);
598  if (NVML_SUCCESS != ret) {
599  SUBDBG("nvmlDeviceGetName failed \n");
600  strncpy(name, "deviceNameUnknown", 17);
601  }
602 
603  name[sizeof(name) - 1] = '\0'; // to safely use strstr operation below, the variable 'name' must be null terminated
604 
605  ret = (*nvmlDeviceGetInforomVersionPtr)(devices[i], NVML_INFOROM_ECC, inforomECC, 16);
606  if (NVML_SUCCESS != ret) {
607  SUBDBG("nvmlGetInforomVersion fails %s\n", (*nvmlErrorStringPtr)(ret));
608  isFermi = 0;
609  }
610  ret = (*nvmlDeviceGetInforomVersionPtr)(devices[i], NVML_INFOROM_POWER, inforomPower, 16);
611  if (NVML_SUCCESS != ret) {
612  /* This implies the card is older then Fermi */
613  SUBDBG("nvmlGetInforomVersion fails %s\n", (*nvmlErrorStringPtr)(ret));
614  SUBDBG("Based upon the return to nvmlGetInforomVersion, we conclude this card is older then Fermi.\n");
615  isFermi = 0;
616  }
617 
618  ecc_version = strtof(inforomECC, NULL);
619  power_version = strtof(inforomPower, NULL);
620 
621  isTesla = (NULL == strstr(name, "Tesla")) ? 0 : 1;
622 
623  /* For Tesla and Quadro products from Fermi and Kepler families. */
624  if (isFermi) {
626  num_events += 3;
627  }
628 
629  /* For Tesla and Quadro products from Fermi and Kepler families.
630  requires NVML_INFOROM_ECC 2.0 or higher for location-based counts
631  requires NVML_INFOROM_ECC 1.0 or higher for all other ECC counts
632  requires ECC mode to be enabled. */
633  ret = (*nvmlDeviceGetEccModePtr)(devices[i], &mode, NULL);
634  if (NVML_SUCCESS == ret) {
635  if (NVML_FEATURE_ENABLED == mode) {
636  if (ecc_version >= 2.0) {
638  num_events += 8; /* {single bit, two bit errors} x { reg, l1, l2, memory } */
639  }
640  if (ecc_version >= 1.0) {
642  num_events += 2; /* single bit errors, double bit errors */
643  }
644  }
645  } else {
646  SUBDBG("nvmlDeviceGetEccMode does not appear to be supported. (nvml return code %d)\n", ret);
647  }
648 
649  /* For all discrete products with dedicated fans */
651  num_events++;
652 
653  /* For Tesla and Quadro products from Fermi and Kepler families. */
654  if (isFermi) {
656  num_events += 3;
657  }
658 
659  /* For all products */
661  num_events += 3; /* total, free, used */
662 
663  /* For Tesla and Quadro products from the Fermi and Kepler families. */
664  if (isFermi) {
666  num_events++;
667  }
668 
669  /* For "GF11x" Tesla and Quadro products from the Fermi family
670  requires NVML_INFOROM_POWER 3.0 or higher
671  For Tesla and Quadro products from the Kepler family
672  does not require NVML_INFOROM_POWER */
673  /* Just try reading power, if it works, enable it*/
674  ret = (*nvmlDeviceGetPowerUsagePtr)(devices[i], &temp);
675  if (NVML_SUCCESS == ret) {
677  num_events++;
678  } else {
679  SUBDBG("nvmlDeviceGetPowerUsage does not appear to be supported on this card. (nvml return code %d)\n", ret);
680  }
681 
682  /* For all discrete and S-class products. */
683  features[i] |= FEATURE_TEMP;
684  num_events++;
685 
686  // For power_management_limit
687  {
688  // Just try the call to see if it works
689  unsigned int templimit = 0;
690  ret = (*nvmlDeviceGetPowerManagementLimitPtr)(devices[i], &templimit);
691  if (ret == NVML_SUCCESS && templimit > 0) {
692  power_management_initial_limit[i] = templimit;
694  num_events += 1;
695  } else {
697  SUBDBG("nvmlDeviceGetPowerManagementLimit not appear to be supported on this card. (NVML code %d)\n", ret);
698  }
699  }
700 
701  // For power_management_limit_constraints, minimum and maximum
702  {
703  unsigned int minLimit = 0, maxLimit = 0;
704  ret = (*nvmlDeviceGetPowerManagementLimitConstraintsPtr)(devices[i], &minLimit, &maxLimit);
705  if (ret == NVML_SUCCESS) {
708  num_events += 1;
711  num_events += 1;
712  } else {
715  }
716  SUBDBG("Done nvmlDeviceGetPowerManagementLimitConstraintsPtr\n");
717  }
718 
719  /* For Tesla and Quadro products from the Fermi and Kepler families */
720  if (isFermi) {
722  num_events += 2;
723  }
724 
725  int retval = snprintf(names[i], sizeof(name), "%s:device:%d", name, i);
726  if (retval > (int)sizeof(name)) {
727  SUBDBG("Device name is too long %s:device%d", name, i);
728  return (PAPI_EINVAL);
729  }
730  names[i][sizeof(name) - 1] = '\0';
731  }
732  return PAPI_OK;
733 }
#define FEATURE_NVML_POWER_MANAGEMENT_LIMIT_CONSTRAINT_MIN
Definition: linux-nvml.h:17
static unsigned int * power_management_limit_constraint_min
Definition: linux-nvml.c:166
static unsigned int * power_management_initial_limit
Definition: linux-nvml.c:165
#define FEATURE_ECC_LOCAL_ERRORS
Definition: linux-nvml.h:7
#define FEATURE_ECC_TOTAL_ERRORS
Definition: linux-nvml.h:14
static int num_events
Definition: linux-nvml.c:161
#define FEATURE_FAN_SPEED
Definition: linux-nvml.h:8
return PAPI_OK
Definition: linux-nvml.c:497
return PAPI_EINVAL
Definition: linux-nvml.c:436
long long ret
Definition: iozone.c:1346
#define FEATURE_UTILIZATION
Definition: linux-nvml.h:15
#define FEATURE_CLOCK_INFO
Definition: linux-nvml.h:6
static nvmlDevice_t * devices
Definition: linux-nvml.c:163
#define FEATURE_MAX_CLOCK
Definition: linux-nvml.h:9
int i
Definition: fileop.c:140
static int device_count
Definition: linux-nvml.c:158
#define FEATURE_PERF_STATES
Definition: linux-nvml.h:11
#define PAPI_ESYS
Definition: papi.h:255
#define FEATURE_TEMP
Definition: linux-nvml.h:13
#define FEATURE_NVML_POWER_MANAGEMENT_LIMIT_CONSTRAINT_MAX
Definition: linux-nvml.h:18
static unsigned int * power_management_limit_constraint_max
Definition: linux-nvml.c:167
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static int * features
Definition: linux-nvml.c:164
#define FEATURE_POWER
Definition: linux-nvml.h:12
char * name
Definition: iozone.c:23648
int temp
Definition: iozone.c:22158
#define FEATURE_POWER_MANAGEMENT
Definition: linux-nvml.h:16
#define FEATURE_MEMORY_INFO
Definition: linux-nvml.h:10
ssize_t retval
Definition: libasync.c:338
const char * names[NUM_EVENTS]

Here is the caller graph for this function:

unsigned long long getClockSpeed ( nvmlDevice_t  dev,
nvmlClockType_t  which_one 
)

Definition at line 170 of file linux-nvml.c.

171 {
172  unsigned int ret = 0;
173  nvmlReturn_t bad;
174  bad = (*nvmlDeviceGetClockInfoPtr)(dev, which_one, &ret);
175 
176  if (NVML_SUCCESS != bad) {
177  SUBDBG("something went wrong %s\n", (*nvmlErrorStringPtr)(bad));
178  }
179 
180  return (unsigned long long)ret;
181 }
long long ret
Definition: iozone.c:1346
#define SUBDBG(format, args...)
Definition: papi_debug.h:63

Here is the caller graph for this function:

unsigned long long getEccLocalErrors ( nvmlDevice_t  dev,
nvmlEccBitType_t  bits,
int  which_one 
)

Definition at line 184 of file linux-nvml.c.

185 {
186  nvmlEccErrorCounts_t counts;
187 
188  nvmlReturn_t bad;
189  bad = (*nvmlDeviceGetDetailedEccErrorsPtr)(dev, bits, NVML_VOLATILE_ECC , &counts);
190 
191  if (NVML_SUCCESS != bad) {
192  SUBDBG("something went wrong %s\n", (*nvmlErrorStringPtr)(bad));
193  }
194  switch (which_one) {
195  case LOCAL_ECC_REGFILE:
196  return counts.registerFile;
197  case LOCAL_ECC_L1:
198  return counts.l1Cache;
199  case LOCAL_ECC_L2:
200  return counts.l2Cache;
201  case LOCAL_ECC_MEM:
202  return counts.deviceMemory;
203  default:
204  ;
205  }
206  return (unsigned long long) - 1;
207 }
#define LOCAL_ECC_MEM
Definition: linux-nvml.h:29
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
#define LOCAL_ECC_L1
Definition: linux-nvml.h:27
#define LOCAL_ECC_REGFILE
Definition: linux-nvml.h:26
#define LOCAL_ECC_L2
Definition: linux-nvml.h:28

Here is the caller graph for this function:

unsigned long long getFanSpeed ( nvmlDevice_t  dev)

Definition at line 210 of file linux-nvml.c.

211 {
212  unsigned int ret = 0;
213  nvmlReturn_t bad;
214  bad = (*nvmlDeviceGetFanSpeedPtr)(dev, &ret);
215 
216  if (NVML_SUCCESS != bad) {
217  SUBDBG("something went wrong %s\n", (*nvmlErrorStringPtr)(bad));
218  }
219  return (unsigned long long)ret;
220 }
long long ret
Definition: iozone.c:1346
#define SUBDBG(format, args...)
Definition: papi_debug.h:63

Here is the caller graph for this function:

unsigned long long getMaxClockSpeed ( nvmlDevice_t  dev,
nvmlClockType_t  which_one 
)

Definition at line 223 of file linux-nvml.c.

224 {
225  unsigned int ret = 0;
226  nvmlReturn_t bad;
227  bad = (*nvmlDeviceGetClockInfoPtr)(dev, which_one, &ret);
228 
229  if (NVML_SUCCESS != bad) {
230  SUBDBG("something went wrong %s\n", (*nvmlErrorStringPtr)(bad));
231  }
232  return (unsigned long long) ret;
233 }
long long ret
Definition: iozone.c:1346
#define SUBDBG(format, args...)
Definition: papi_debug.h:63

Here is the caller graph for this function:

unsigned long long getMemoryInfo ( nvmlDevice_t  dev,
int  which_one 
)

Definition at line 236 of file linux-nvml.c.

237 {
238  nvmlMemory_t meminfo;
239  nvmlReturn_t bad;
240  bad = (*nvmlDeviceGetMemoryInfoPtr)(dev, &meminfo);
241 
242  if (NVML_SUCCESS != bad) {
243  SUBDBG("something went wrong %s\n", (*nvmlErrorStringPtr)(bad));
244  }
245 
246  switch (which_one) {
248  return meminfo.total;
249  case MEMINFO_UNALLOCED:
250  return meminfo.free;
251  case MEMINFO_ALLOCED:
252  return meminfo.used;
253  default:
254  ;
255  }
256  return (unsigned long long) - 1;
257 }
#define MEMINFO_TOTAL_MEMORY
Definition: linux-nvml.h:22
#define MEMINFO_ALLOCED
Definition: linux-nvml.h:24
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
#define MEMINFO_UNALLOCED
Definition: linux-nvml.h:23

Here is the caller graph for this function:

unsigned long long getPowerManagementLimit ( nvmlDevice_t  dev)

Definition at line 377 of file linux-nvml.c.

378 {
379  unsigned int limit;
380  nvmlReturn_t rv;
381  rv = (*nvmlDeviceGetPowerManagementLimitPtr)(dev, &limit);
382  if (NVML_SUCCESS != rv) {
383  SUBDBG("something went wrong %s\n", (*nvmlErrorStringPtr)(rv));
384  return (unsigned long long) 0;
385  }
386  return (unsigned long long) limit;
387 }
#define SUBDBG(format, args...)
Definition: papi_debug.h:63

Here is the caller graph for this function:

unsigned long long getPowerUsage ( nvmlDevice_t  dev)

Definition at line 313 of file linux-nvml.c.

314 {
315  unsigned int power;
316  nvmlReturn_t bad;
317  bad = (*nvmlDeviceGetPowerUsagePtr)(dev, &power);
318 
319  if (NVML_SUCCESS != bad) {
320  SUBDBG("something went wrong %s\n", (*nvmlErrorStringPtr)(bad));
321  }
322  return (unsigned long long) power;
323 }
#define SUBDBG(format, args...)
Definition: papi_debug.h:63

Here is the caller graph for this function:

unsigned long long getPState ( nvmlDevice_t  dev)

Definition at line 260 of file linux-nvml.c.

261 {
262  unsigned int ret = 0;
263  nvmlPstates_t state = NVML_PSTATE_15;
264  nvmlReturn_t bad;
265  bad = (*nvmlDeviceGetPerformanceStatePtr)(dev, &state);
266 
267  if (NVML_SUCCESS != bad) {
268  SUBDBG("something went wrong %s\n", (*nvmlErrorStringPtr)(bad));
269  }
270  switch (state) {
271  case NVML_PSTATE_15:
272  ret++;
273  case NVML_PSTATE_14:
274  ret++;
275  case NVML_PSTATE_13:
276  ret++;
277  case NVML_PSTATE_12:
278  ret++;
279  case NVML_PSTATE_11:
280  ret++;
281  case NVML_PSTATE_10:
282  ret++;
283  case NVML_PSTATE_9:
284  ret++;
285  case NVML_PSTATE_8:
286  ret++;
287  case NVML_PSTATE_7:
288  ret++;
289  case NVML_PSTATE_6:
290  ret++;
291  case NVML_PSTATE_5:
292  ret++;
293  case NVML_PSTATE_4:
294  ret++;
295  case NVML_PSTATE_3:
296  ret++;
297  case NVML_PSTATE_2:
298  ret++;
299  case NVML_PSTATE_1:
300  ret++;
301  case NVML_PSTATE_0:
302  break;
303  case NVML_PSTATE_UNKNOWN:
304  default:
305  /* This should never happen?
306  * The API docs just state Unknown performance state... */
307  return (unsigned long long) - 1;
308  }
309  return (unsigned long long)ret;
310 }
long long ret
Definition: iozone.c:1346
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
child_idents[x-1] state
Definition: iozone.c:21341

Here is the caller graph for this function:

unsigned long long getTemperature ( nvmlDevice_t  dev)

Definition at line 326 of file linux-nvml.c.

327 {
328  unsigned int ret = 0;
329  nvmlReturn_t bad;
330  bad = (*nvmlDeviceGetTemperaturePtr)(dev, NVML_TEMPERATURE_GPU, &ret);
331 
332  if (NVML_SUCCESS != bad) {
333  SUBDBG("something went wrong %s\n", (*nvmlErrorStringPtr)(bad));
334  }
335  return (unsigned long long)ret;
336 }
long long ret
Definition: iozone.c:1346
#define SUBDBG(format, args...)
Definition: papi_debug.h:63

Here is the caller graph for this function:

unsigned long long getTotalEccErrors ( nvmlDevice_t  dev,
nvmlEccBitType_t  bits 
)

Definition at line 339 of file linux-nvml.c.

340 {
341  unsigned long long counts = 0;
342  nvmlReturn_t bad;
343  bad = (*nvmlDeviceGetTotalEccErrorsPtr)(dev, bits, NVML_VOLATILE_ECC , &counts);
344 
345  if (NVML_SUCCESS != bad) {
346  SUBDBG("something went wrong %s\n", (*nvmlErrorStringPtr)(bad));
347  }
348  return counts;
349 }
#define SUBDBG(format, args...)
Definition: papi_debug.h:63

Here is the caller graph for this function:

unsigned long long getUtilization ( nvmlDevice_t  dev,
int  which_one 
)

Definition at line 355 of file linux-nvml.c.

356 {
357  nvmlUtilization_t util;
358  nvmlReturn_t bad;
359  bad = (*nvmlDeviceGetUtilizationRatesPtr)(dev, &util);
360 
361  if (NVML_SUCCESS != bad) {
362  SUBDBG("something went wrong %s\n", (*nvmlErrorStringPtr)(bad));
363  }
364 
365  switch (which_one) {
366  case GPU_UTILIZATION:
367  return (unsigned long long) util.gpu;
368  case MEMORY_UTILIZATION:
369  return (unsigned long long) util.memory;
370  default:
371  ;
372  }
373 
374  return (unsigned long long) - 1;
375 }
#define MEMORY_UTILIZATION
Definition: linux-nvml.h:32
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
#define GPU_UTILIZATION
Definition: linux-nvml.h:31

Here is the caller graph for this function:

static int linkCudaLibraries ( )
static

Definition at line 1099 of file linux-nvml.c.

1100 {
1101  /* Attempt to guess if we were statically linked to libc, if so bail */
1102  if (_dl_non_dynamic_init != NULL) {
1103  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML component does not support statically linking of libc.", PAPI_MAX_STR_LEN);
1104  return PAPI_ENOSUPP;
1105  }
1106 
1107  /* Need to link in the cuda libraries, if not found disable the component */
1108  dl1 = dlopen("libcuda.so", RTLD_NOW | RTLD_GLOBAL);
1109  if (!dl1) {
1110  strncpy(_nvml_vector.cmp_info.disabled_reason, "CUDA library libcuda.so not found.", PAPI_MAX_STR_LEN);
1111  return (PAPI_ENOSUPP);
1112  }
1113  cuInitPtr = dlsym(dl1, "cuInit");
1114  if (dlerror() != NULL) {
1115  strncpy(_nvml_vector.cmp_info.disabled_reason, "CUDA function cuInit not found.", PAPI_MAX_STR_LEN);
1116  return (PAPI_ENOSUPP);
1117  }
1118 
1119  dl2 = dlopen("libcudart.so", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
1120  if (!dl2) {
1121  strncpy(_nvml_vector.cmp_info.disabled_reason, "CUDA runtime library libcudart.so not found.", PAPI_MAX_STR_LEN);
1122  return (PAPI_ENOSUPP);
1123  }
1124  cudaGetDevicePtr = dlsym(dl2, "cudaGetDevice");
1125  if (dlerror() != NULL) {
1126  strncpy(_nvml_vector.cmp_info.disabled_reason, "CUDART function cudaGetDevice not found.", PAPI_MAX_STR_LEN);
1127  return (PAPI_ENOSUPP);
1128  }
1129  cudaGetDeviceCountPtr = dlsym(dl2, "cudaGetDeviceCount");
1130  if (dlerror() != NULL) {
1131  strncpy(_nvml_vector.cmp_info.disabled_reason, "CUDART function cudaGetDeviceCount not found.", PAPI_MAX_STR_LEN);
1132  return (PAPI_ENOSUPP);
1133  }
1134  cudaDeviceGetPCIBusIdPtr = dlsym(dl2, "cudaDeviceGetPCIBusId");
1135  if (dlerror() != NULL) {
1136  strncpy(_nvml_vector.cmp_info.disabled_reason, "CUDART function cudaDeviceGetPCIBusId not found.", PAPI_MAX_STR_LEN);
1137  return (PAPI_ENOSUPP);
1138  }
1139 
1140  dl3 = dlopen("libnvidia-ml.so", RTLD_NOW | RTLD_GLOBAL);
1141  if (!dl3) {
1142  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML runtime library libnvidia-ml.so not found.", PAPI_MAX_STR_LEN);
1143  return (PAPI_ENOSUPP);
1144  }
1145  nvmlDeviceGetClockInfoPtr = dlsym(dl3, "nvmlDeviceGetClockInfo");
1146  if (dlerror() != NULL) {
1147  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlDeviceGetClockInfo not found.", PAPI_MAX_STR_LEN);
1148  return (PAPI_ENOSUPP);
1149  }
1150  nvmlErrorStringPtr = dlsym(dl3, "nvmlErrorString");
1151  if (dlerror() != NULL) {
1152  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlErrorString not found.", PAPI_MAX_STR_LEN);
1153  return (PAPI_ENOSUPP);
1154  }
1155  nvmlDeviceGetDetailedEccErrorsPtr = dlsym(dl3, "nvmlDeviceGetDetailedEccErrors");
1156  if (dlerror() != NULL) {
1157  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlDeviceGetDetailedEccErrors not found.", PAPI_MAX_STR_LEN);
1158  return (PAPI_ENOSUPP);
1159  }
1160  nvmlDeviceGetFanSpeedPtr = dlsym(dl3, "nvmlDeviceGetFanSpeed");
1161  if (dlerror() != NULL) {
1162  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlDeviceGetFanSpeed not found.", PAPI_MAX_STR_LEN);
1163  return (PAPI_ENOSUPP);
1164  }
1165  nvmlDeviceGetMemoryInfoPtr = dlsym(dl3, "nvmlDeviceGetMemoryInfo");
1166  if (dlerror() != NULL) {
1167  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlDeviceGetMemoryInfo not found.", PAPI_MAX_STR_LEN);
1168  return (PAPI_ENOSUPP);
1169  }
1170  nvmlDeviceGetPerformanceStatePtr = dlsym(dl3, "nvmlDeviceGetPerformanceState");
1171  if (dlerror() != NULL) {
1172  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlDeviceGetPerformanceState not found.", PAPI_MAX_STR_LEN);
1173  return (PAPI_ENOSUPP);
1174  }
1175  nvmlDeviceGetPowerUsagePtr = dlsym(dl3, "nvmlDeviceGetPowerUsage");
1176  if (dlerror() != NULL) {
1177  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlDeviceGetPowerUsage not found.", PAPI_MAX_STR_LEN);
1178  return (PAPI_ENOSUPP);
1179  }
1180  nvmlDeviceGetTemperaturePtr = dlsym(dl3, "nvmlDeviceGetTemperature");
1181  if (dlerror() != NULL) {
1182  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlDeviceGetTemperature not found.", PAPI_MAX_STR_LEN);
1183  return (PAPI_ENOSUPP);
1184  }
1185  nvmlDeviceGetTotalEccErrorsPtr = dlsym(dl3, "nvmlDeviceGetTotalEccErrors");
1186  if (dlerror() != NULL) {
1187  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlDeviceGetTotalEccErrors not found.", PAPI_MAX_STR_LEN);
1188  return (PAPI_ENOSUPP);
1189  }
1190  nvmlDeviceGetUtilizationRatesPtr = dlsym(dl3, "nvmlDeviceGetUtilizationRates");
1191  if (dlerror() != NULL) {
1192  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlDeviceGetUtilizationRates not found.", PAPI_MAX_STR_LEN);
1193  return (PAPI_ENOSUPP);
1194  }
1195  nvmlDeviceGetHandleByIndexPtr = dlsym(dl3, "nvmlDeviceGetHandleByIndex");
1196  if (dlerror() != NULL) {
1197  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlDeviceGetHandleByIndex not found.", PAPI_MAX_STR_LEN);
1198  return (PAPI_ENOSUPP);
1199  }
1200  nvmlDeviceGetPciInfoPtr = dlsym(dl3, "nvmlDeviceGetPciInfo");
1201  if (dlerror() != NULL) {
1202  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlDeviceGetPciInfo not found.", PAPI_MAX_STR_LEN);
1203  return (PAPI_ENOSUPP);
1204  }
1205  nvmlDeviceGetNamePtr = dlsym(dl3, "nvmlDeviceGetName");
1206  if (dlerror() != NULL) {
1207  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlDeviceGetName not found.", PAPI_MAX_STR_LEN);
1208  return (PAPI_ENOSUPP);
1209  }
1210  nvmlDeviceGetInforomVersionPtr = dlsym(dl3, "nvmlDeviceGetInforomVersion");
1211  if (dlerror() != NULL) {
1212  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlDeviceGetInforomVersion not found.", PAPI_MAX_STR_LEN);
1213  return (PAPI_ENOSUPP);
1214  }
1215  nvmlDeviceGetEccModePtr = dlsym(dl3, "nvmlDeviceGetEccMode");
1216  if (dlerror() != NULL) {
1217  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlDeviceGetEccMode not found.", PAPI_MAX_STR_LEN);
1218  return (PAPI_ENOSUPP);
1219  }
1220  nvmlInitPtr = dlsym(dl3, "nvmlInit");
1221  if (dlerror() != NULL) {
1222  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlInit not found.", PAPI_MAX_STR_LEN);
1223  return (PAPI_ENOSUPP);
1224  }
1225  nvmlDeviceGetCountPtr = dlsym(dl3, "nvmlDeviceGetCount");
1226  if (dlerror() != NULL) {
1227  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlDeviceGetCount not found.", PAPI_MAX_STR_LEN);
1228  return (PAPI_ENOSUPP);
1229  }
1230  nvmlShutdownPtr = dlsym(dl3, "nvmlShutdown");
1231  if (dlerror() != NULL) {
1232  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlShutdown not found.", PAPI_MAX_STR_LEN);
1233  return (PAPI_ENOSUPP);
1234  }
1235  nvmlDeviceGetPowerManagementLimitPtr = dlsym(dl3, "nvmlDeviceGetPowerManagementLimit");
1236  if (dlerror() != NULL) {
1237  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlDeviceGetPowerManagementLimit not found.", PAPI_MAX_STR_LEN);
1238  return (PAPI_ENOSUPP);
1239  }
1240  nvmlDeviceSetPowerManagementLimitPtr = dlsym(dl3, "nvmlDeviceSetPowerManagementLimit");
1241  if (dlerror() != NULL) {
1242  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlDeviceSetPowerManagementLimit not found.", PAPI_MAX_STR_LEN);
1243  return (PAPI_ENOSUPP);
1244  }
1245  nvmlDeviceGetPowerManagementLimitConstraintsPtr = dlsym(dl3, "nvmlDeviceGetPowerManagementLimitConstraints");
1246  if (dlerror() != NULL) {
1247  strncpy(_nvml_vector.cmp_info.disabled_reason, "NVML function nvmlDeviceGetPowerManagementLimitConstraints not found.", PAPI_MAX_STR_LEN);
1248  return (PAPI_ENOSUPP);
1249  }
1250  return (PAPI_OK);
1251 }
#define PAPI_ENOSUPP
Definition: papi.h:271
return PAPI_OK
Definition: linux-nvml.c:497
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
static void * dl1
Definition: linux-cuda.c:84
papi_vector_t _nvml_vector
Definition: linux-nvml.c:1610
char disabled_reason[PAPI_MAX_STR_LEN]
Definition: papi.h:636
static void * dl2
Definition: linux-cuda.c:85
void(* _dl_non_dynamic_init)(void)
Definition: linux-cuda.c:160
static void * dl3
Definition: linux-cuda.c:86
#define PAPI_MAX_STR_LEN
Definition: papi.h:465

Here is the caller graph for this function:

static void nvml_hardware_reset ( )
static

Definition at line 390 of file linux-nvml.c.

391 {
392  /* nvmlDeviceSet* and nvmlDeviceClear* calls require root/admin access, so while
393  * possible to implement a reset on the ECC counters, we pass */
394  /*
395  for ( i=0; i < device_count; i++ )
396  nvmlDeviceClearEccErrorCounts( device[i], NVML_VOLATILE_ECC );
397  */
398  int i;
399  nvmlReturn_t ret;
400  unsigned int templimit = 0;
401  for (i = 0; i < device_count; i++) {
403  // if power management is available
404  if (power_management_initial_limit[i] != 0) {
405  ret = (*nvmlDeviceGetPowerManagementLimitPtr)(devices[i], &templimit);
406  if ((ret == NVML_SUCCESS) && (templimit != power_management_initial_limit[i])) {
407  SUBDBG("Reset power_management_limit on device %d to initial value of %d \n", i, power_management_initial_limit[i]);
408  // if power is not at its initial value
409  // reset to initial value
410  ret = (*nvmlDeviceSetPowerManagementLimitPtr)(devices[i], power_management_initial_limit[i]);
411  if (ret != NVML_SUCCESS)
412  SUBDBG("Unable to reset the NVML power management limit on device %i to %ull (return code %d) \n", i, power_management_initial_limit[i] , ret);
413  }
414  }
415  }
416  }
417 }
static unsigned int * power_management_initial_limit
Definition: linux-nvml.c:165
long long ret
Definition: iozone.c:1346
static nvmlDevice_t * devices
Definition: linux-nvml.c:163
int i
Definition: fileop.c:140
static int device_count
Definition: linux-nvml.c:158
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static int * features
Definition: linux-nvml.c:164
#define HAS_FEATURE(features, query)
Definition: linux-nvml.h:20
#define FEATURE_POWER_MANAGEMENT
Definition: linux-nvml.h:16

Here is the caller graph for this function:

static int nvml_hardware_write ( long long value,
int  which_one 
)
static

Code that reads event values.

Definition at line 503 of file linux-nvml.c.

504 {
506  nvmlDevice_t handle;
507  int cudaIdx = -1;
508  nvmlReturn_t nvret;
509 
510  entry = &nvml_native_table[which_one];
511  /* replace entry->resources with the current cuda_device->nvml device */
512  (*cudaGetDevicePtr)(&cudaIdx);
513 
514  if (cudaIdx < 0 || cudaIdx > device_count)
515  return PAPI_EINVAL;
516 
517  /* Make sure the device we are running on has the requested event */
518  if (!HAS_FEATURE(features[cudaIdx] , entry->type))
519  return PAPI_EINVAL;
520 
521  handle = devices[cudaIdx];
522 
523  switch (entry->type) {
525  unsigned int setToPower = (unsigned int) * value;
526  if (setToPower < power_management_limit_constraint_min[cudaIdx]) {
527  SUBDBG("Error: Desired power %u mW < minimum %u mW on device %d\n", setToPower, power_management_limit_constraint_min[cudaIdx], cudaIdx);
528  return PAPI_EINVAL;
529  }
530  if (setToPower > power_management_limit_constraint_max[cudaIdx]) {
531  SUBDBG("Error: Desired power %u mW > maximum %u mW on device %d\n", setToPower, power_management_limit_constraint_max[cudaIdx], cudaIdx);
532  return PAPI_EINVAL;
533  }
534  if ((nvret = (*nvmlDeviceSetPowerManagementLimitPtr)(handle, setToPower)) != NVML_SUCCESS) {
535  SUBDBG("Error: %s\n", (*nvmlErrorStringPtr)(nvret));
536  return PAPI_EINVAL;
537  }
538  }
539  break;
540 
541  default:
542  return PAPI_EINVAL;
543  }
544 
545  return PAPI_OK;
546 }
static unsigned int * power_management_limit_constraint_min
Definition: linux-nvml.c:166
int type
Definition: linux-nvml.h:53
return PAPI_OK
Definition: linux-nvml.c:497
struct cache_ent * entry
Definition: libasync.c:1170
return PAPI_EINVAL
Definition: linux-nvml.c:436
void double value
Definition: iozone.c:18781
static nvml_native_event_entry_t * nvml_native_table
Definition: linux-nvml.c:155
static nvmlDevice_t * devices
Definition: linux-nvml.c:163
Definition: linux-nvml.h:48
static int device_count
Definition: linux-nvml.c:158
static unsigned int * power_management_limit_constraint_max
Definition: linux-nvml.c:167
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static int * features
Definition: linux-nvml.c:164
nvmlDevice_t handle
Definition: linux-nvml.c:427
int
Definition: iozone.c:18528
#define HAS_FEATURE(features, query)
Definition: linux-nvml.h:20
#define FEATURE_POWER_MANAGEMENT
Definition: linux-nvml.h:16
int cudaIdx
Definition: linux-nvml.c:428

Here is the caller graph for this function:

switch ( entry->  type)

Definition at line 444 of file linux-nvml.c.

444  {
445  case FEATURE_CLOCK_INFO:
446  *value = getClockSpeed(handle, (nvmlClockType_t)entry->options.clock);
447  break;
450  (nvmlEccBitType_t)entry->options.ecc_opts.bits,
451  (int)entry->options.ecc_opts.which_one);
452  break;
453  case FEATURE_FAN_SPEED:
455  break;
456  case FEATURE_MAX_CLOCK:
458  (nvmlClockType_t)entry->options.clock);
459  break;
460  case FEATURE_MEMORY_INFO:
462  (int)entry->options.which_one);
463  break;
464  case FEATURE_PERF_STATES:
465  *value = getPState(handle);
466  break;
467  case FEATURE_POWER:
469  break;
470  case FEATURE_TEMP:
472  break;
475  (nvmlEccBitType_t)entry->options.ecc_opts.bits);
476  break;
477  case FEATURE_UTILIZATION:
479  (int)entry->options.which_one);
480  break;
483  break;
484 
487  break;
488 
491  break;
492 
493  default:
494  return PAPI_EINVAL;
495  }
unsigned long long getPState(nvmlDevice_t dev)
Definition: linux-nvml.c:260
#define FEATURE_NVML_POWER_MANAGEMENT_LIMIT_CONSTRAINT_MIN
Definition: linux-nvml.h:17
static unsigned int * power_management_limit_constraint_min
Definition: linux-nvml.c:166
unsigned long long getTotalEccErrors(nvmlDevice_t dev, nvmlEccBitType_t bits)
Definition: linux-nvml.c:339
#define FEATURE_ECC_LOCAL_ERRORS
Definition: linux-nvml.h:7
unsigned long long getPowerUsage(nvmlDevice_t dev)
Definition: linux-nvml.c:313
#define FEATURE_ECC_TOTAL_ERRORS
Definition: linux-nvml.h:14
#define FEATURE_FAN_SPEED
Definition: linux-nvml.h:8
unsigned long long getMemoryInfo(nvmlDevice_t dev, int which_one)
Definition: linux-nvml.c:236
struct cache_ent * entry
Definition: libasync.c:1170
return PAPI_EINVAL
Definition: linux-nvml.c:436
void double value
Definition: iozone.c:18781
unsigned long long getPowerManagementLimit(nvmlDevice_t dev)
Definition: linux-nvml.c:377
#define FEATURE_UTILIZATION
Definition: linux-nvml.h:15
#define FEATURE_CLOCK_INFO
Definition: linux-nvml.h:6
#define FEATURE_MAX_CLOCK
Definition: linux-nvml.h:9
unsigned long long getEccLocalErrors(nvmlDevice_t dev, nvmlEccBitType_t bits, int which_one)
Definition: linux-nvml.c:184
#define FEATURE_PERF_STATES
Definition: linux-nvml.h:11
#define FEATURE_TEMP
Definition: linux-nvml.h:13
#define FEATURE_NVML_POWER_MANAGEMENT_LIMIT_CONSTRAINT_MAX
Definition: linux-nvml.h:18
static unsigned int * power_management_limit_constraint_max
Definition: linux-nvml.c:167
nvmlDevice_t handle
Definition: linux-nvml.c:427
#define FEATURE_POWER
Definition: linux-nvml.h:12
unsigned long long getClockSpeed(nvmlDevice_t dev, nvmlClockType_t which_one)
Definition: linux-nvml.c:170
unsigned long long getTemperature(nvmlDevice_t dev)
Definition: linux-nvml.c:326
unsigned long long getFanSpeed(nvmlDevice_t dev)
Definition: linux-nvml.c:210
#define FEATURE_POWER_MANAGEMENT
Definition: linux-nvml.h:16
unsigned long long getUtilization(nvmlDevice_t dev, int which_one)
Definition: linux-nvml.c:355
#define FEATURE_MEMORY_INFO
Definition: linux-nvml.h:10
int cudaIdx
Definition: linux-nvml.c:428
unsigned long long getMaxClockSpeed(nvmlDevice_t dev, nvmlClockType_t which_one)
Definition: linux-nvml.c:223

Here is the call graph for this function:

Variable Documentation

void(* _dl_non_dynamic_init)(void)

Holds control flags. Usually there's one of these per event-set. Usually this is out-of band configuration of the hardware

< Copy of counts, holds results when stopped

Definition at line 48 of file linux-nvml.c.

143  {
144  int num_events;
145  int which_counter[NVML_MAX_COUNTERS];
146  long long counter[NVML_MAX_COUNTERS];
static int num_events
Definition: linux-nvml.c:161
#define NVML_MAX_COUNTERS
nvml_control_state_t
Definition: linux-nvml.c:147
papi_vector_t _nvml_vector

Vector that points to entry points for our component

Definition at line 1610 of file linux-nvml.c.

(*) cudaGetDevicePtr cudaIdx) = -1

Definition at line 428 of file linux-nvml.c.

int device_count = 0
static

Number of devices detected at component_init time

Definition at line 158 of file linux-nvml.c.

nvmlDevice_t* devices = NULL
static

Definition at line 163 of file linux-nvml.c.

entry = &nvml_native_table[which_one]

Definition at line 430 of file linux-nvml.c.

int* features = NULL
static

Definition at line 164 of file linux-nvml.c.

handle = devices[cudaIdx]

Definition at line 427 of file linux-nvml.c.

int
static
Initial value:

Code that reads event values.

Definition at line 425 of file linux-nvml.c.

int num_events = 0
static

number of events in the table

Definition at line 161 of file linux-nvml.c.

nvml_control_state_t

Definition at line 147 of file linux-nvml.c.

nvml_native_event_entry_t* nvml_native_table = NULL
static

This table contains the native events

Definition at line 155 of file linux-nvml.c.

return PAPI_EINVAL

Definition at line 436 of file linux-nvml.c.

return PAPI_OK

Definition at line 497 of file linux-nvml.c.

unsigned int* power_management_initial_limit = NULL
static

Definition at line 165 of file linux-nvml.c.

unsigned int* power_management_limit_constraint_max = NULL
static

Definition at line 167 of file linux-nvml.c.

unsigned int* power_management_limit_constraint_min = NULL
static

Definition at line 166 of file linux-nvml.c.

* value = (long long) - 1

Definition at line 431 of file linux-nvml.c.