13 #define MAX_DEVICES (32) 14 #define EVENTS_PER_DEVICE 10 20 #include "MicAccessTypes.h" 21 #include "MicBasicTypes.h" 22 #include "MicAccessErrorTypes.h" 23 #include "MicAccessApi.h" 24 #include "MicPowerManagerAPI.h" 34 #define UPDATEFREQ 500000 38 typedef struct host_micpower_register {
40 unsigned int selector;
43 typedef struct host_micpower_reg_alloc {
48 typedef struct host_micpower_native_event_entry {
56 typedef struct host_micpower_control_state {
64 typedef struct host_micpower_context {
79 #define MICACCESS_API __attribute__((weak)) 87 const char *(*MicGetErrorStringPtr)(U32);
125 scif_access = dlopen(
"libscif.so", RTLD_NOW | RTLD_GLOBAL);
133 mic_access = dlopen(
"libMicAccessSDK.so", RTLD_NOW | RTLD_GLOBAL);
142 if (dlerror() != NULL)
149 if (dlerror() != NULL)
156 if (dlerror() != NULL)
163 if (dlerror() != NULL)
170 if (dlerror() != NULL)
178 if (dlerror() != NULL)
197 U32
ret = MIC_ACCESS_API_ERROR_UNKNOWN;
210 if ( MIC_ACCESS_API_SUCCESS !=
ret ) {
224 for (adapterNum=0; adapterNum <
nAdapters; adapterNum++) {
227 if (MIC_ACCESS_API_SUCCESS !=
ret) {
230 for (adapterNum=0; adapterNum <
nAdapters; adapterNum++)
234 "Failed to initialize card %d's interface.",
nAdapters);
238 if (MIC_ACCESS_API_SUCCESS !=
ret) {
241 for (adapterNum=0; adapterNum <
nAdapters; adapterNum++)
245 "Failed to initialize card %d's interface.",
nAdapters);
254 for (adapterNum=0; adapterNum <
nAdapters; adapterNum++) {
387 U32
ret = MIC_ACCESS_API_ERROR_UNKNOWN;
389 if ( which_one < 0 || which_one > (
int)
nAdapters )
394 if (MIC_ACCESS_API_SUCCESS !=
ret) {
395 fprintf(stderr,
"Oops MicGetPowerUsage failed: %s\n",
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;
416 long long **
events,
int flags)
422 int needs_update = 0;
435 if ( needs_update ) {
461 int needs_update = 0;
475 if ( needs_update ) {
508 *EventCode = *EventCode + 1;
576 .
name =
"host_micpower",
577 .short_name =
"host_micpower",
578 .description =
"A host-side component to read power usage on MIC guest cards.",
580 .support_version =
"n/a",
581 .kernel_version =
"n/a",
int _host_micpower_ntv_code_to_descr(unsigned int EventCode, char *name, int len)
static HANDLE handles[MAX_DEVICES]
int _host_micpower_stop(hwd_context_t *ctx, hwd_control_state_t *ctl)
char disabled_reason[PAPI_MAX_STR_LEN]
papi_vector_t _host_micpower_vector
int _host_micpower_ctl(hwd_context_t *ctx, int code, _papi_int_option_t *option)
char units[PAPI_MIN_STR_LEN]
char name[PAPI_MAX_STR_LEN]
const char *(* MicGetErrorStringPtr)(U32)
int resident[MAX_DEVICES *EVENTS_PER_DEVICE]
int _host_micpower_set_domain(hwd_control_state_t *ctl, int domain)
const char * MicGetErrorString(U32)
static double array[ARRAYSIZE]
host_micpower_register_t resources
long long lastupdate[MAX_DEVICES]
char long_descr[PAPI_HUGE_STR_LEN]
char units[MAX_EVENTS][BUFSIZ]
PAPI_component_info_t cmp_info
int _host_micpower_ntv_enum_events(unsigned int *EventCode, int modifier)
U32 MICACCESS_API MicInitAdapter(HANDLE *, MicDeviceOnSystem *)
Return codes and api definitions.
char events[MAX_EVENTS][BUFSIZ]
static power_t cached_values[MAX_DEVICES]
static MicDeviceOnSystem adapters[MAX_DEVICES]
static host_micpower_native_event_entry_t * native_events_table
host_micpower_control_state_t state
U32 MICACCESS_API MicGetPowerUsage(HANDLE, MicPwrUsage *)
#define EVENTS_PER_DEVICE
char symbol[PAPI_HUGE_STR_LEN]
int _host_micpower_ntv_code_to_info(unsigned int EventCode, PAPI_event_info_t *info)
int _host_micpower_start(hwd_context_t *ctx, hwd_control_state_t *ctl)
__attribute__((constructor))
#define MAX_DEVICES
This component wraps the MicAccessAPI to provide hostside power information for attached Intel Xeon P...
host_micpower_register_t ra_bits
static long long lastupdate[MAX_DEVICES]
U32(* MicGetPowerUsagePtr)(HANDLE, MicPwrUsage *)
static void * scif_access
int _host_micpower_update_control_state(hwd_control_state_t *ctl, NativeInfo_t *info, int count, hwd_context_t *ctx)
char name[PAPI_MAX_STR_LEN]
U32 MICACCESS_API MicInitAPI(HANDLE *, ETarget, MicDeviceOnSystem *, U32 *)
U32(* MicInitAPIPtr)(HANDLE *, ETarget, MicDeviceOnSystem *, U32 *)
U32(* MicInitAdapterPtr)(HANDLE *, MicDeviceOnSystem *)
static HANDLE accessHandle
static int read_power(struct powers *pwr, int which_one)
static int loadFunctionPtrs()
int _host_micpower_init_component(int cidx)
long long PAPI_get_real_usec(void)
int _host_micpower_ntv_code_to_name(unsigned int EventCode, char *name, int len)
U32(* MicCloseAdapterPtr)(HANDLE)
long long counts[MAX_DEVICES *EVENTS_PER_DEVICE]
#define PAPI_NATIVE_AND_MASK
U32 MICACCESS_API MicCloseAdapter(HANDLE)
int _host_micpower_shutdown_component(void)
int _host_micpower_read(hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags)
U32(* MicCloseAPIPtr)(HANDLE *)
void(* _dl_non_dynamic_init)(void)
char description[PAPI_MAX_STR_LEN]
int _host_micpower_init_control_state(hwd_control_state_t *ctl)
int _host_micpower_shutdown_thread(hwd_context_t *ctx)
U32 MICACCESS_API MicCloseAPI(HANDLE *)
int _host_micpower_init_thread(hwd_context_t *ctx)