|
PAPI
5.1.0.2
|

Go to the source code of this file.
| #define INVALID_RESULT -1000000L |
Definition at line 21 of file linux-micpower.c.
| #define MICPOWER_NUMBER_OF_NATIVE_EVENTS 16 |
Definition at line 22 of file linux-micpower.c.
| #define REFRESH_LAT 50000 |
Definition at line 19 of file linux-micpower.c.
| int _micpower_ctl | ( | hwd_context_t * | ctx, |
| int | code, | ||
| _papi_int_option_t * | option | ||
| ) |
Definition at line 311 of file linux-micpower.c.
{
( void ) ctx;
( void ) code;
( void ) option;
return PAPI_OK;
}
| int _micpower_init_component | ( | int | cidx | ) |
Definition at line 190 of file linux-micpower.c.
{
if ( is_initialized )
return (PAPI_OK );
is_initialized = 1;
/* Check that /sys/class/micras/power is readable */
if ( 0 != access( "/sys/class/micras/power", R_OK ) ) {
strncpy(_micpower_vector.cmp_info.disabled_reason,
"Cannot read /sys/class/micras/power",PAPI_MAX_STR_LEN);
return PAPI_ENOCMP;
}
/* Export the total number of events available */
num_events =
_micpower_vector.cmp_info.num_native_events = MICPOWER_NUMBER_OF_NATIVE_EVENTS;
/* Export the component id */
_micpower_vector.cmp_info.CmpIdx = cidx;
return PAPI_OK;
}
| int _micpower_init_control_state | ( | hwd_control_state_t * | ctl | ) |
Definition at line 223 of file linux-micpower.c.
{
int retval = 0;
MICPOWER_control_state_t *micpower_ctl = (MICPOWER_control_state_t *) ctl;
retval = read_sysfs_file(micpower_ctl->counts);
/* Set last access time for caching results */
micpower_ctl->lastupdate = PAPI_get_real_usec();
return (retval)?PAPI_OK:PAPI_ESYS;
}

| int _micpower_init_thread | ( | hwd_context_t * | ctx | ) |
Definition at line 177 of file linux-micpower.c.
{
( void ) ctx;
return PAPI_OK;
}
| int _micpower_ntv_code_to_descr | ( | unsigned int | EventCode, |
| char * | name, | ||
| int | len | ||
| ) |
Definition at line 438 of file linux-micpower.c.
{
int index = EventCode;
if ( index >= 0 && index < num_events ) {
strncpy( name, _micpower_native_events[index].description, len );
return PAPI_OK;
}
return PAPI_ENOEVNT;
}
| int _micpower_ntv_code_to_info | ( | unsigned int | EventCode, |
| PAPI_event_info_t * | info | ||
| ) |
Definition at line 450 of file linux-micpower.c.
{
int index = EventCode;
if ( ( index < 0) || (index >= num_events )) return PAPI_ENOEVNT;
strncpy( info->symbol, _micpower_native_events[index].name,
sizeof(info->symbol));
strncpy( info->long_descr, _micpower_native_events[index].description,
sizeof(info->long_descr));
strncpy( info->units, _micpower_native_events[index].units,
sizeof(info->units));
return PAPI_OK;
}
| int _micpower_ntv_code_to_name | ( | unsigned int | EventCode, |
| char * | name, | ||
| int | len | ||
| ) |
Definition at line 423 of file linux-micpower.c.
{
int index = EventCode;
if ( index >= 0 && index < num_events ) {
strncpy( name, _micpower_native_events[index].name, len );
return PAPI_OK;
}
return PAPI_ENOEVNT;
}
| int _micpower_ntv_enum_events | ( | unsigned int * | EventCode, |
| int | modifier | ||
| ) |
Definition at line 384 of file linux-micpower.c.
{
int index;
switch ( modifier ) {
case PAPI_ENUM_FIRST:
if (num_events==0) {
return PAPI_ENOEVNT;
}
*EventCode = 0;
return PAPI_OK;
case PAPI_ENUM_EVENTS:
index = *EventCode;
if ( index < num_events - 1 ) {
*EventCode = *EventCode + 1;
return PAPI_OK;
} else {
return PAPI_ENOEVNT;
}
break;
default:
return PAPI_EINVAL;
}
return PAPI_EINVAL;
}
| int _micpower_read | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctl, | ||
| long long ** | events, | ||
| int | flags | ||
| ) |
Definition at line 246 of file linux-micpower.c.
{
(void) flags;
(void) ctx;
int retval = 0;
MICPOWER_control_state_t* control = (MICPOWER_control_state_t*) ctl;
long long now = PAPI_get_real_usec();
/* Only read the values from the kernel if enough time has passed */
/* since the last read. Otherwise return cached values. */
if ( now - control->lastupdate > REFRESH_LAT ) {
retval = read_sysfs_file(control->counts);
control->lastupdate = now;
}
/* Pass back a pointer to our results */
*events = control->counts;
return (retval)?PAPI_OK:PAPI_ESYS;
}

| int _micpower_reset | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctl | ||
| ) |
Definition at line 371 of file linux-micpower.c.
{
( void ) ctx;
( void ) ctl;
return PAPI_OK;
}
| int _micpower_set_domain | ( | hwd_control_state_t * | cntl, |
| int | domain | ||
| ) |
Definition at line 349 of file linux-micpower.c.
{
int found = 0;
( void ) cntl;
if ( PAPI_DOM_USER & domain )
found = 1;
if ( PAPI_DOM_KERNEL & domain )
found = 1;
if ( PAPI_DOM_OTHER & domain )
found = 1;
if ( !found )
return PAPI_EINVAL;
return PAPI_OK;
}
| int _micpower_shutdown_component | ( | ) |
Definition at line 296 of file linux-micpower.c.
{
if ( is_initialized ) {
is_initialized = 0;
num_events = 0;
}
return PAPI_OK;
}
| int _micpower_shutdown_thread | ( | hwd_context_t * | ctx | ) |
Definition at line 285 of file linux-micpower.c.
{
( void ) ctx;
return PAPI_OK;
}
| int _micpower_start | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctl | ||
| ) |
Definition at line 237 of file linux-micpower.c.
{
( void ) ctx;
( void ) ctl;
return PAPI_OK;
}
| int _micpower_stop | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctl | ||
| ) |
Definition at line 271 of file linux-micpower.c.
{
(void) ctx;
int retval = 0;
/* read values */
MICPOWER_control_state_t* control = (MICPOWER_control_state_t*) ctl;
retval = read_sysfs_file(control->counts);
control->lastupdate = PAPI_get_real_usec();
return (retval)?PAPI_OK:PAPI_ESYS;
}

| int _micpower_update_control_state | ( | hwd_control_state_t * | ptr, |
| NativeInfo_t * | native, | ||
| int | count, | ||
| hwd_context_t * | ctx | ||
| ) |
Definition at line 322 of file linux-micpower.c.
{
int i, index;
( void ) ctx;
( void ) ptr;
for ( i = 0; i < count; i++ ) {
index = native[i].ni_event;
native[i].ni_position = _micpower_native_events[index].resources.selector - 1;
}
return PAPI_OK;
}
| static int read_sysfs_file | ( | long long * | counts | ) | [static] |
Definition at line 152 of file linux-micpower.c.
{
FILE* fp = NULL;
int i;
int retval = 1;
fp = fopen( "/sys/class/micras/power", "r" );
for (i=0; i < MICPOWER_MAX_COUNTERS-9; i++) {
retval&= fscanf(fp, "%lld", &counts[i]);
}
for (i=MICPOWER_MAX_COUNTERS-9; i < MICPOWER_MAX_COUNTERS; i+=3) {
retval&= fscanf(fp, "%lld %lld %lld", &counts[i], &counts[i+1], &counts[i+2] );
}
return !retval;
}

Definition at line 26 of file linux-micpower.c.
Definition at line 24 of file linux-micpower.c.
int is_initialized = 0 [static] |
Definition at line 110 of file linux-micpower.c.
int num_events = 0 [static] |
Definition at line 109 of file linux-micpower.c.