PAPI 7.1.0.0
Loading...
Searching...
No Matches
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.
 
#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 void * mic_access = NULL
 
static void * scif_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_tnative_events_table = NULL
 
static power_t cached_values [MAX_DEVICES]
 
papi_vector_t _host_micpower_vector
 

Macro Definition Documentation

◆ EVENTS_PER_DEVICE

#define EVENTS_PER_DEVICE   10

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

◆ MAX_DEVICES

#define MAX_DEVICES   (32)

◆ MICACCESS_API

#define MICACCESS_API   __attribute__((weak))

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

◆ UPDATEFREQ

#define UPDATEFREQ   500000

Function Documentation

◆ _host_micpower_ctl()

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

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

561{
562 (void)ctx;
563 (void)code;
564 (void)option;
565 return PAPI_OK;
566}
#define PAPI_OK
Definition: f90papi.h:73

◆ _host_micpower_init_component()

int _host_micpower_init_component ( int  cidx)

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

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

◆ _host_micpower_init_control_state()

int _host_micpower_init_control_state ( hwd_control_state_t ctl)

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

◆ _host_micpower_init_thread()

int _host_micpower_init_thread ( hwd_context_t ctx)

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

326 {
327 (void)ctx;
328 return PAPI_OK;
329}

◆ _host_micpower_ntv_code_to_descr()

int _host_micpower_ntv_code_to_descr ( unsigned int  EventCode,
char *  name,
int  len 
)

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

537{
538 unsigned int code = EventCode & PAPI_NATIVE_AND_MASK;
540 strncpy( name, native_events_table[code].description, len );
541 return PAPI_OK;
542 }
543
544 return PAPI_ENOEVNT;
545}
#define PAPI_ENOEVNT
Definition: f90papi.h:139
#define PAPI_NATIVE_AND_MASK

◆ _host_micpower_ntv_code_to_info()

int _host_micpower_ntv_code_to_info ( unsigned int  EventCode,
PAPI_event_info_t info 
)

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

549{
550 unsigned int code = EventCode & PAPI_NATIVE_AND_MASK;
552 return PAPI_ENOEVNT;
553 strncpy( info->symbol, native_events_table[code].name, sizeof(info->symbol) );
554 strncpy( info->long_descr, native_events_table[code].description, sizeof(info->long_descr) );
555 strncpy( info->units, native_events_table[code].units, sizeof(info->units) );
556 return PAPI_OK;
557}
char units[PAPI_MIN_STR_LEN]
Definition: papi.h:969
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:960
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
char units[3]
char description[PAPI_MAX_STR_LEN]
char name[PAPI_MAX_STR_LEN]

◆ _host_micpower_ntv_code_to_name()

int _host_micpower_ntv_code_to_name ( unsigned int  EventCode,
char *  name,
int  len 
)

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

525{
526 unsigned int code = EventCode & PAPI_NATIVE_AND_MASK;
528 strncpy( name, native_events_table[code].name, len);
529 return PAPI_OK;
530 }
531
532 return PAPI_ENOEVNT;
533}

◆ _host_micpower_ntv_enum_events()

int _host_micpower_ntv_enum_events ( unsigned int EventCode,
int  modifier 
)

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

500{
501 int index;
502 switch (modifier) {
503 case PAPI_ENUM_FIRST:
505 return PAPI_ENOEVNT;
506 *EventCode = 0;
507 return PAPI_OK;
508 case PAPI_ENUM_EVENTS:
509 index = *EventCode;
510 if ( index < _host_micpower_vector.cmp_info.num_cntrs - 1) {
511 *EventCode = *EventCode + 1;
512 return PAPI_OK;
513 } else {
514 return PAPI_ENOEVNT;
515 }
516 break;
517 default:
518 return PAPI_EINVAL;
519 }
520 return PAPI_EINVAL;
521}
#define PAPI_ENUM_EVENTS
Definition: f90papi.h:224
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
#define PAPI_EINVAL
Definition: f90papi.h:115

◆ _host_micpower_read()

int _host_micpower_read ( hwd_context_t ctx,
hwd_control_state_t ctl,
long long **  events,
int  flags 
)

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

420{
421 (void)flags;
422 (void)events;
423 (void)ctx;
424 unsigned int i,j;
425 int needs_update = 0;
427 long long now = PAPI_get_real_usec();
428
429 for( i=0; i<nAdapters; i++) {
430 needs_update = 0;
431 for (j=0; j<EVENTS_PER_DEVICE; j++) {
432 if ( control->resident[EVENTS_PER_DEVICE*i+j]) {
433 needs_update = 1;
434 break;
435 }
436 }
437
438 if ( needs_update ) {
439 /* Do the global update */
440 if ( now >= lastupdate[i] + UPDATEFREQ) {
441 read_power( &cached_values[i].power, i );
442 lastupdate[i] = now;
443 }
444 /* update from cached values */
445 if ( control->lastupdate[i] < lastupdate[i]) {
446 control->lastupdate[i] = lastupdate[i];
447 }
448 for (j=0; j<EVENTS_PER_DEVICE; j++) {
449 if ( control->resident[EVENTS_PER_DEVICE*i+j] ) {
450 control->counts[EVENTS_PER_DEVICE*i+j] = (long long)cached_values[i].array[j];
451 }
452 }
453 }
454 }
455
456 *events = control->counts;
457 return PAPI_OK;
458}
int i
get real time counter value in microseconds
char events[MAX_EVENTS][BUFSIZ]
static int read_power(struct powers *pwr, int which_one)
#define UPDATEFREQ
static double array[ARRAYSIZE]
Definition: papi_l1_dca.c:23
long long int long long
Definition: sde_internal.h:85
long long lastupdate[MAX_DEVICES]
long long counts[MAX_DEVICES *EVENTS_PER_DEVICE]
int resident[MAX_DEVICES *EVENTS_PER_DEVICE]
Here is the call graph for this function:

◆ _host_micpower_set_domain()

int _host_micpower_set_domain ( hwd_control_state_t ctl,
int  domain 
)

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

570{
571 (void)ctl;
572 if ( PAPI_DOM_ALL != domain )
573 return PAPI_EINVAL;
574 return PAPI_OK;
575}
#define PAPI_DOM_ALL
Definition: f90papi.h:261

◆ _host_micpower_shutdown_component()

int _host_micpower_shutdown_component ( void  )

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

332 {
333 U32 i = 0;
334 for( i=0; i<nAdapters; i++) {
336 }
337
339 return PAPI_OK;
340}
#define papi_free(a)
Definition: papi_memory.h:35

◆ _host_micpower_shutdown_thread()

int _host_micpower_shutdown_thread ( hwd_context_t ctx)

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

343 {
344 (void) ctx;
345 return PAPI_OK;
346}

◆ _host_micpower_start()

int _host_micpower_start ( hwd_context_t ctx,
hwd_control_state_t ctl 
)

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

380{
381 (void) ctx;
382 (void) ctl;
383 return PAPI_OK;
384}

◆ _host_micpower_stop()

int _host_micpower_stop ( hwd_context_t ctx,
hwd_control_state_t ctl 
)

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

462{
463 (void)ctx;
464 int needs_update = 0;
465 unsigned int i,j;
467 long long now = PAPI_get_real_usec();
468
469 for( i=0; i<nAdapters; i++) {
470 needs_update = 0;
471 for (j=0; j<EVENTS_PER_DEVICE; j++) {
472 if ( control->resident[EVENTS_PER_DEVICE*i+j]) {
473 needs_update = 1;
474 break;
475 }
476 }
477
478 if ( needs_update ) {
479 /* Do the global update */
480 if ( now >= lastupdate[i] + UPDATEFREQ) {
481 read_power( &cached_values[i].power, i );
482 lastupdate[i] = now;
483 }
484 /* update from cached values */
485 if ( control->lastupdate[i] < lastupdate[i]) {
486 control->lastupdate[i] = lastupdate[i];
487 }
488 for (j=0; j<EVENTS_PER_DEVICE; j++) {
489 if ( control->resident[EVENTS_PER_DEVICE*i+j] ) {
490 control->counts[EVENTS_PER_DEVICE*i+j] = (long long)cached_values[i].array[j];
491 }
492 }
493 }
494 }
495 return PAPI_OK;
496
497}
Here is the call graph for this function:

◆ _host_micpower_update_control_state()

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

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

358 {
359
360 (void) ctx;
361 int i, index;
362
364
365 for (i=0; i<MAX_DEVICES*EVENTS_PER_DEVICE; i++)
366 state->resident[i] = 0;
367
368 for (i=0; i < count; i++) {
369 index = info[i].ni_event&PAPI_NATIVE_AND_MASK;
370 info[i].ni_position=native_events_table[index].resources.selector-1;
371 state->resident[index] = 1;
372 }
373 state->num_events = count;
374
375 return PAPI_OK;
376}
static long count

◆ loadFunctionPtrs()

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}
static void * scif_access
U32(* MicGetPowerUsagePtr)(HANDLE, MicPwrUsage *)
void(* _dl_non_dynamic_init)(void)
static void * mic_access
Here is the caller graph for this function:

◆ MicCloseAdapter()

U32 MICACCESS_API MicCloseAdapter ( HANDLE  )

◆ MicCloseAPI()

U32 MICACCESS_API MicCloseAPI ( HANDLE *  )

◆ MicGetErrorString()

const char * MicGetErrorString ( U32  )

◆ MicGetPowerUsage()

U32 MICACCESS_API MicGetPowerUsage ( HANDLE  ,
MicPwrUsage *   
)

◆ MicInitAdapter()

U32 MICACCESS_API MicInitAdapter ( HANDLE *  ,
MicDeviceOnSystem *   
)

◆ MicInitAPI()

U32 MICACCESS_API MicInitAPI ( HANDLE *  ,
ETarget  ,
MicDeviceOnSystem *  ,
U32 *   
)

◆ read_power()

static int read_power ( struct powers pwr,
int  which_one 
)
static

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

388{
389 MicPwrUsage power;
390 U32 ret = MIC_ACCESS_API_ERROR_UNKNOWN;
391
392 if ( which_one < 0 || which_one > (int)nAdapters )
393 return PAPI_ENOEVNT;
394
395
396 ret = MicGetPowerUsagePtr(handles[which_one], &power);
397 if (MIC_ACCESS_API_SUCCESS != ret) {
398 fprintf(stderr,"Oops MicGetPowerUsage failed: %s\n",
400 return PAPI_ECMP;
401 }
402
403 pwr->total0 = power.total0.prr;
404 pwr->total1 = power.total1.prr;
405 pwr->inst = power.inst.prr;
406 pwr->imax = power.imax.prr;
407 pwr->pcie = power.pcie.prr;
408 pwr->c2x3 = power.c2x3.prr;
409 pwr->c2x4 = power.c2x4.prr;
410 pwr->vccp = power.vccp.pwr;
411 pwr->vddg = power.vddg.pwr;
412 pwr->vddq = power.vddq.pwr;
413
414 return PAPI_OK;
415}
#define PAPI_ECMP
Definition: f90papi.h:214
Here is the caller graph for this function:

Variable Documentation

◆ _dl_non_dynamic_init

void(* _dl_non_dynamic_init) (void) ( 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

◆ _host_micpower_vector

papi_vector_t _host_micpower_vector

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

◆ accessHandle

HANDLE accessHandle = NULL
static

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

◆ adapters

MicDeviceOnSystem adapters[MAX_DEVICES]
static

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

◆ cached_values

power_t cached_values[MAX_DEVICES]
static

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

◆ handles

HANDLE handles[MAX_DEVICES]
static

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

◆ host_micpower_register_t

host_micpower_register_t

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

◆ lastupdate

long long lastupdate[MAX_DEVICES]
static

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

◆ mic_access

void* mic_access = NULL
static

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

◆ MicCloseAdapterPtr

U32(* MicCloseAdapterPtr) (HANDLE) ( HANDLE  )

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

◆ MicCloseAPIPtr

U32(* MicCloseAPIPtr) (HANDLE *) ( HANDLE *  )

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

◆ MicGetErrorStringPtr

const char *(* MicGetErrorStringPtr) (U32) ( U32  )

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

◆ MicGetPowerUsagePtr

U32(* MicGetPowerUsagePtr) (HANDLE, MicPwrUsage *) ( HANDLE  ,
MicPwrUsage *   
)

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

◆ MicInitAdapterPtr

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

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

◆ MicInitAPIPtr

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

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

◆ nAdapters

U32 nAdapters = MAX_DEVICES
static

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

◆ native_events_table

host_micpower_native_event_entry_t* native_events_table = NULL
static

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

◆ scif_access

void* scif_access = NULL
static

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