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
38typedef struct host_micpower_register {
40 unsigned int selector;
43typedef struct host_micpower_reg_alloc {
48typedef struct host_micpower_native_event_entry {
56typedef struct host_micpower_control_state {
64typedef struct host_micpower_context {
79#define MICACCESS_API __attribute__((weak))
87const 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)
198 U32 ret = MIC_ACCESS_API_ERROR_UNKNOWN;
212 if ( MIC_ACCESS_API_SUCCESS != ret ) {
228 for (adapterNum=0; adapterNum <
nAdapters; adapterNum++) {
231 if (MIC_ACCESS_API_SUCCESS != ret) {
234 for (adapterNum=0; adapterNum <
nAdapters; adapterNum++)
238 "Failed to initialize card %d's interface.",
nAdapters);
243 if (MIC_ACCESS_API_SUCCESS != ret) {
246 for (adapterNum=0; adapterNum <
nAdapters; adapterNum++)
250 "Failed to initialize card %d's interface.",
nAdapters);
261 for (adapterNum=0; adapterNum <
nAdapters; adapterNum++) {
371 state->resident[index] = 1;
390 U32 ret = MIC_ACCESS_API_ERROR_UNKNOWN;
392 if ( which_one < 0 || which_one > (
int)
nAdapters )
397 if (MIC_ACCESS_API_SUCCESS != ret) {
398 fprintf(
stderr,
"Oops MicGetPowerUsage failed: %s\n",
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;
419 long long **
events,
int flags)
425 int needs_update = 0;
438 if ( needs_update ) {
464 int needs_update = 0;
478 if ( needs_update ) {
511 *EventCode = *EventCode + 1;
579 .
name =
"host_micpower",
580 .short_name =
"host_micpower",
581 .description =
"A host-side component to read power usage on MIC guest cards.",
583 .support_version =
"n/a",
584 .kernel_version =
"n/a",
get real time counter value in microseconds
struct papi_vectors * _papi_hwd[]
char events[MAX_EVENTS][BUFSIZ]
U32(* MicInitAdapterPtr)(HANDLE *, MicDeviceOnSystem *)
U32 MICACCESS_API MicGetPowerUsage(HANDLE, MicPwrUsage *)
static MicDeviceOnSystem adapters[MAX_DEVICES]
int _host_micpower_read(hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags)
static host_micpower_native_event_entry_t * native_events_table
int _host_micpower_update_control_state(hwd_control_state_t *ctl, NativeInfo_t *info, int count, hwd_context_t *ctx)
const char *(* MicGetErrorStringPtr)(U32)
U32(* MicCloseAPIPtr)(HANDLE *)
static long long lastupdate[MAX_DEVICES]
int _host_micpower_ntv_code_to_descr(unsigned int EventCode, char *name, int len)
papi_vector_t _host_micpower_vector
static int loadFunctionPtrs()
int _host_micpower_init_thread(hwd_context_t *ctx)
int _host_micpower_start(hwd_context_t *ctx, hwd_control_state_t *ctl)
#define EVENTS_PER_DEVICE
#define MAX_DEVICES
This component wraps the MicAccessAPI to provide hostside power information for attached Intel Xeon P...
int _host_micpower_set_domain(hwd_control_state_t *ctl, int domain)
int _host_micpower_ntv_enum_events(unsigned int *EventCode, int modifier)
static HANDLE accessHandle
static power_t cached_values[MAX_DEVICES]
const char * MicGetErrorString(U32)
U32 MICACCESS_API MicCloseAdapter(HANDLE)
int _host_micpower_init_control_state(hwd_control_state_t *ctl)
int _host_micpower_ntv_code_to_name(unsigned int EventCode, char *name, int len)
int _host_micpower_shutdown_thread(hwd_context_t *ctx)
static HANDLE handles[MAX_DEVICES]
static int read_power(struct powers *pwr, int which_one)
int _host_micpower_ctl(hwd_context_t *ctx, int code, _papi_int_option_t *option)
static void * scif_access
U32(* MicGetPowerUsagePtr)(HANDLE, MicPwrUsage *)
U32 MICACCESS_API MicInitAPI(HANDLE *, ETarget, MicDeviceOnSystem *, U32 *)
int _host_micpower_init_component(int cidx)
U32 MICACCESS_API MicInitAdapter(HANDLE *, MicDeviceOnSystem *)
void(* _dl_non_dynamic_init)(void)
U32(* MicCloseAdapterPtr)(HANDLE)
U32(* MicInitAPIPtr)(HANDLE *, ETarget, MicDeviceOnSystem *, U32 *)
U32 MICACCESS_API MicCloseAPI(HANDLE *)
int _host_micpower_shutdown_component(void)
int _host_micpower_ntv_code_to_info(unsigned int EventCode, PAPI_event_info_t *info)
int _host_micpower_stop(hwd_context_t *ctx, hwd_control_state_t *ctl)
unsigned long AO_t __attribute__((__aligned__(4)))
#define PAPI_NATIVE_AND_MASK
Return codes and api definitions.
static double array[ARRAYSIZE]
char units[MAX_EVENTS][BUFSIZ]
char name[PAPI_MAX_STR_LEN]
char disabled_reason[PAPI_HUGE_STR_LEN]
char units[PAPI_MIN_STR_LEN]
char symbol[PAPI_HUGE_STR_LEN]
char long_descr[PAPI_HUGE_STR_LEN]
host_micpower_control_state_t state
long long lastupdate[MAX_DEVICES]
long long counts[MAX_DEVICES *EVENTS_PER_DEVICE]
int resident[MAX_DEVICES *EVENTS_PER_DEVICE]
char description[PAPI_MAX_STR_LEN]
host_micpower_register_t resources
char name[PAPI_MAX_STR_LEN]
host_micpower_register_t ra_bits
PAPI_component_info_t cmp_info