PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
linux-host_micpower.c File Reference
Include dependency graph for linux-host_micpower.c:

Go to the source code of this file.

Data Structures

struct  host_micpower_reg_alloc_t
 
struct  host_micpower_native_event_entry_t
 
struct  host_micpower_control_state_t
 
struct  host_micpower_context_t
 
struct  powers
 
union  power_t
 

Macros

#define MAX_DEVICES   (32)
 This component wraps the MicAccessAPI to provide hostside power information for attached Intel Xeon Phi (MIC) cards. More...
 
#define EVENTS_PER_DEVICE   10
 
#define UPDATEFREQ   500000
 
#define MICACCESS_API   __attribute__((weak))
 

Functions

const char * MicGetErrorString (U32)
 
U32 MICACCESS_API MicCloseAdapter (HANDLE)
 
U32 MICACCESS_API MicInitAPI (HANDLE *, ETarget, MicDeviceOnSystem *, U32 *)
 
U32 MICACCESS_API MicCloseAPI (HANDLE *)
 
U32 MICACCESS_API MicInitAdapter (HANDLE *, MicDeviceOnSystem *)
 
U32 MICACCESS_API MicGetPowerUsage (HANDLE, MicPwrUsage *)
 
static int loadFunctionPtrs ()
 
int _host_micpower_init_component (int cidx)
 
int _host_micpower_init_thread (hwd_context_t *ctx)
 
int _host_micpower_shutdown_component (void)
 
int _host_micpower_shutdown_thread (hwd_context_t *ctx)
 
int _host_micpower_init_control_state (hwd_control_state_t *ctl)
 
int _host_micpower_update_control_state (hwd_control_state_t *ctl, NativeInfo_t *info, int count, hwd_context_t *ctx)
 
int _host_micpower_start (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
static int read_power (struct powers *pwr, int which_one)
 
int _host_micpower_read (hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags)
 
int _host_micpower_stop (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
int _host_micpower_ntv_enum_events (unsigned int *EventCode, int modifier)
 
int _host_micpower_ntv_code_to_name (unsigned int EventCode, char *name, int len)
 
int _host_micpower_ntv_code_to_descr (unsigned int EventCode, char *name, int len)
 
int _host_micpower_ntv_code_to_info (unsigned int EventCode, PAPI_event_info_t *info)
 
int _host_micpower_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
 
int _host_micpower_set_domain (hwd_control_state_t *ctl, int domain)
 

Variables

void(* _dl_non_dynamic_init )(void)
 
 host_micpower_register_t
 
static MicDeviceOnSystem adapters [MAX_DEVICES]
 
static HANDLE handles [MAX_DEVICES]
 
static long long lastupdate [MAX_DEVICES]
 
static HANDLE accessHandle = NULL
 
static U32 nAdapters = MAX_DEVICES
 
static voidmic_access = NULL
 
static voidscif_access = NULL
 
const char *(* MicGetErrorStringPtr )(U32)
 
U32(* MicCloseAdapterPtr )(HANDLE)
 
U32(* MicInitAPIPtr )(HANDLE *, ETarget, MicDeviceOnSystem *, U32 *)
 
U32(* MicCloseAPIPtr )(HANDLE *)
 
U32(* MicInitAdapterPtr )(HANDLE *, MicDeviceOnSystem *)
 
U32(* MicGetPowerUsagePtr )(HANDLE, MicPwrUsage *)
 
static
host_micpower_native_event_entry_t
native_events_table = NULL
 
static power_t cached_values [MAX_DEVICES]
 
papi_vector_t _host_micpower_vector
 

Macro Definition Documentation

#define EVENTS_PER_DEVICE   10

Definition at line 14 of file linux-host_micpower.c.

#define MICACCESS_API   __attribute__((weak))

Definition at line 79 of file linux-host_micpower.c.

#define UPDATEFREQ   500000

Function Documentation

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

Definition at line 557 of file linux-host_micpower.c.

558 {
559  (void)ctx;
560  (void)code;
561  (void)option;
562  return PAPI_OK;
563 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
int _host_micpower_init_component ( int  cidx)

Definition at line 195 of file linux-host_micpower.c.

196 {
197  U32 ret = MIC_ACCESS_API_ERROR_UNKNOWN;
198  U32 adapterNum = 0;
199  U32 throwaway = 1;
200 
202 
203  if ( loadFunctionPtrs() ) {
204  goto disable_me;
205  }
206 
207  memset( lastupdate, 0x0, sizeof(lastupdate));
208  memset( cached_values, 0x0, sizeof(struct powers)*MAX_DEVICES );
209  ret = MicInitAPIPtr( &accessHandle, eTARGET_SCIF_DRIVER, adapters, &nAdapters );
210  if ( MIC_ACCESS_API_SUCCESS != ret ) {
213  goto disable_me;
214  }
215  /* Sanity check on array size */
216  if ( nAdapters >= MAX_DEVICES ) {
217  snprintf(_host_micpower_vector.cmp_info.disabled_reason, PAPI_MAX_STR_LEN, "Too many MIC cards [%d] found, bailing.", nAdapters);
219  goto disable_me;
220  }
221 
222 /* XXX: This code initializes a token for each adapter, in testing this appeared to be required/
223  * One has to call MicInitAdapter() before calling into that adapter's entries */
224  for (adapterNum=0; adapterNum < nAdapters; adapterNum++) {
225  ret = MicInitAPIPtr( &handles[adapterNum], eTARGET_SCIF_DRIVER, adapters, &throwaway );
226  throwaway = 1;
227  if (MIC_ACCESS_API_SUCCESS != ret) {
228  fprintf(stderr, "%d:MicInitAPI carps: %s\n", __LINE__, MicGetErrorStringPtr(ret));
229  nAdapters = adapterNum;
230  for (adapterNum=0; adapterNum < nAdapters; adapterNum++)
231  MicCloseAdapterPtr( handles[adapterNum] );
234  "Failed to initialize card %d's interface.", nAdapters);
235  goto disable_me;
236  }
237  ret = MicInitAdapterPtr(&handles[adapterNum], &adapters[adapterNum]);
238  if (MIC_ACCESS_API_SUCCESS != ret) {
239  fprintf(stderr, "%d:MicInitAdapter carps: %s\n", __LINE__, MicGetErrorStringPtr(ret));
240  nAdapters = adapterNum;
241  for (adapterNum=0; adapterNum < nAdapters; adapterNum++)
242  MicCloseAdapterPtr( handles[adapterNum] );
245  "Failed to initialize card %d's interface.", nAdapters);
246  goto disable_me;
247  }
248  }
249 
251  if ( NULL == native_events_table ) {
252  return PAPI_ENOMEM;
253  }
254  for (adapterNum=0; adapterNum < nAdapters; adapterNum++) {
255  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE].name, PAPI_MAX_STR_LEN, "mic%d:tot0", adapterNum);
256  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE].description, PAPI_MAX_STR_LEN, "Total power utilization, Averaged over Time Window 0 (uWatts)");
257  native_events_table[adapterNum*EVENTS_PER_DEVICE].resources.selector = adapterNum*EVENTS_PER_DEVICE + 1;
258  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE].units, PAPI_MIN_STR_LEN, "uW");
259 
260  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 1].name, PAPI_MAX_STR_LEN, "mic%d:tot1", adapterNum);
261  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 1].description, PAPI_MAX_STR_LEN, "Total power utilization, Averaged over Time Window 1 (uWatts)");
262  native_events_table[adapterNum*EVENTS_PER_DEVICE + 1].resources.selector = adapterNum*EVENTS_PER_DEVICE + 2;
263  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 1].units, PAPI_MIN_STR_LEN, "uW");
264 
265  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 2].name, PAPI_MAX_STR_LEN, "mic%d:pcie", adapterNum);
266  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 2].description, PAPI_MAX_STR_LEN, "PCI-E connector power (uWatts)");
267  native_events_table[adapterNum*EVENTS_PER_DEVICE + 2].resources.selector = adapterNum*EVENTS_PER_DEVICE + 3;
268  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 2].units, PAPI_MIN_STR_LEN, "uW");
269 
270  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 3].name, PAPI_MAX_STR_LEN, "mic%d:inst", adapterNum);
271  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 3].description, PAPI_MAX_STR_LEN, "Instantaneous power (uWatts)");
272  native_events_table[adapterNum*EVENTS_PER_DEVICE + 3].resources.selector = adapterNum*EVENTS_PER_DEVICE + 4;
273  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 3].units, PAPI_MIN_STR_LEN, "uW");
274 
275  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 4].name, PAPI_MAX_STR_LEN, "mic%d:imax", adapterNum);
276  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 4].description, PAPI_MAX_STR_LEN, "Max instantaneous power (uWatts)");
277  native_events_table[adapterNum*EVENTS_PER_DEVICE + 4].resources.selector = adapterNum*EVENTS_PER_DEVICE + 5;
278  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 4].units, PAPI_MIN_STR_LEN, "uW");
279 
280  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 5].name, PAPI_MAX_STR_LEN, "mic%d:c2x3", adapterNum);
281  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 5].description, PAPI_MAX_STR_LEN, "2x3 connector power (uWatts)");
282  native_events_table[adapterNum*EVENTS_PER_DEVICE + 5].resources.selector = adapterNum*EVENTS_PER_DEVICE + 6;
283  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 5].units, PAPI_MIN_STR_LEN, "uW");
284 
285  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 6].name, PAPI_MAX_STR_LEN, "mic%d:c2x4", adapterNum);
286  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 6].description, PAPI_MAX_STR_LEN, "2x4 connector power (uWatts)");
287  native_events_table[adapterNum*EVENTS_PER_DEVICE + 6].resources.selector = adapterNum*EVENTS_PER_DEVICE + 7;
288  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 6].units, PAPI_MIN_STR_LEN, "uW");
289 
290  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 7].name, PAPI_MAX_STR_LEN, "mic%d:vccp", adapterNum);
291  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 7].description, PAPI_MAX_STR_LEN, "Core rail (uVolts)");
292  native_events_table[adapterNum*EVENTS_PER_DEVICE + 7].resources.selector = adapterNum*EVENTS_PER_DEVICE + 8;
293  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 7].units, PAPI_MIN_STR_LEN, "uV");
294 
295  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 8].name, PAPI_MAX_STR_LEN, "mic%d:vddg", adapterNum);
296  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 8].description, PAPI_MAX_STR_LEN, "Uncore rail (uVolts)");
297  native_events_table[adapterNum*EVENTS_PER_DEVICE + 8].resources.selector = adapterNum*EVENTS_PER_DEVICE + 9;
298  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 8].units, PAPI_MIN_STR_LEN, "uV");
299 
300  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 9].name, PAPI_MAX_STR_LEN, "mic%d:vddq", adapterNum);
301  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 9].description, PAPI_MAX_STR_LEN, "Memory subsystem rail (uVolts)");
302  native_events_table[adapterNum*EVENTS_PER_DEVICE + 9].resources.selector = adapterNum*EVENTS_PER_DEVICE + 10;
303  snprintf(native_events_table[adapterNum*EVENTS_PER_DEVICE + 9].units, PAPI_MIN_STR_LEN, "uV");
304  }
305 
308 
310 
311  return PAPI_OK;
312 
313 disable_me:
318 
319  nAdapters = 0;
320  return PAPI_ENOSUPP;
321 }
static HANDLE handles[MAX_DEVICES]
memset(eventId, 0, size)
papi_vector_t _host_micpower_vector
#define papi_malloc(a)
Definition: papi_memory.h:34
#define PAPI_ENOSUPP
Definition: papi.h:269
const char *(* MicGetErrorStringPtr)(U32)
#define MAX_DEVICES
This component wraps the MicAccessAPI to provide hostside power information for attached Intel Xeon P...
host_micpower_register_t resources
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
long long ret
Definition: iozone.c:1346
U32(* MicInitAdapterPtr)(HANDLE *, MicDeviceOnSystem *)
char disabled_reason[PAPI_MAX_STR_LEN]
Definition: papi.h:633
static power_t cached_values[MAX_DEVICES]
static MicDeviceOnSystem adapters[MAX_DEVICES]
static host_micpower_native_event_entry_t * native_events_table
#define EVENTS_PER_DEVICE
static int cidx
Definition: event_info.c:40
static U32 nAdapters
U32(* MicCloseAPIPtr)(HANDLE *)
static long long lastupdate[MAX_DEVICES]
U32(* MicInitAPIPtr)(HANDLE *, ETarget, MicDeviceOnSystem *, U32 *)
#define PAPI_ENOMEM
Definition: papi.h:252
static HANDLE accessHandle
static int loadFunctionPtrs()
char * name
Definition: iozone.c:23648
#define PAPI_MIN_STR_LEN
Definition: papi.h:462
#define PAPI_MAX_STR_LEN
Definition: papi.h:463
U32(* MicCloseAdapterPtr)(HANDLE)

Here is the call graph for this function:

int _host_micpower_init_control_state ( hwd_control_state_t ctl)

Definition at line 345 of file linux-host_micpower.c.

345  {
347  memset( state, 0, sizeof(host_micpower_control_state_t));
348 
349  return PAPI_OK;
350 }
memset(eventId, 0, size)
return PAPI_OK
Definition: linux-nvml.c:458
child_idents[x-1] state
Definition: iozone.c:21341

Here is the call graph for this function:

int _host_micpower_init_thread ( hwd_context_t ctx)

Definition at line 323 of file linux-host_micpower.c.

323  {
324  (void)ctx;
325  return PAPI_OK;
326 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
int _host_micpower_ntv_code_to_descr ( unsigned int  EventCode,
char *  name,
int  len 
)

Definition at line 533 of file linux-host_micpower.c.

534 {
535  unsigned int code = EventCode & PAPI_NATIVE_AND_MASK;
537  strncpy( name, native_events_table[code].description, len );
538  return PAPI_OK;
539  }
540 
541  return PAPI_ENOEVNT;
542 }
#define PAPI_ENOEVNT
Definition: papi.h:258
papi_vector_t _host_micpower_vector
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
static host_micpower_native_event_entry_t * native_events_table
char * name
Definition: iozone.c:23648
#define PAPI_NATIVE_AND_MASK
int _host_micpower_ntv_code_to_info ( unsigned int  EventCode,
PAPI_event_info_t info 
)

Definition at line 545 of file linux-host_micpower.c.

546 {
547  unsigned int code = EventCode & PAPI_NATIVE_AND_MASK;
549  return PAPI_ENOEVNT;
550  strncpy( info->symbol, native_events_table[code].name, sizeof(info->symbol) );
551  strncpy( info->long_descr, native_events_table[code].description, sizeof(info->long_descr) );
552  strncpy( info->units, native_events_table[code].units, sizeof(info->units) );
553  return PAPI_OK;
554 }
#define PAPI_ENOEVNT
Definition: papi.h:258
papi_vector_t _host_micpower_vector
char name[PAPI_MAX_STR_LEN]
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:966
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
static host_micpower_native_event_entry_t * native_events_table
#define PAPI_NATIVE_AND_MASK
char units[3]
char description[PAPI_MAX_STR_LEN]
char units[PAPI_MIN_STR_LEN]
Definition: papi.h:972
int _host_micpower_ntv_code_to_name ( unsigned int  EventCode,
char *  name,
int  len 
)

Definition at line 521 of file linux-host_micpower.c.

522 {
523  unsigned int code = EventCode & PAPI_NATIVE_AND_MASK;
525  strncpy( name, native_events_table[code].name, len);
526  return PAPI_OK;
527  }
528 
529  return PAPI_ENOEVNT;
530 }
#define PAPI_ENOEVNT
Definition: papi.h:258
papi_vector_t _host_micpower_vector
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
static host_micpower_native_event_entry_t * native_events_table
char * name
Definition: iozone.c:23648
#define PAPI_NATIVE_AND_MASK
int _host_micpower_ntv_enum_events ( unsigned int EventCode,
int  modifier 
)

Definition at line 496 of file linux-host_micpower.c.

497 {
498  int index;
499  switch (modifier) {
500  case PAPI_ENUM_FIRST:
502  return PAPI_ENOEVNT;
503  *EventCode = 0;
504  return PAPI_OK;
505  case PAPI_ENUM_EVENTS:
506  index = *EventCode;
507  if ( index < _host_micpower_vector.cmp_info.num_cntrs - 1) {
508  *EventCode = *EventCode + 1;
509  return PAPI_OK;
510  } else {
511  return PAPI_ENOEVNT;
512  }
513  break;
514  default:
515  return PAPI_EINVAL;
516  }
517  return PAPI_EINVAL;
518 }
#define PAPI_ENOEVNT
Definition: papi.h:258
papi_vector_t _host_micpower_vector
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
int _host_micpower_read ( hwd_context_t ctx,
hwd_control_state_t ctl,
long long **  events,
int  flags 
)

Definition at line 415 of file linux-host_micpower.c.

417 {
418  (void)flags;
419  (void)events;
420  (void)ctx;
421  unsigned int i,j;
422  int needs_update = 0;
424  long long now = PAPI_get_real_usec();
425 
426  for( i=0; i<nAdapters; i++) {
427  needs_update = 0;
428  for (j=0; j<EVENTS_PER_DEVICE; j++) {
429  if ( control->resident[EVENTS_PER_DEVICE*i+j]) {
430  needs_update = 1;
431  break;
432  }
433  }
434 
435  if ( needs_update ) {
436  /* Do the global update */
437  if ( now >= lastupdate[i] + UPDATEFREQ) {
438  read_power( &cached_values[i].power, i );
439  lastupdate[i] = now;
440  }
441  /* update from cached values */
442  if ( control->lastupdate[i] < lastupdate[i]) {
443  control->lastupdate[i] = lastupdate[i];
444  }
445  for (j=0; j<EVENTS_PER_DEVICE; j++) {
446  if ( control->resident[EVENTS_PER_DEVICE*i+j] ) {
447  control->counts[EVENTS_PER_DEVICE*i+j] = (long long)cached_values[i].array[j];
448  }
449  }
450  }
451  }
452 
453  *events = control->counts;
454  return PAPI_OK;
455 }
long long flags
Definition: iozone.c:12330
int resident[MAX_DEVICES *EVENTS_PER_DEVICE]
long long lastupdate[MAX_DEVICES]
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
char events[MAX_EVENTS][BUFSIZ]
static power_t cached_values[MAX_DEVICES]
int i
Definition: fileop.c:140
#define EVENTS_PER_DEVICE
static U32 nAdapters
long long
Definition: iozone.c:19827
static long long lastupdate[MAX_DEVICES]
static int read_power(struct powers *pwr, int which_one)
long long PAPI_get_real_usec(void)
Definition: papi.c:6190
#define UPDATEFREQ
long long counts[MAX_DEVICES *EVENTS_PER_DEVICE]
long j
Definition: iozone.c:19135

Here is the call graph for this function:

int _host_micpower_set_domain ( hwd_control_state_t ctl,
int  domain 
)

Definition at line 566 of file linux-host_micpower.c.

567 {
568  (void)ctl;
569  if ( PAPI_DOM_ALL != domain )
570  return PAPI_EINVAL;
571  return PAPI_OK;
572 }
#define PAPI_DOM_ALL
Definition: papi.h:301
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
return PAPI_EINVAL
Definition: linux-nvml.c:408
int _host_micpower_shutdown_component ( void  )

Definition at line 329 of file linux-host_micpower.c.

329  {
330  U32 i = 0;
331  for( i=0; i<nAdapters; i++) {
333  }
334 
336  return PAPI_OK;
337 }
static HANDLE handles[MAX_DEVICES]
#define papi_free(a)
Definition: papi_memory.h:35
return PAPI_OK
Definition: linux-nvml.c:458
static host_micpower_native_event_entry_t * native_events_table
int i
Definition: fileop.c:140
static U32 nAdapters
U32(* MicCloseAdapterPtr)(HANDLE)
int _host_micpower_shutdown_thread ( hwd_context_t ctx)

Definition at line 340 of file linux-host_micpower.c.

340  {
341  (void) ctx;
342  return PAPI_OK;
343 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
int _host_micpower_start ( hwd_context_t ctx,
hwd_control_state_t ctl 
)

Definition at line 376 of file linux-host_micpower.c.

377 {
378  (void) ctx;
379  (void) ctl;
380  return PAPI_OK;
381 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
int _host_micpower_stop ( hwd_context_t ctx,
hwd_control_state_t ctl 
)

Definition at line 458 of file linux-host_micpower.c.

459 {
460  (void)ctx;
461  int needs_update = 0;
462  unsigned int i,j;
464  long long now = PAPI_get_real_usec();
465 
466  for( i=0; i<nAdapters; i++) {
467  needs_update = 0;
468  for (j=0; j<EVENTS_PER_DEVICE; j++) {
469  if ( control->resident[EVENTS_PER_DEVICE*i+j]) {
470  needs_update = 1;
471  break;
472  }
473  }
474 
475  if ( needs_update ) {
476  /* Do the global update */
477  if ( now >= lastupdate[i] + UPDATEFREQ) {
478  read_power( &cached_values[i].power, i );
479  lastupdate[i] = now;
480  }
481  /* update from cached values */
482  if ( control->lastupdate[i] < lastupdate[i]) {
483  control->lastupdate[i] = lastupdate[i];
484  }
485  for (j=0; j<EVENTS_PER_DEVICE; j++) {
486  if ( control->resident[EVENTS_PER_DEVICE*i+j] ) {
487  control->counts[EVENTS_PER_DEVICE*i+j] = (long long)cached_values[i].array[j];
488  }
489  }
490  }
491  }
492  return PAPI_OK;
493 
494 }
int resident[MAX_DEVICES *EVENTS_PER_DEVICE]
long long lastupdate[MAX_DEVICES]
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
static power_t cached_values[MAX_DEVICES]
int i
Definition: fileop.c:140
#define EVENTS_PER_DEVICE
static U32 nAdapters
long long
Definition: iozone.c:19827
static long long lastupdate[MAX_DEVICES]
static int read_power(struct powers *pwr, int which_one)
long long PAPI_get_real_usec(void)
Definition: papi.c:6190
#define UPDATEFREQ
long long counts[MAX_DEVICES *EVENTS_PER_DEVICE]
long j
Definition: iozone.c:19135

Here is the call graph for this function:

int _host_micpower_update_control_state ( hwd_control_state_t ctl,
NativeInfo_t info,
int  count,
hwd_context_t ctx 
)

Definition at line 352 of file linux-host_micpower.c.

355  {
356 
357  (void) ctx;
358  int i, index;
359 
361 
362  for (i=0; i<MAX_DEVICES*EVENTS_PER_DEVICE; i++)
363  state->resident[i] = 0;
364 
365  for (i=0; i < count; i++) {
366  index = info[i].ni_event&PAPI_NATIVE_AND_MASK;
367  info[i].ni_position=native_events_table[index].resources.selector-1;
368  state->resident[index] = 1;
369  }
370  state->num_events = count;
371 
372  return PAPI_OK;
373 }
int resident[MAX_DEVICES *EVENTS_PER_DEVICE]
#define MAX_DEVICES
This component wraps the MicAccessAPI to provide hostside power information for attached Intel Xeon P...
host_micpower_register_t resources
for(i=0;i<=max_y;i++)
Definition: iozone.c:11615
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
void
Definition: iozone.c:18627
static host_micpower_native_event_entry_t * native_events_table
int i
Definition: fileop.c:140
#define EVENTS_PER_DEVICE
child_idents[x-1] state
Definition: iozone.c:21341
#define PAPI_NATIVE_AND_MASK

Here is the call graph for this function:

static int loadFunctionPtrs ( )
static

Definition at line 116 of file linux-host_micpower.c.

117 {
118  /* Attempt to guess if we were statically linked to libc, if so bail */
119  if ( _dl_non_dynamic_init != NULL ) {
120  strncpy(_host_micpower_vector.cmp_info.disabled_reason, "The host_micpower component does not support statically linking of libc.", PAPI_MAX_STR_LEN);
121  return PAPI_ENOSUPP;
122  }
123 
124  /* Need to link in the cuda libraries, if not found disable the component */
125  scif_access = dlopen("libscif.so", RTLD_NOW | RTLD_GLOBAL);
126  if (NULL == scif_access)
127  {
128  snprintf(_host_micpower_vector.cmp_info.disabled_reason, PAPI_MAX_STR_LEN, "Problem loading the SCIF library: %s\n", dlerror());
130  return ( PAPI_ENOSUPP );
131  }
132 
133  mic_access = dlopen("libMicAccessSDK.so", RTLD_NOW | RTLD_GLOBAL);
134  if (NULL == mic_access)
135  {
136  snprintf(_host_micpower_vector.cmp_info.disabled_reason, PAPI_MAX_STR_LEN, "Problem loading libMicAccessSDK.so: %s\n", dlerror());
138  return ( PAPI_ENOSUPP );
139  }
140 
141  MicGetErrorStringPtr = dlsym(mic_access, "MicGetErrorString");
142  if (dlerror() != NULL)
143  {
144  strncpy(_host_micpower_vector.cmp_info.disabled_reason, "MicAccessSDK function MicGetErrorString not found.",PAPI_MAX_STR_LEN);
146  return ( PAPI_ENOSUPP );
147  }
148  MicCloseAdapterPtr = dlsym(mic_access, "MicCloseAdapter");
149  if (dlerror() != NULL)
150  {
151  strncpy(_host_micpower_vector.cmp_info.disabled_reason, "MicAccessSDK function MicCloseAdapter not found.",PAPI_MAX_STR_LEN);
153  return ( PAPI_ENOSUPP );
154  }
155  MicInitAPIPtr = dlsym(mic_access, "MicInitAPI");
156  if (dlerror() != NULL)
157  {
158  strncpy(_host_micpower_vector.cmp_info.disabled_reason, "MicAccessSDK function MicInitAPI not found.",PAPI_MAX_STR_LEN);
160  return ( PAPI_ENOSUPP );
161  }
162  MicCloseAPIPtr = dlsym(mic_access, "MicCloseAPI");
163  if (dlerror() != NULL)
164  {
165  strncpy(_host_micpower_vector.cmp_info.disabled_reason, "MicAccessSDK function MicCloseAPI not found.",PAPI_MAX_STR_LEN);
167  return ( PAPI_ENOSUPP );
168  }
169  MicInitAdapterPtr = dlsym(mic_access, "MicInitAdapter");
170  if (dlerror() != NULL)
171  {
172  strncpy(_host_micpower_vector.cmp_info.disabled_reason, "MicAccessSDK function MicInitAdapter not found.",PAPI_MAX_STR_LEN);
174  return ( PAPI_ENOSUPP );
175  }
176 
177  MicGetPowerUsagePtr = dlsym(mic_access, "MicGetPowerUsage");
178  if (dlerror() != NULL)
179  {
180  strncpy(_host_micpower_vector.cmp_info.disabled_reason, "MicAccessSDK function MicGetPowerUsage not found.",PAPI_MAX_STR_LEN);
182  return ( PAPI_ENOSUPP );
183  }
184 
185  return 0;
186 }
papi_vector_t _host_micpower_vector
#define PAPI_ENOSUPP
Definition: papi.h:269
const char *(* MicGetErrorStringPtr)(U32)
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
U32(* MicInitAdapterPtr)(HANDLE *, MicDeviceOnSystem *)
char disabled_reason[PAPI_MAX_STR_LEN]
Definition: papi.h:633
void(* _dl_non_dynamic_init)(void)
Definition: linux-cuda.c:41
U32(* MicGetPowerUsagePtr)(HANDLE, MicPwrUsage *)
U32(* MicCloseAPIPtr)(HANDLE *)
static void * scif_access
U32(* MicInitAPIPtr)(HANDLE *, ETarget, MicDeviceOnSystem *, U32 *)
#define PAPI_MAX_STR_LEN
Definition: papi.h:463
U32(* MicCloseAdapterPtr)(HANDLE)
static void * mic_access

Here is the caller graph for this function:

U32 MICACCESS_API MicCloseAdapter ( HANDLE  )
U32 MICACCESS_API MicCloseAPI ( HANDLE *  )
const char* MicGetErrorString ( U32  )
U32 MICACCESS_API MicGetPowerUsage ( HANDLE  ,
MicPwrUsage *   
)
U32 MICACCESS_API MicInitAdapter ( HANDLE *  ,
MicDeviceOnSystem *   
)
U32 MICACCESS_API MicInitAPI ( HANDLE *  ,
ETarget  ,
MicDeviceOnSystem *  ,
U32 *   
)
static int read_power ( struct powers pwr,
int  which_one 
)
static

Definition at line 384 of file linux-host_micpower.c.

385 {
386  MicPwrUsage power;
387  U32 ret = MIC_ACCESS_API_ERROR_UNKNOWN;
388 
389  if ( which_one < 0 || which_one > (int)nAdapters )
390  return PAPI_ENOEVNT;
391 
392 
393  ret = MicGetPowerUsagePtr(handles[which_one], &power);
394  if (MIC_ACCESS_API_SUCCESS != ret) {
395  fprintf(stderr,"Oops MicGetPowerUsage failed: %s\n",
396  MicGetErrorStringPtr(ret));
397  return PAPI_ECMP;
398  }
399 
400  pwr->total0 = power.total0.prr;
401  pwr->total1 = power.total1.prr;
402  pwr->inst = power.inst.prr;
403  pwr->imax = power.imax.prr;
404  pwr->pcie = power.pcie.prr;
405  pwr->c2x3 = power.c2x3.prr;
406  pwr->c2x4 = power.c2x4.prr;
407  pwr->vccp = power.vccp.pwr;
408  pwr->vddg = power.vddg.pwr;
409  pwr->vddq = power.vddq.pwr;
410 
411  return PAPI_OK;
412 }
#define PAPI_ENOEVNT
Definition: papi.h:258
static HANDLE handles[MAX_DEVICES]
const char *(* MicGetErrorStringPtr)(U32)
return PAPI_OK
Definition: linux-nvml.c:458
long long ret
Definition: iozone.c:1346
U32(* MicGetPowerUsagePtr)(HANDLE, MicPwrUsage *)
static U32 nAdapters
#define PAPI_ECMP
Definition: papi.h:254

Here is the caller graph for this function:

Variable Documentation

void(* _dl_non_dynamic_init)(void)

Corresponds to counter slot, indexed from 1, 0 has a special meaning

Definition at line 31 of file linux-host_micpower.c.

38  {
40  unsigned int selector;
host_micpower_register_t
papi_vector_t _host_micpower_vector

Definition at line 574 of file linux-host_micpower.c.

HANDLE accessHandle = NULL
static

Definition at line 72 of file linux-host_micpower.c.

MicDeviceOnSystem adapters[MAX_DEVICES]
static

Definition at line 69 of file linux-host_micpower.c.

power_t cached_values[MAX_DEVICES]
static

Definition at line 113 of file linux-host_micpower.c.

HANDLE handles[MAX_DEVICES]
static

Definition at line 70 of file linux-host_micpower.c.

host_micpower_register_t

Definition at line 41 of file linux-host_micpower.c.

long long lastupdate[MAX_DEVICES]
static

Definition at line 71 of file linux-host_micpower.c.

void* mic_access = NULL
static

Definition at line 75 of file linux-host_micpower.c.

U32(* MicCloseAdapterPtr)(HANDLE)

Definition at line 88 of file linux-host_micpower.c.

U32(* MicCloseAPIPtr)(HANDLE *)

Definition at line 90 of file linux-host_micpower.c.

const char*(* MicGetErrorStringPtr)(U32)

Definition at line 87 of file linux-host_micpower.c.

U32(* MicGetPowerUsagePtr)(HANDLE, MicPwrUsage *)

Definition at line 92 of file linux-host_micpower.c.

U32(* MicInitAdapterPtr)(HANDLE *, MicDeviceOnSystem *)

Definition at line 91 of file linux-host_micpower.c.

U32(* MicInitAPIPtr)(HANDLE *, ETarget, MicDeviceOnSystem *, U32 *)

Definition at line 89 of file linux-host_micpower.c.

U32 nAdapters = MAX_DEVICES
static

Definition at line 73 of file linux-host_micpower.c.

host_micpower_native_event_entry_t* native_events_table = NULL
static

Definition at line 93 of file linux-host_micpower.c.

void* scif_access = NULL
static

Definition at line 76 of file linux-host_micpower.c.