PAPI  5.6.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
linux-mx.c File Reference

A component for Myricom MX (Myrinet Express) More...

Include dependency graph for linux-mx.c:

Go to the source code of this file.

Data Structures

struct  MX_register_t
 
struct  MX_native_event_entry_t
 
struct  MX_reg_alloc_t
 
struct  MX_control_state_t
 
struct  MX_context_t
 

Macros

#define MX_MAX_COUNTERS   100
 
#define MX_MAX_COUNTER_TERMS   MX_MAX_COUNTERS
 
#define LINELEN   128
 

Functions

static int read_mx_counters (long long *counters)
 
static int _mx_init_component (int cidx)
 
static int _mx_init_thread (hwd_context_t *ctx)
 
static int _mx_shutdown_component (void)
 
static int _mx_shutdown_thread (hwd_context_t *ctx)
 
static int _mx_init_control_state (hwd_control_state_t *ctl)
 
static int _mx_update_control_state (hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
 
static int _mx_start (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
static int _mx_stop (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
static int _mx_read (hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags)
 
static int _mx_reset (hwd_context_t *ctx, hwd_control_state_t *ctrl)
 
static int _mx_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
 
static int _mx_set_domain (hwd_control_state_t *cntrl, int domain)
 
static int _mx_ntv_code_to_name (unsigned int EventCode, char *name, int len)
 
static int _mx_ntv_code_to_descr (unsigned int EventCode, char *name, int len)
 
static int _mx_ntv_enum_events (unsigned int *EventCode, int modifier)
 

Variables

static const
MX_native_event_entry_t 
mx_native_table []
 
static int num_events =0
 
papi_vector_t _mx_vector
 
static char mx_counters_exe [BUFSIZ]
 

Macro Definition Documentation

#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.

Function Documentation

static int _mx_ctl ( hwd_context_t ctx,
int  code,
_papi_int_option_t option 
)
static

Definition at line 416 of file linux-mx.c.

417 {
418  ( void ) ctx; /*unused */
419  ( void ) code; /*unused */
420  ( void ) option; /*unused */
421 
422  return PAPI_OK;
423 }
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
static int _mx_init_component ( int  cidx)
static

Definition at line 223 of file linux-mx.c.

224 {
225 
226  FILE *fff;
227  char test_string[BUFSIZ];
228 
229  /* detect if MX available */
230 
231  strncpy(mx_counters_exe,"mx_counters 2> /dev/null",BUFSIZ);
232  fff=popen(mx_counters_exe,"r");
233  /* popen only returns NULL if "sh" fails, not the actual command */
234  if (fgets(test_string,BUFSIZ,fff)==NULL) {
235  pclose(fff);
236  strncpy(mx_counters_exe,"./components/mx/utils/fake_mx_counters 2> /dev/null",BUFSIZ);
237  fff=popen(mx_counters_exe,"r");
238  if (fgets(test_string,BUFSIZ,fff)==NULL) {
239  pclose(fff);
240  /* neither real nor fake found */
242  "No MX utilities found",PAPI_MAX_STR_LEN);
243  return PAPI_ECMP;
244  }
245  }
246  pclose(fff);
247 
250 
251  /* Export the component id */
253 
254 
255  return PAPI_OK;
256 }
return PAPI_OK
Definition: linux-nvml.c:497
static char mx_counters_exe[BUFSIZ]
Definition: linux-mx.c:164
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
FILE * fff[MAX_EVENTS]
papi_vector_t _mx_vector
Definition: linux-mx.c:162
static int cidx
char disabled_reason[PAPI_MAX_STR_LEN]
Definition: papi.h:636
#define PAPI_ECMP
Definition: papi.h:256
#define MX_MAX_COUNTERS
Definition: linux-mx.c:17
#define PAPI_MAX_STR_LEN
Definition: papi.h:465
static int num_events
Definition: linux-mx.c:161
static int _mx_init_control_state ( hwd_control_state_t ctl)
static

Definition at line 290 of file linux-mx.c.

291 {
292  ( void ) ctl; /*unused */
293 
294  return PAPI_OK;
295 }
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
static int _mx_init_thread ( hwd_context_t ctx)
static

Definition at line 263 of file linux-mx.c.

264 {
265  ( void ) ctx; /*unused */
266  return PAPI_OK;
267 }
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
static int _mx_ntv_code_to_descr ( unsigned int  EventCode,
char *  name,
int  len 
)
static

Definition at line 464 of file linux-mx.c.

465 {
466  int event=EventCode;
467 
468  if (event >=0 && event < num_events) {
469  strncpy( name, mx_native_table[event].description, len );
470  return PAPI_OK;
471  }
472  return PAPI_ENOEVNT;
473 }
static const MX_native_event_entry_t mx_native_table[]
Definition: linux-mx.c:58
#define PAPI_ENOEVNT
Definition: papi.h:260
return PAPI_OK
Definition: linux-nvml.c:497
char * name
Definition: iozone.c:23648
static int num_events
Definition: linux-mx.c:161
static int _mx_ntv_code_to_name ( unsigned int  EventCode,
char *  name,
int  len 
)
static

Definition at line 449 of file linux-mx.c.

450 {
451 
452  int event=EventCode;
453 
454  if (event >=0 && event < num_events) {
455  strncpy( name, mx_native_table[event].name, len );
456  return PAPI_OK;
457  }
458  return PAPI_ENOEVNT;
459 
460 
461 }
static const MX_native_event_entry_t mx_native_table[]
Definition: linux-mx.c:58
#define PAPI_ENOEVNT
Definition: papi.h:260
return PAPI_OK
Definition: linux-nvml.c:497
char * name
Definition: iozone.c:23648
static int num_events
Definition: linux-mx.c:161
static int _mx_ntv_enum_events ( unsigned int EventCode,
int  modifier 
)
static

Definition at line 478 of file linux-mx.c.

479 {
480 
481  if ( modifier == PAPI_ENUM_FIRST ) {
482  if (num_events==0) return PAPI_ENOEVNT;
483  *EventCode = 0;
484  return PAPI_OK;
485  }
486 
487  if ( modifier == PAPI_ENUM_EVENTS ) {
488  int index = *EventCode;
489 
490  if ( mx_native_table[index + 1].resources.selector ) {
491  *EventCode = *EventCode + 1;
492  return PAPI_OK;
493  } else {
494  return PAPI_ENOEVNT;
495  }
496  }
497 
498  return PAPI_EINVAL;
499 }
static const MX_native_event_entry_t mx_native_table[]
Definition: linux-mx.c:58
#define PAPI_ENOEVNT
Definition: papi.h:260
return PAPI_OK
Definition: linux-nvml.c:497
return PAPI_EINVAL
Definition: linux-nvml.c:436
static int num_events
Definition: linux-mx.c:161
static int _mx_read ( hwd_context_t ctx,
hwd_control_state_t ctl,
long long **  events,
int  flags 
)
static

Definition at line 365 of file linux-mx.c.

367 {
368  ( void ) ctx; /*unused */
369  ( void ) flags; /*unused */
370  int i;
371  long long mx_counters[MX_MAX_COUNTERS];
372 
373  MX_control_state_t *mx_ctl = (MX_control_state_t *)ctl;
374 
375  read_mx_counters( mx_counters );
376 
377  for ( i = 0; i < mx_ctl->num_events; i++ ) {
378  mx_ctl->current_count[i]=
379  mx_counters[mx_ctl->which_counter[i]];
380  mx_ctl->difference[i] = mx_ctl->current_count[i]-
381  mx_ctl->start_count[i];
382  }
383  *events = mx_ctl->difference;
384 
385  return PAPI_OK;
386 }
long long start_count[MX_MAX_COUNTERS]
Definition: linux-mx.c:45
long long flags
Definition: iozone.c:12330
long long current_count[MX_MAX_COUNTERS]
Definition: linux-mx.c:46
static int read_mx_counters(long long *counters)
Definition: linux-mx.c:167
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
char events[MAX_EVENTS][BUFSIZ]
int i
Definition: fileop.c:140
#define MX_MAX_COUNTERS
Definition: linux-mx.c:17
int which_counter[MX_MAX_COUNTERS]
Definition: linux-mx.c:48
long long difference[MX_MAX_COUNTERS]
Definition: linux-mx.c:47

Here is the call graph for this function:

static int _mx_reset ( hwd_context_t ctx,
hwd_control_state_t ctrl 
)
static

Definition at line 390 of file linux-mx.c.

391 {
392  _mx_start( ctx, ctrl );
393  return PAPI_OK;
394 }
return PAPI_OK
Definition: linux-nvml.c:497
static int _mx_start(hwd_context_t *ctx, hwd_control_state_t *ctl)
Definition: linux-mx.c:321

Here is the call graph for this function:

static int _mx_set_domain ( hwd_control_state_t cntrl,
int  domain 
)
static

Definition at line 436 of file linux-mx.c.

437 {
438  ( void ) cntrl; /*unused */
439  if ( PAPI_DOM_ALL != domain ) {
440  return PAPI_EINVAL;
441  }
442 
443  return PAPI_OK;
444 }
#define PAPI_DOM_ALL
Definition: papi.h:303
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
return PAPI_EINVAL
Definition: linux-nvml.c:436
static int _mx_shutdown_component ( void  )
static

Definition at line 271 of file linux-mx.c.

272 {
273  return PAPI_OK;
274 }
return PAPI_OK
Definition: linux-nvml.c:497
static int _mx_shutdown_thread ( hwd_context_t ctx)
static

Definition at line 277 of file linux-mx.c.

278 {
279  ( void ) ctx; /*unused */
280  return PAPI_OK;
281 }
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
static int _mx_start ( hwd_context_t ctx,
hwd_control_state_t ctl 
)
static

Definition at line 321 of file linux-mx.c.

322 {
323 
324  long long mx_counters[MX_MAX_COUNTERS];
325 
326  ( void ) ctx; /*unused */
327 
328  MX_control_state_t *mx_ctl = (MX_control_state_t *)ctl;
329  int i;
330 
331  read_mx_counters( mx_counters );
332 
333  // for(i=0;i<MX_MAX_COUNTERS;i++) printf("%d %lld\n",i,mx_counters[i]);
334 
335  for(i=0;i<mx_ctl->num_events;i++) {
336  mx_ctl->current_count[i]=
337  mx_counters[mx_ctl->which_counter[i]];
338  mx_ctl->start_count[i]=mx_ctl->current_count[i];
339  }
340 
341  return PAPI_OK;
342 }
long long start_count[MX_MAX_COUNTERS]
Definition: linux-mx.c:45
long long current_count[MX_MAX_COUNTERS]
Definition: linux-mx.c:46
static int read_mx_counters(long long *counters)
Definition: linux-mx.c:167
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
int i
Definition: fileop.c:140
#define MX_MAX_COUNTERS
Definition: linux-mx.c:17
int which_counter[MX_MAX_COUNTERS]
Definition: linux-mx.c:48

Here is the call graph for this function:

Here is the caller graph for this function:

static int _mx_stop ( hwd_context_t ctx,
hwd_control_state_t ctl 
)
static

Definition at line 346 of file linux-mx.c.

347 {
348  ( void ) ctx; /*unused */
349 
350  long long mx_counters[MX_MAX_COUNTERS];
351  MX_control_state_t *mx_ctl = (MX_control_state_t *)ctl;
352  int i;
353 
354  read_mx_counters( mx_counters );
355 
356  for(i=0;i<mx_ctl->num_events;i++) {
357  mx_ctl->current_count[i]=
358  mx_counters[mx_ctl->which_counter[i]];
359  }
360 
361  return PAPI_OK;
362 }
long long current_count[MX_MAX_COUNTERS]
Definition: linux-mx.c:46
static int read_mx_counters(long long *counters)
Definition: linux-mx.c:167
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
int i
Definition: fileop.c:140
#define MX_MAX_COUNTERS
Definition: linux-mx.c:17
int which_counter[MX_MAX_COUNTERS]
Definition: linux-mx.c:48

Here is the call graph for this function:

static int _mx_update_control_state ( hwd_control_state_t ctl,
NativeInfo_t native,
int  count,
hwd_context_t ctx 
)
static

Definition at line 298 of file linux-mx.c.

300 {
301  ( void ) ctx; /*unused */
302  int i, index;
303 
304  MX_control_state_t *mx_ctl = (MX_control_state_t *)ctl;
305 
306  for(i=0; i<count; i++ ) {
307  index = native[i].ni_event;
308  mx_ctl->which_counter[i]=index;
309  // printf("Mapping event# %d to HW counter %d (count=%d)\n",
310  // i,index,count);
311  native[i].ni_position = i;
312  }
313 
314  mx_ctl->num_events=count;
315 
316  return PAPI_OK;
317 }
return PAPI_OK
Definition: linux-nvml.c:497
int count
Definition: iozone.c:22422
void
Definition: iozone.c:18627
int i
Definition: fileop.c:140
int which_counter[MX_MAX_COUNTERS]
Definition: linux-mx.c:48
static int read_mx_counters ( long long counters)
static

Definition at line 167 of file linux-mx.c.

168 {
169  FILE *fp;
170  char line[LINELEN];
171  int i, linenum;
172 
173  /* Open a pipe to the mx_counters executable */
174 
175  fp = popen( mx_counters_exe, "r" );
176  if ( !fp ) {
177  perror( "popen" );
178  return PAPI_ECMP;
179  }
180 
181 
182  /* A line of output looks something similar to: */
183  /* " Lanai uptime (seconds): 766268 (0xbb13c)" */
184 
185  /* This code may fail if number of ports on card > 1 */
186 
187  linenum = 0;
188  while ( fgets( line, LINELEN, fp ) ) {
189  // printf("%s",line);
190  for(i=0; line[i]!= '\0' && i<LINELEN-1;i++) {
191 
192  /* skip to colon */
193  if (line[i]==':') {
194 
195  /* read in value */
196  if (line[i+1]!='\0') {
197  // printf("Line %d trying %s",linenum,&line[i+1]);
198  sscanf(&line[i+1],"%lld",&counters[linenum]);
199  linenum++;
200  break;
201  }
202  }
203  }
204  if (linenum>=MX_MAX_COUNTERS) break;
205  }
206 
207  pclose( fp );
208 
209  return PAPI_OK;
210 }
return PAPI_OK
Definition: linux-nvml.c:497
static char mx_counters_exe[BUFSIZ]
Definition: linux-mx.c:164
static FILE * fp
#define LINELEN
Definition: linux-mx.c:20
int i
Definition: fileop.c:140
#define PAPI_ECMP
Definition: papi.h:256
#define MX_MAX_COUNTERS
Definition: linux-mx.c:17
sscanf(mnc->m_child_port,"%d",&mc.m_child_port)

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

papi_vector_t _mx_vector

Definition at line 162 of file linux-mx.c.

char mx_counters_exe[BUFSIZ]
static

Definition at line 164 of file linux-mx.c.

const MX_native_event_entry_t mx_native_table[]
static

Definition at line 58 of file linux-mx.c.

int num_events =0
static

Definition at line 161 of file linux-mx.c.