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

This file has the source code for a component that enables PAPI-C to access hardware monitoring counters for InfiniBand devices through the OFED library. Since a new interface was introduced with OFED version 1.4 (released Dec 2008), the current InfiniBand component does not support OFED versions < 1.4. More...

Include dependency graph for linux-infiniband.c:

Go to the source code of this file.

Macros

#define infiniband_native_table   subscriptions
 
#define InitStruct(var, type)   type var; memset(&var, 0, sizeof(type))
 

Functions

static counter_infoaddCounter (const char *name, const char *desc, const char *unit)
 
static void addIBPort (const char *ca_name, umad_port_t *port)
 
static int init_ib_port (ib_port *portdata)
 
static int read_ib_counter ()
 
void host_read_values (long long *data)
 
static counter_infocounterFromName (const char *cntr)
 
static uint64_t host_subscribe (const char *cntr)
 
static string_listhost_listCounter (int num_counters1)
 
static void host_finalize ()
 
static void host_deleteStringList (string_list *to_delete)
 
int INFINIBAND_init_thread (hwd_context_t *ctx)
 
int INFINIBAND_init_component (int cidx)
 
static int linkInfinibandLibraries ()
 
int INFINIBAND_init_control_state (hwd_control_state_t *ctrl)
 
int INFINIBAND_start (hwd_context_t *ctx, hwd_control_state_t *ctrl)
 
int INFINIBAND_stop (hwd_context_t *ctx, hwd_control_state_t *ctrl)
 
int INFINIBAND_read (hwd_context_t *ctx, hwd_control_state_t *ctrl, long_long **events, int flags)
 
int INFINIBAND_shutdown_thread (hwd_context_t *ctx)
 
int INFINIBAND_shutdown_component (void)
 
int INFINIBAND_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
 
int INFINIBAND_update_control_state (hwd_control_state_t *ptr, NativeInfo_t *native, int count, hwd_context_t *ctx)
 
int INFINIBAND_set_domain (hwd_control_state_t *cntrl, int domain)
 
int INFINIBAND_reset (hwd_context_t *ctx, hwd_control_state_t *ctrl)
 
int INFINIBAND_ntv_enum_events (unsigned int *EventCode, int modifier)
 
int INFINIBAND_ntv_code_to_name (unsigned int EventCode, char *name, int len)
 
int INFINIBAND_ntv_code_to_descr (unsigned int EventCode, char *name, int len)
 
int INFINIBAND_ntv_code_to_bits (unsigned int EventCode, hwd_register_t *bits)
 

Variables

void(* _dl_non_dynamic_init )(void)
 
papi_vector_t _infiniband_vector
 

Detailed Description

Author
Heike Jagode (in collaboration with Michael Kluge, TU Dresden) jagod.nosp@m.e@ee.nosp@m.cs.ut.nosp@m.k.ed.nosp@m.u

InfiniBand component

Tested version of OFED: 1.4

Definition in file linux-infiniband.c.

Macro Definition Documentation

#define infiniband_native_table   subscriptions
#define InitStruct (   var,
  type 
)    type var; memset(&var, 0, sizeof(type))

Function Documentation

static counter_info* addCounter ( const char *  name,
const char *  desc,
const char *  unit 
)
static

add a counter to the list of available counters

Parameters
namethe short name of the counter
desca longer description
unitthe unit for this counter

Definition at line 153 of file linux-infiniband.c.

154 {
155  counter_info *cntr, *last;
156 
157  cntr = ( counter_info * ) malloc( sizeof ( counter_info ) );
158  if ( cntr == NULL ) {
159  fprintf( stderr, "can not allocate memory for new counter\n" );
160  exit( 1 );
161  }
162  cntr->name = strdup( name );
163  cntr->description = strdup( desc );
164  cntr->unit = strdup( unit );
165  cntr->value = 0;
166  cntr->next = NULL;
167 
168  if ( root_counter == NULL ) {
169  root_counter = cntr;
170  } else {
171  last = root_counter;
172  while ( last->next != NULL )
173  last = last->next;
174  last->next = cntr;
175  }
176 
177  return cntr;
178 }
struct counter_info_struct * next
static struct temp_event * last
char * name
Definition: iozone.c:23648
void exit()

Here is the call graph for this function:

Here is the caller graph for this function:

static void addIBPort ( const char *  ca_name,
umad_port_t *  port 
)
static

add one IB port to the list of available ports and add the counters related to this port to the global counter list

Definition at line 186 of file linux-infiniband.c.

187 {
188  ib_port *nwif, *last;
189  char counter_name[512];
190 
191  nwif = ( ib_port * ) malloc( sizeof ( ib_port ) );
192 
193  if ( nwif == NULL ) {
194  fprintf( stderr, "can not allocate memory for IB port description\n" );
195  exit( 1 );
196  }
197 
198  sprintf( counter_name, "%s_%d", ca_name, port->portnum );
199  nwif->name = strdup( counter_name );
200 
201  sprintf( counter_name, "%s_%d_recv", ca_name, port->portnum );
202  nwif->recv_cntr =
203  addCounter( counter_name, "bytes received on this IB port", "bytes" );
204 
205  sprintf( counter_name, "%s_%d_send", ca_name, port->portnum );
206  nwif->send_cntr =
207  addCounter( counter_name, "bytes written to this IB port", "bytes" );
208 
209  nwif->port_rate = port->rate;
210  nwif->is_initialized = 0;
211  nwif->port_number = port->portnum;
212  nwif->next = NULL;
213 
214  num_counters += 2;
215 
216  if ( root_ib_port == NULL ) {
217  root_ib_port = nwif;
218  } else {
219  last = root_ib_port;
220  while ( last->next != NULL )
221  last = last->next;
222  last->next = nwif;
223  }
224 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
char * name
counter_info * send_cntr
static counter_info * addCounter(const char *name, const char *desc, const char *unit)
counter_info * recv_cntr
char * port
Definition: iozone.c:1620
struct ib_port_struct * next
static struct temp_event * last
int is_initialized
void exit()

Here is the call graph for this function:

static counter_info* counterFromName ( const char *  cntr)
static

find the pointer for a counter_info structure based on the counter name

Definition at line 353 of file linux-infiniband.c.

354 {
355  int loop = 0;
356  char tmp[512];
357  counter_info *local_cntr = root_counter;
358 
359  while ( local_cntr != NULL ) {
360  if ( strcmp( cntr, local_cntr->name ) == 0 )
361  return local_cntr;
362 
363  local_cntr = local_cntr->next;
364  loop++;
365  }
366 
367  gethostname( tmp, 512 );
368  fprintf( stderr, "can not find host counter: %s on %s\n", cntr, tmp );
369  fprintf( stderr, "we only have: " );
370  local_cntr = root_counter;
371 
372  while ( local_cntr != NULL ) {
373  fprintf( stderr, "'%s' ", local_cntr->name );
374  local_cntr = local_cntr->next;
375  loop++;
376  }
377 
378  fprintf( stderr, "\n" );
379  exit( 1 );
380  /* never reached */
381  return 0;
382 }
struct counter_info_struct * next
double loop(long n)
Definition: kufrin.c:19
long long tmp
Definition: iozone.c:12031
void exit()
gethostname(controlling_host_name, 100)

Here is the call graph for this function:

Here is the caller graph for this function:

static void host_deleteStringList ( string_list to_delete)
static

delete a list of strings

Definition at line 509 of file linux-infiniband.c.

510 {
511  int loop;
512 
513  if ( to_delete->data != NULL ) {
514  for ( loop = 0; loop < to_delete->count; loop++ )
515  free( to_delete->data[loop] );
516 
517  free( to_delete->data );
518  }
519 
520  free( to_delete );
521 }
double loop(long n)
Definition: kufrin.c:19
free(dummyfile[xx])

Here is the call graph for this function:

Here is the caller graph for this function:

static void host_finalize ( void  )
static

finalizes the library

Definition at line 481 of file linux-infiniband.c.

482 {
483  counter_info *cntr, *next;
484 
485  if ( is_finalized )
486  return;
487 
488  cntr = root_counter;
489 
490  while ( cntr != NULL ) {
491  next = cntr->next;
492  free( cntr->name );
493  free( cntr->description );
494  free( cntr->unit );
495  free( cntr );
496  cntr = next;
497  }
498 
499  root_counter = NULL;
500 
501  is_finalized = 1;
502 }
struct counter_info_struct * next
free(dummyfile[xx])
nsize_list next
Definition: iozone.c:20053

Here is the call graph for this function:

Here is the caller graph for this function:

static string_list* host_listCounter ( int  num_counters1)
static

return a newly allocated list of strings containing all counter names

Definition at line 448 of file linux-infiniband.c.

449 {
450  string_list *list;
451  counter_info *cntr = root_counter;
452 
453  list = malloc( sizeof ( string_list ) );
454  if ( list == NULL ) {
455  fprintf( stderr, "unable to allocate memory for new string_list" );
456  exit( 1 );
457  }
458  list->count = 0;
459  list->data = ( char ** ) malloc( num_counters1 * sizeof ( char * ) );
460 
461  if ( list->data == NULL ) {
462  fprintf( stderr,
463  "unable to allocate memory for %d pointers in a new string_list\n",
464  num_counters1 );
465  exit( 1 );
466  }
467 
468  while ( cntr != NULL ) {
469  list->data[list->count++] = strdup( cntr->name );
470  cntr = cntr->next;
471  }
472 
473  return list;
474 }
struct counter_info_struct * next
void exit()

Here is the call graph for this function:

Here is the caller graph for this function:

void host_read_values ( long long data)

Definition at line 334 of file linux-infiniband.c.

335 {
336  int loop;
337 
338  read_ib_counter( );
339 
340  for ( loop = 0; loop < INFINIBAND_MAX_COUNTERS; loop++ ) {
341  if ( subscriptions[loop] == NULL )
342  break;
343 
344  data[loop] = subscriptions[loop]->value;
345  }
346 }
double loop(long n)
Definition: kufrin.c:19
#define INFINIBAND_MAX_COUNTERS
static int read_ib_counter()

Here is the call graph for this function:

Here is the caller graph for this function:

static uint64_t host_subscribe ( const char *  cntr)
static

allow external code to subscribe to a counter based on the counter name

Definition at line 389 of file linux-infiniband.c.

390 {
391  int loop;
392  int len;
393  char tmp_name[512];
394  ib_port *aktp;
395 
396  counter_info *counter = counterFromName( cntr );
397 
398  for ( loop = 0; loop < INFINIBAND_MAX_COUNTERS; loop++ ) {
399  if ( subscriptions[loop] == NULL ) {
400  subscriptions[loop] = counter;
401  counter->idx = loop;
402 
403  /* we have an IB counter if the name ends with _send or _recv and
404  the prefix before that is in the ib_port list */
405  if ( ( len = strlen( cntr ) ) > 5 ) {
406  if ( strcmp( &cntr[len - 5], "_recv" ) == 0 ||
407  strcmp( &cntr[len - 5], "_send" ) == 0 ) {
408  /* look through all IB_counters */
409  strncpy( tmp_name, cntr, len - 5 );
410  tmp_name[len - 5] = 0;
411  aktp = root_ib_port;
412  // printf("looking for IB port '%s'\n", tmp_name);
413  while ( aktp != NULL ) {
414  if ( strcmp( aktp->name, tmp_name ) == 0 ) {
415  if ( !aktp->is_initialized ) {
416  init_ib_port( aktp );
417  active_ib_port = aktp;
418  }
419  return loop + 1;
420  }
421  /* name does not match, if this counter is
422  initialized, we can't have two active IB ports */
423  if ( aktp->is_initialized ) {
424 #if 0 /* not necessary with OFED version >= 1.4 */
425  fprintf( stderr,
426  "unable to activate IB port monitoring for more than one port\n" );
427  exit( 1 );
428 #endif
429  }
430  aktp = aktp->next;
431  }
432  }
433  }
434  return loop + 1;
435  }
436  }
437  fprintf( stderr, "please subscribe only once to each counter\n" );
438  exit( 1 );
439  /* never reached */
440  return 0;
441 }
char * name
static int init_ib_port(ib_port *portdata)
double loop(long n)
Definition: kufrin.c:19
#define INFINIBAND_MAX_COUNTERS
struct ib_port_struct * next
int is_initialized
static counter_info * counterFromName(const char *cntr)
void exit()

Here is the call graph for this function:

Here is the caller graph for this function:

int INFINIBAND_ctl ( hwd_context_t ctx,
int  code,
_papi_int_option_t option 
)

Definition at line 787 of file linux-infiniband.c.

788 {
789  ( void ) ctx;
790  ( void ) code;
791  ( void ) option;
792  return ( PAPI_OK );
793 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
int INFINIBAND_init_component ( int  cidx)

Definition at line 569 of file linux-infiniband.c.

570 {
571  SUBDBG ("Entry: cidx: %d\n", cidx);
572  int i;
573 
574  /* link in all the infiniband libraries and resolve the symbols we need to use */
575  if (linkInfinibandLibraries() != PAPI_OK) {
576  SUBDBG ("Dynamic link of Infiniband libraries failed, component will be disabled.\n");
577  SUBDBG ("See disable reason in papi_component_avail output for more details.\n");
578  return (PAPI_ENOSUPP);
579  }
580 
581  /* make sure that the infiniband library finds the kernel module loaded. */
582  if ( (*umad_initPtr)( ) < 0 ) {
583  strncpy(_infiniband_vector.cmp_info.disabled_reason, "Call to initialize umad library failed.",PAPI_MAX_STR_LEN);
584  return ( PAPI_ENOSUPP );
585  }
586 
587  for ( i = 0; i < INFINIBAND_MAX_COUNTERS; i++ ) {
588  _papi_hwd_infiniband_register_start[i] = -1;
589  _papi_hwd_infiniband_register[i] = -1;
590  }
591 
592  /* Export the component id */
594 
595  return ( PAPI_OK );
596 }
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
#define INFINIBAND_MAX_COUNTERS
char disabled_reason[PAPI_MAX_STR_LEN]
Definition: papi.h:632
int i
Definition: fileop.c:140
#define PAPI_ENOSUPP
Definition: fpapi.h:123
static int cidx
Definition: event_info.c:40
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
papi_vector_t _infiniband_vector
static int linkInfinibandLibraries()

Here is the call graph for this function:

int INFINIBAND_init_control_state ( hwd_control_state_t ctrl)

Definition at line 687 of file linux-infiniband.c.

688 {
689  ( void ) ctrl;
690  return PAPI_OK;
691 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
int INFINIBAND_init_thread ( hwd_context_t ctx)

Definition at line 532 of file linux-infiniband.c.

533 {
534  string_list *counter_list = NULL;
535  int i;
536  int loop;
537 
538  /* initialize portid struct of type ib_portid_t to 0 */
539  InitStruct( portid, ib_portid_t );
540 
541  if ( is_initialized )
542  return PAPI_OK;
543 
544  is_initialized = 1;
545 
546  init_ib_counter( );
547 
548  for ( loop = 0; loop < INFINIBAND_MAX_COUNTERS; loop++ )
549  subscriptions[loop] = NULL;
550 
551  counter_list = host_listCounter( num_counters );
552 
553  for ( i = 0; i < counter_list->count; i++ )
554  host_subscribe( counter_list->data[i] );
555 
556  ( ( INFINIBAND_context_t * ) ctx )->state.ncounter = counter_list->count;
557 
558  host_deleteStringList( counter_list );
559 
560  return PAPI_OK;
561 }
static uint64_t host_subscribe(const char *cntr)
return PAPI_OK
Definition: linux-nvml.c:458
double loop(long n)
Definition: kufrin.c:19
static void init_ib_counter()
#define INFINIBAND_MAX_COUNTERS
int i
Definition: fileop.c:140
static string_list * host_listCounter(int num_counters1)
static int is_initialized
#define InitStruct(var, type)
static void host_deleteStringList(string_list *to_delete)

Here is the call graph for this function:

int INFINIBAND_ntv_code_to_bits ( unsigned int  EventCode,
hwd_register_t bits 
)

Definition at line 897 of file linux-infiniband.c.

898 {
899  memcpy( ( INFINIBAND_register_t * ) bits,
900  infiniband_native_table[EventCode],
901  sizeof ( INFINIBAND_register_t ) );
902 
903  return PAPI_OK;
904 }
return PAPI_OK
Definition: linux-nvml.c:458
#define infiniband_native_table
int INFINIBAND_ntv_code_to_descr ( unsigned int  EventCode,
char *  name,
int  len 
)

Definition at line 885 of file linux-infiniband.c.

886 {
887  strncpy( name, infiniband_native_table[EventCode]->description, len );
888 
889  return PAPI_OK;
890 }
return PAPI_OK
Definition: linux-nvml.c:458
char description[PAPI_MAX_STR_LEN]
#define infiniband_native_table
char * name
Definition: iozone.c:23648
int INFINIBAND_ntv_code_to_name ( unsigned int  EventCode,
char *  name,
int  len 
)

Definition at line 873 of file linux-infiniband.c.

874 {
875  strncpy( name, infiniband_native_table[EventCode]->name, len );
876 
877  return PAPI_OK;
878 }
return PAPI_OK
Definition: linux-nvml.c:458
#define infiniband_native_table
char * name
Definition: iozone.c:23648
int INFINIBAND_ntv_enum_events ( unsigned int EventCode,
int  modifier 
)

Definition at line 849 of file linux-infiniband.c.

850 {
851  if ( modifier == PAPI_ENUM_FIRST ) {
852  *EventCode = 0;
853  return PAPI_OK;
854  }
855 
856  if ( modifier == PAPI_ENUM_EVENTS ) {
857  int index = *EventCode;
858 
859  if ( infiniband_native_table[index + 1] ) {
860  *EventCode = *EventCode + 1;
861  return ( PAPI_OK );
862  } else
863  return ( PAPI_ENOEVNT );
864  } else
865  return ( PAPI_EINVAL );
866 }
#define PAPI_ENOEVNT
Definition: fpapi.h:112
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define infiniband_native_table
int INFINIBAND_read ( hwd_context_t ctx,
hwd_control_state_t ctrl,
long_long **  events,
int  flags 
)

Definition at line 737 of file linux-infiniband.c.

739 {
740  int i;
741  ( void ) flags;
742 
743  host_read_values( _papi_hwd_infiniband_register );
744 
745  for ( i = 0; i < ( ( INFINIBAND_context_t * ) ctx )->state.ncounter; i++ ) {
746  ( ( INFINIBAND_control_state_t * ) ctrl )->counts[i] =
747  _papi_hwd_infiniband_register[i] -
748  _papi_hwd_infiniband_register_start[i];
749  }
750 
751  *events = ( ( INFINIBAND_control_state_t * ) ctrl )->counts;
752  return ( PAPI_OK );
753 }
void host_read_values(long long *data)
long long flags
Definition: iozone.c:12330
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
int i
Definition: fileop.c:140
char events[MAX_EVENTS][BUFSIZ]

Here is the call graph for this function:

int INFINIBAND_reset ( hwd_context_t ctx,
hwd_control_state_t ctrl 
)

Definition at line 838 of file linux-infiniband.c.

839 {
840  INFINIBAND_start( ctx, ctrl );
841  return ( PAPI_OK );
842 }
return PAPI_OK
Definition: linux-nvml.c:458
int INFINIBAND_start(hwd_context_t *ctx, hwd_control_state_t *ctrl)

Here is the call graph for this function:

int INFINIBAND_set_domain ( hwd_control_state_t cntrl,
int  domain 
)

Definition at line 824 of file linux-infiniband.c.

825 {
826  (void) cntrl;
827  if ( PAPI_DOM_ALL != domain )
828  return ( PAPI_EINVAL );
829 
830  return ( PAPI_OK );
831 }
#define PAPI_DOM_ALL
Definition: fpapi.h:25
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
return PAPI_EINVAL
Definition: linux-nvml.c:408
int INFINIBAND_shutdown_component ( void  )

Definition at line 772 of file linux-infiniband.c.

773 {
774  // close the dynamic libraries needed by this component (opened in the init substrate call)
775  dlclose(dl1);
776  dlclose(dl2);
777 
778  return ( PAPI_OK );
779 }
return PAPI_OK
Definition: linux-nvml.c:458
int INFINIBAND_shutdown_thread ( hwd_context_t ctx)

Definition at line 760 of file linux-infiniband.c.

761 {
762  ( void ) ctx;
763  host_finalize( );
764  return ( PAPI_OK );
765 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
static void host_finalize()

Here is the call graph for this function:

int INFINIBAND_start ( hwd_context_t ctx,
hwd_control_state_t ctrl 
)

Definition at line 698 of file linux-infiniband.c.

699 {
700  ( void ) ctx;
701  ( void ) ctrl;
702 
703  host_read_values( _papi_hwd_infiniband_register_start );
704 
705  memcpy( _papi_hwd_infiniband_register, _papi_hwd_infiniband_register_start,
706  INFINIBAND_MAX_COUNTERS * sizeof ( long long ) );
707 
708  return ( PAPI_OK );
709 }
void host_read_values(long long *data)
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define INFINIBAND_MAX_COUNTERS

Here is the call graph for this function:

Here is the caller graph for this function:

int INFINIBAND_stop ( hwd_context_t ctx,
hwd_control_state_t ctrl 
)

Definition at line 716 of file linux-infiniband.c.

717 {
718  int i;
719  ( void ) ctx;
720 
721  host_read_values( _papi_hwd_infiniband_register );
722 
723  for ( i = 0; i < ( ( INFINIBAND_context_t * ) ctx )->state.ncounter; i++ ) {
724  ( ( INFINIBAND_control_state_t * ) ctrl )->counts[i] =
725  _papi_hwd_infiniband_register[i] -
726  _papi_hwd_infiniband_register_start[i];
727  }
728 
729  return ( PAPI_OK );
730 }
void host_read_values(long long *data)
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
int i
Definition: fileop.c:140

Here is the call graph for this function:

int INFINIBAND_update_control_state ( hwd_control_state_t ptr,
NativeInfo_t native,
int  count,
hwd_context_t ctx 
)

Definition at line 803 of file linux-infiniband.c.

806 {
807  ( void ) ptr;
808  ( void ) ctx;
809  int i, index;
810 
811  for ( i = 0; i < count; i++ ) {
812  index = native[i].ni_event;
813  native[i].ni_position = index;
814  }
815 
816  return ( PAPI_OK );
817 }
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
void
Definition: iozone.c:18627
int i
Definition: fileop.c:140
static int init_ib_port ( ib_port portdata)
static

initialize one IB port so that we are able to read values from it

Definition at line 231 of file linux-infiniband.c.

232 {
233  int mgmt_classes[4] = { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS,
234  IB_PERFORMANCE_CLASS
235  };
236  char *ca = 0;
237  static uint8_t pc[1024];
238  int mask = 0xFFFF;
239 
240  srcport = (*mad_rpc_open_portPtr)( ca, portdata->port_number, mgmt_classes, 4 );
241  if ( !srcport ) {
242  fprintf( stderr, "Failed to open '%s' port '%d'\n", ca,
243  portdata->port_number );
244  exit( 1 );
245  }
246 
247  if ( (*ib_resolve_self_viaPtr)( &portid, &ibportnum, 0, srcport ) < 0 ) {
248  fprintf( stderr, "can't resolve self port\n" );
249  exit( 1 );
250  }
251 
252  /* PerfMgt ClassPortInfo is a required attribute */
253  /* might be redundant, could be left out for fast implementation */
254  if ( !(*pma_query_viaPtr) ( pc, &portid, ibportnum, ib_timeout, CLASS_PORT_INFO, srcport ) ) {
255  fprintf( stderr, "classportinfo query\n" );
256  exit( 1 );
257  }
258 
259  if ( !(*performance_reset_viaPtr) ( pc, &portid, ibportnum, mask, ib_timeout, IB_GSI_PORT_COUNTERS, srcport ) ) {
260  fprintf( stderr, "perf reset\n" );
261  exit( 1 );
262  }
263 
264  /* read the initial values */
265  (*mad_decode_fieldPtr)( pc, IB_PC_XMT_BYTES_F, &portdata->last_send_val );
266  portdata->sum_send_val = 0;
267  (*mad_decode_fieldPtr)( pc, IB_PC_RCV_BYTES_F, &portdata->last_recv_val );
268  portdata->sum_recv_val = 0;
269 
270  portdata->is_initialized = 1;
271 
272  return 0;
273 }
uint32_t last_recv_val
uint32_t last_send_val
uint64_t sum_send_val
int is_initialized
void exit()
uint64_t sum_recv_val

Here is the call graph for this function:

Here is the caller graph for this function:

static int linkInfinibandLibraries ( )
static

Definition at line 606 of file linux-infiniband.c.

607 {
608  /* Attempt to guess if we were statically linked to libc, if so bail */
609  if ( _dl_non_dynamic_init != NULL ) {
610  strncpy(_infiniband_vector.cmp_info.disabled_reason, "The Infiniband component does not support statically linking of libc.", PAPI_MAX_STR_LEN);
611  return PAPI_ENOSUPP;
612  }
613 
614  /* Need to link in the Infiniband libraries, if not found disable the component */
615  dl1 = dlopen("libibumad.so", RTLD_NOW | RTLD_GLOBAL);
616  if (!dl1)
617  {
618  strncpy(_infiniband_vector.cmp_info.disabled_reason, "Infiniband library libibumad.so not found.",PAPI_MAX_STR_LEN);
619  return ( PAPI_ENOSUPP );
620  }
621  umad_initPtr = dlsym(dl1, "umad_init");
622  if (dlerror() != NULL)
623  {
624  strncpy(_infiniband_vector.cmp_info.disabled_reason, "Infiniband function umad_init not found.",PAPI_MAX_STR_LEN);
625  return ( PAPI_ENOSUPP );
626  }
627  umad_get_cas_namesPtr = dlsym(dl1, "umad_get_cas_names");
628  if (dlerror() != NULL)
629  {
630  strncpy(_infiniband_vector.cmp_info.disabled_reason, "Infiniband function umad_get_cas_names not found.",PAPI_MAX_STR_LEN);
631  return ( PAPI_ENOSUPP );
632  }
633  umad_get_caPtr = dlsym(dl1, "umad_get_ca");
634  if (dlerror() != NULL)
635  {
636  strncpy(_infiniband_vector.cmp_info.disabled_reason, "Infiniband function umad_get_ca not found.",PAPI_MAX_STR_LEN);
637  return ( PAPI_ENOSUPP );
638  }
639 
640  /* Need to link in the Infiniband libraries, if not found disable the component */
641  dl2 = dlopen("libibmad.so", RTLD_NOW | RTLD_GLOBAL);
642  if (!dl2)
643  {
644  strncpy(_infiniband_vector.cmp_info.disabled_reason, "Infiniband library libibmad.so not found.",PAPI_MAX_STR_LEN);
645  return ( PAPI_ENOSUPP );
646  }
647  mad_decode_fieldPtr = dlsym(dl2, "mad_decode_field");
648  if (dlerror() != NULL)
649  {
650  strncpy(_infiniband_vector.cmp_info.disabled_reason, "Infiniband function mad_decode_field not found.",PAPI_MAX_STR_LEN);
651  return ( PAPI_ENOSUPP );
652  }
653  mad_rpc_open_portPtr = dlsym(dl2, "mad_rpc_open_port");
654  if (dlerror() != NULL)
655  {
656  strncpy(_infiniband_vector.cmp_info.disabled_reason, "Infiniband function mad_rpc_open_port not found.",PAPI_MAX_STR_LEN);
657  return ( PAPI_ENOSUPP );
658  }
659  ib_resolve_self_viaPtr = dlsym(dl2, "ib_resolve_self_via");
660  if (dlerror() != NULL)
661  {
662  strncpy(_infiniband_vector.cmp_info.disabled_reason, "Infiniband function ib_resolve_self_via not found.",PAPI_MAX_STR_LEN);
663  return ( PAPI_ENOSUPP );
664  }
665  performance_reset_viaPtr = dlsym(dl2, "performance_reset_via");
666  if (dlerror() != NULL)
667  {
668  strncpy(_infiniband_vector.cmp_info.disabled_reason, "Infiniband function performance_reset_via not found.",PAPI_MAX_STR_LEN);
669  return ( PAPI_ENOSUPP );
670  }
671  pma_query_viaPtr = dlsym(dl2, "pma_query_via");
672  if (dlerror() != NULL)
673  {
674  strncpy(_infiniband_vector.cmp_info.disabled_reason, "Infiniband function pma_query_via not found.",PAPI_MAX_STR_LEN);
675  return ( PAPI_ENOSUPP );
676  }
677 
678  return ( PAPI_OK );
679 }
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
char disabled_reason[PAPI_MAX_STR_LEN]
Definition: papi.h:632
void(* _dl_non_dynamic_init)(void)
Definition: linux-cuda.c:41
#define PAPI_ENOSUPP
Definition: fpapi.h:123
papi_vector_t _infiniband_vector

Here is the caller graph for this function:

static int read_ib_counter ( )
static

read and reset IB counters (reset on demand)

Definition at line 280 of file linux-infiniband.c.

281 {
282  uint32_t send_val;
283  uint32_t recv_val;
284  uint8_t pc[1024];
285  /* 32 bit counter FFFFFFFF */
286  uint32_t max_val = 4294967295;
287  /* if it is bigger than this -> reset */
288  uint32_t reset_limit = max_val * 0.7;
289  int mask = 0xFFFF;
290 
291  if ( active_ib_port == NULL )
292  return 0;
293 
294  /* reading cost ~70 mirco secs */
295  if ( !(*pma_query_viaPtr) ( pc, &portid, ibportnum, ib_timeout, IB_GSI_PORT_COUNTERS, srcport ) ) {
296  fprintf( stderr, "perfquery\n" );
297  exit( 1 );
298  }
299 
300  (*mad_decode_fieldPtr)( pc, IB_PC_XMT_BYTES_F, &send_val );
301  (*mad_decode_fieldPtr)( pc, IB_PC_RCV_BYTES_F, &recv_val );
302 
303  /* multiply the numbers read by 4 as the IB port counters are not
304  counting bytes. they always count 32dwords. see man page of
305  perfquery for details
306  internally a uint64_t ia used to sum up the values */
307  active_ib_port->sum_send_val +=
308  ( send_val - active_ib_port->last_send_val ) * 4;
309  active_ib_port->sum_recv_val +=
310  ( recv_val - active_ib_port->last_recv_val ) * 4;
311 
312  active_ib_port->send_cntr->value = active_ib_port->sum_send_val;
313  active_ib_port->recv_cntr->value = active_ib_port->sum_recv_val;
314 
315  if ( send_val > reset_limit || recv_val > reset_limit ) {
316  /* reset cost ~70 mirco secs */
317  if ( !(*performance_reset_viaPtr) ( pc, &portid, ibportnum, mask, ib_timeout, IB_GSI_PORT_COUNTERS, srcport ) ) {
318  fprintf( stderr, "perf reset\n" );
319  exit( 1 );
320  }
321 
322  (*mad_decode_fieldPtr)( pc, IB_PC_XMT_BYTES_F, &active_ib_port->last_send_val );
323  (*mad_decode_fieldPtr)( pc, IB_PC_RCV_BYTES_F, &active_ib_port->last_recv_val );
324  } else {
325  active_ib_port->last_send_val = send_val;
326  active_ib_port->last_recv_val = recv_val;
327  }
328 
329  return 0;
330 }
void exit()

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

void(* _dl_non_dynamic_init)(void)

use libumad to discover IB ports

Definition at line 32 of file linux-infiniband.c.

110 {
111  char names[20][UMAD_CA_NAME_LEN];
112  int n, i;
113  char *ca_name;
114  umad_ca_t ca;
115  int r;
116  int portnum;
117 
118 // if ( umad_init( ) < 0 ) {
119 // fprintf( stderr, "can't init UMAD library\n" );
120 // exit( 1 );
121 // }
122 
123  if ( ( n = (*umad_get_cas_namesPtr)( ( void * ) names, UMAD_CA_NAME_LEN ) ) < 0 ) {
124  fprintf( stderr, "can't list IB device names\n" );
125  exit( 1 );
126  }
127 
128  for ( i = 0; i < n; i++ ) {
129  ca_name = names[i];
130 
131  if ( ( r = (*umad_get_caPtr)( ca_name, &ca ) ) < 0 ) {
132  fprintf( stderr, "can't read ca from IB device\n" );
133  exit( 1 );
134  }
135 
136  if ( !ca.node_type )
137  continue;
138 
139  /* port numbers are '1' based in OFED */
140  for ( portnum = 1; portnum <= ca.numports; portnum++ )
141  addIBPort( ca.ca_name, ca.ports[portnum] );
142  }
143 }
int i
Definition: fileop.c:140
static void addIBPort(const char *ca_name, umad_port_t *port)
const char * names[NUM_EVENTS]
void exit()
int n
Definition: mendes-alt.c:164
papi_vector_t _infiniband_vector

Definition at line 910 of file linux-infiniband.c.