|
PAPI
5.0.1.0
|
A component for Myricom MX (Myrinet Express) More...

Go to the source code of this file.
Definition in file linux-mx.c.
| #define LINELEN 128 |
Definition at line 20 of file linux-mx.c.
| #define MX_MAX_COUNTER_TERMS MX_MAX_COUNTERS |
Definition at line 18 of file linux-mx.c.
| #define MX_MAX_COUNTERS 100 |
Definition at line 17 of file linux-mx.c.
| int _mx_ctl | ( | hwd_context_t * | ctx, |
| int | code, | ||
| _papi_int_option_t * | option | ||
| ) |
Definition at line 411 of file linux-mx.c.
{
( void ) ctx; /*unused */
( void ) code; /*unused */
( void ) option; /*unused */
return PAPI_OK;
}
| int _mx_init_component | ( | ) |
Definition at line 223 of file linux-mx.c.
{
FILE *fff;
char test_string[BUFSIZ];
/* detect if MX available */
strncpy(mx_counters_exe,"mx_counters 2> /dev/null",BUFSIZ);
fff=popen(mx_counters_exe,"r");
/* popen only returns NULL if "sh" fails, not the actual command */
if (fgets(test_string,BUFSIZ,fff)==NULL) {
pclose(fff);
strncpy(mx_counters_exe,"./components/mx/utils/fake_mx_counters 2> /dev/null",BUFSIZ);
fff=popen(mx_counters_exe,"r");
if (fgets(test_string,BUFSIZ,fff)==NULL) {
pclose(fff);
/* neither real nor fake found */
strncpy(_mx_vector.cmp_info.disabled_reason,
"No MX utilities found",PAPI_MAX_STR_LEN);
return PAPI_ECMP;
}
}
pclose(fff);
num_events=MX_MAX_COUNTERS;
_mx_vector.cmp_info.num_native_events=num_events;
return PAPI_OK;
}
| int _mx_init_control_state | ( | hwd_control_state_t * | ctl | ) |
Definition at line 286 of file linux-mx.c.
{
( void ) ctl; /*unused */
return PAPI_OK;
}
| int _mx_init_thread | ( | hwd_context_t * | ctx | ) |
Definition at line 259 of file linux-mx.c.
{
( void ) ctx; /*unused */
return PAPI_OK;
}
| int _mx_ntv_code_to_descr | ( | unsigned int | EventCode, |
| char * | name, | ||
| int | len | ||
| ) |
Definition at line 467 of file linux-mx.c.
{
int event=EventCode;
if (event >=0 && event < num_events) {
strncpy( name, mx_native_table[event].description, len );
return PAPI_OK;
}
return PAPI_ENOEVNT;
}
| int _mx_ntv_code_to_name | ( | unsigned int | EventCode, |
| char * | name, | ||
| int | len | ||
| ) |
Definition at line 452 of file linux-mx.c.
{
int event=EventCode;
if (event >=0 && event < num_events) {
strncpy( name, mx_native_table[event].name, len );
return PAPI_OK;
}
return PAPI_ENOEVNT;
}
| int _mx_ntv_enum_events | ( | unsigned int * | EventCode, |
| int | modifier | ||
| ) |
Definition at line 481 of file linux-mx.c.
{
if ( modifier == PAPI_ENUM_FIRST ) {
if (num_events==0) return PAPI_ENOEVNT;
*EventCode = 0;
return PAPI_OK;
}
if ( modifier == PAPI_ENUM_EVENTS ) {
int index = *EventCode;
if ( mx_native_table[index + 1].resources.selector ) {
*EventCode = *EventCode + 1;
return PAPI_OK;
} else {
return PAPI_ENOEVNT;
}
}
return PAPI_EINVAL;
}
| int _mx_read | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctl, | ||
| long long ** | events, | ||
| int | flags | ||
| ) |
Definition at line 361 of file linux-mx.c.
{
( void ) ctx; /*unused */
( void ) flags; /*unused */
int i;
long long mx_counters[MX_MAX_COUNTERS];
MX_control_state_t *mx_ctl = (MX_control_state_t *)ctl;
read_mx_counters( mx_counters );
for ( i = 0; i < mx_ctl->num_events; i++ ) {
mx_ctl->current_count[i]=
mx_counters[mx_ctl->which_counter[i]];
mx_ctl->difference[i] = mx_ctl->current_count[i]-
mx_ctl->start_count[i];
}
*events = mx_ctl->difference;
return PAPI_OK;
}

| int _mx_reset | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctrl | ||
| ) |
| int _mx_set_domain | ( | hwd_control_state_t * | cntrl, |
| int | domain | ||
| ) |
Definition at line 431 of file linux-mx.c.
{
( void ) cntrl; /*unused */
int found = 0;
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 _mx_shutdown_component | ( | void | ) |
Definition at line 267 of file linux-mx.c.
{
return PAPI_OK;
}
| int _mx_shutdown_thread | ( | hwd_context_t * | ctx | ) |
Definition at line 273 of file linux-mx.c.
{
( void ) ctx; /*unused */
return PAPI_OK;
}
| int _mx_start | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctl | ||
| ) |
Definition at line 317 of file linux-mx.c.
{
long long mx_counters[MX_MAX_COUNTERS];
( void ) ctx; /*unused */
MX_control_state_t *mx_ctl = (MX_control_state_t *)ctl;
int i;
read_mx_counters( mx_counters );
// for(i=0;i<MX_MAX_COUNTERS;i++) printf("%d %lld\n",i,mx_counters[i]);
for(i=0;i<mx_ctl->num_events;i++) {
mx_ctl->current_count[i]=
mx_counters[mx_ctl->which_counter[i]];
mx_ctl->start_count[i]=mx_ctl->current_count[i];
}
return PAPI_OK;
}


| int _mx_stop | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctl | ||
| ) |
Definition at line 342 of file linux-mx.c.
{
( void ) ctx; /*unused */
long long mx_counters[MX_MAX_COUNTERS];
MX_control_state_t *mx_ctl = (MX_control_state_t *)ctl;
int i;
read_mx_counters( mx_counters );
for(i=0;i<mx_ctl->num_events;i++) {
mx_ctl->current_count[i]=
mx_counters[mx_ctl->which_counter[i]];
}
return PAPI_OK;
}

| int _mx_update_control_state | ( | hwd_control_state_t * | ctl, |
| NativeInfo_t * | native, | ||
| int | count, | ||
| hwd_context_t * | ctx | ||
| ) |
Definition at line 294 of file linux-mx.c.
{
( void ) ctx; /*unused */
int i, index;
MX_control_state_t *mx_ctl = (MX_control_state_t *)ctl;
for(i=0; i<count; i++ ) {
index = native[i].ni_event;
mx_ctl->which_counter[i]=index;
// printf("Mapping event# %d to HW counter %d (count=%d)\n",
// i,index,count);
native[i].ni_position = i;
}
mx_ctl->num_events=count;
return PAPI_OK;
}
| int _mx_write | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctrl, | ||
| long long * | from | ||
| ) |
Definition at line 393 of file linux-mx.c.
{
( void ) ctx; /*unused */
( void ) ctrl; /*unused */
( void ) from; /*unused */
return PAPI_OK;
}
| static int read_mx_counters | ( | long long * | counters | ) | [static] |
Definition at line 167 of file linux-mx.c.
{
FILE *fp;
char line[LINELEN];
int i, linenum;
/* Open a pipe to the mx_counters executable */
fp = popen( mx_counters_exe, "r" );
if ( !fp ) {
perror( "popen" );
return PAPI_ECMP;
}
/* A line of output looks something similar to: */
/* " Lanai uptime (seconds): 766268 (0xbb13c)" */
/* This code may fail if number of ports on card > 1 */
linenum = 0;
while ( fgets( line, LINELEN, fp ) ) {
// printf("%s",line);
for(i=0; line[i]!= '\0' && i<LINELEN-1;i++) {
/* skip to colon */
if (line[i]==':') {
/* read in value */
if (line[i+1]!='\0') {
// printf("Line %d trying %s",linenum,&line[i+1]);
sscanf(&line[i+1],"%lld",&counters[linenum]);
linenum++;
break;
}
}
}
if (linenum>=MX_MAX_COUNTERS) break;
}
pclose( fp );
return PAPI_OK;
}

Definition at line 162 of file linux-mx.c.
char mx_counters_exe[BUFSIZ] [static] |
Definition at line 164 of file linux-mx.c.
Definition at line 58 of file linux-mx.c.
int num_events = 0 [static] |
Definition at line 161 of file linux-mx.c.