PAPI  5.4.0.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 the infiniband performance monitor through the Linux sysfs interface. This code will dynamically create a native events table for all the events that can be accesed through the sysfs interface. The counters exported by this component cannot be reset programatically. More...

Include dependency graph for linux-infiniband.c:

Go to the source code of this file.

Data Structures

struct  infiniband_register_t
 
struct  ib_device_t
 
struct  ib_counter_t
 
struct  infiniband_native_event_entry_t
 
struct  infiniband_control_state_t
 
struct  infiniband_context_t
 

Macros

#define INFINIBAND_MAX_COUNTERS   128
 

Functions

static char * make_ib_event_description (const char *input_str, int extended)
 
static ib_device_tadd_ib_device (const char *name, int port)
 
static ib_counter_tadd_ib_counter (const char *name, const char *file_name, int extended, ib_device_t *device)
 
static int find_ib_device_events (ib_device_t *dev, int extended)
 
static int find_ib_devices ()
 
static long long read_ib_counter_value (int index)
 
static void deallocate_infiniband_resources ()
 
int _infiniband_init_thread (hwd_context_t *ctx)
 
int _infiniband_init_component (int cidx)
 
int _infiniband_init_control_state (hwd_control_state_t *ctl)
 
int _infiniband_start (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
int _infiniband_stop (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
int _infiniband_read (hwd_context_t *ctx, hwd_control_state_t *ctl, long_long **events, int flags)
 
int _infiniband_shutdown_component (void)
 
int _infiniband_shutdown_thread (hwd_context_t *ctx)
 
int _infiniband_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
 
int _infiniband_update_control_state (hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
 
int _infiniband_set_domain (hwd_control_state_t *ctl, int domain)
 
int _infiniband_reset (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
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_info (unsigned int EventCode, PAPI_event_info_t *info)
 

Variables

static const char * ib_dir_path = "/sys/class/infiniband"
 
static
infiniband_native_event_entry_t
infiniband_native_events = 0
 
static int num_events = 0
 
papi_vector_t _infiniband_vector
 
static ib_device_troot_device = 0
 
static ib_counter_troot_counter = 0
 

Detailed Description

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.

Author
Gabriel Marin gmari.nosp@m.n@ee.nosp@m.cs.ut.nosp@m.k.ed.nosp@m.u

Infiniband component

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_MAX_COUNTERS   128

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

Function Documentation

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

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

578 {
579  ( void ) ctx;
580  ( void ) code;
581  ( void ) option;
582  return PAPI_OK;
583 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
int _infiniband_init_component ( int  cidx)

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

434 {
435  /* discover Infiniband devices and available events */
436  int result = find_ib_devices();
437 
438  if (result != PAPI_OK) // we couldn't initialize the component
439  {
440  // deallocate any eventually allocated memory
442  }
443 
445 
448 
449 
450  /* Export the component id */
452 
453  return (result);
454 }
static void deallocate_infiniband_resources()
static int num_events
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
static int cidx
Definition: event_info.c:40
static int find_ib_devices()
papi_vector_t _infiniband_vector

Here is the call graph for this function:

int _infiniband_init_control_state ( hwd_control_state_t ctl)

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

463 {
465  int i;
466 
467  for (i=0 ; i<INFINIBAND_MAX_COUNTERS ; ++i) {
468  control->being_measured[i] = 0;
469  }
470 
471  return PAPI_OK;
472 }
return PAPI_OK
Definition: linux-nvml.c:458
int i
Definition: fileop.c:140
int being_measured[INFINIBAND_MAX_COUNTERS]
#define INFINIBAND_MAX_COUNTERS
int _infiniband_init_thread ( hwd_context_t ctx)

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

422 {
423  (void) ctx;
424  return PAPI_OK;
425 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
int _infiniband_ntv_code_to_descr ( unsigned int  EventCode,
char *  name,
int  len 
)

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

708 {
709  int index = EventCode;
710 
711  if (index>=0 && index<num_events) {
712  strncpy(name, infiniband_native_events[index].description, len);
713  }
714  return PAPI_OK;
715 }
static infiniband_native_event_entry_t * infiniband_native_events
static int num_events
return PAPI_OK
Definition: linux-nvml.c:458
char * name
Definition: iozone.c:23648
int _infiniband_ntv_code_to_info ( unsigned int  EventCode,
PAPI_event_info_t info 
)

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

719 {
720  int index = EventCode;
721 
722  if ( ( index < 0) || (index >= num_events )) return PAPI_ENOEVNT;
723 
724  if (infiniband_native_events[index].name)
725  {
726  unsigned int len = strlen(infiniband_native_events[index].name);
727  if (len > sizeof(info->symbol)-1) len = sizeof(info->symbol)-1;
728  strncpy(info->symbol, infiniband_native_events[index].name, len);
729  info->symbol[len] = '\0';
730  }
731  if (infiniband_native_events[index].description)
732  {
733  unsigned int len = strlen(infiniband_native_events[index].description);
734  if (len > sizeof(info->long_descr)-1) len = sizeof(info->long_descr)-1;
735  strncpy(info->long_descr, infiniband_native_events[index].description, len);
736  info->long_descr[len] = '\0';
737  }
738 
739  strncpy(info->units, "\0", 1);
740  /* infiniband_native_events[index].units, sizeof(info->units)); */
741 
742 /* info->data_type = infiniband_native_events[index].return_type;
743  */
744  return PAPI_OK;
745 }
#define PAPI_ENOEVNT
Definition: papi.h:258
static infiniband_native_event_entry_t * infiniband_native_events
char * name
static int num_events
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:966
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
return PAPI_OK
Definition: linux-nvml.c:458
char * description
char * name
Definition: iozone.c:23648
char units[PAPI_MIN_STR_LEN]
Definition: papi.h:972
int _infiniband_ntv_code_to_name ( unsigned int  EventCode,
char *  name,
int  len 
)

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

693 {
694  int index = EventCode;
695 
696  if (index>=0 && index<num_events) {
697  strncpy( name, infiniband_native_events[index].name, len );
698  }
699 
700  return PAPI_OK;
701 }
static infiniband_native_event_entry_t * infiniband_native_events
static int num_events
return PAPI_OK
Definition: linux-nvml.c:458
char * name
Definition: iozone.c:23648
int _infiniband_ntv_enum_events ( unsigned int EventCode,
int  modifier 
)

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

661 {
662  switch (modifier) {
663  case PAPI_ENUM_FIRST:
664  if (num_events == 0)
665  return (PAPI_ENOEVNT);
666 
667  *EventCode = 0;
668  return PAPI_OK;
669 
670  case PAPI_ENUM_EVENTS:
671  {
672  int index = *EventCode & PAPI_NATIVE_AND_MASK;
673 
674  if (index < num_events - 1) {
675  *EventCode = *EventCode + 1;
676  return PAPI_OK;
677  } else
678  return PAPI_ENOEVNT;
679 
680  break;
681  }
682  default:
683  return PAPI_EINVAL;
684  }
685  return PAPI_EINVAL;
686 }
#define PAPI_ENOEVNT
Definition: papi.h:258
static int num_events
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define PAPI_NATIVE_AND_MASK
int _infiniband_read ( hwd_context_t ctx,
hwd_control_state_t ctl,
long_long **  events,
int  flags 
)

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

542 {
543  ( void ) flags;
544 
545  _infiniband_stop(ctx, ctl); /* we cannot actually stop the counters */
546  /* Pass back a pointer to our results */
547  *events = ((infiniband_control_state_t*) ctl)->counts;
548 
549  return PAPI_OK;
550 }
int _infiniband_stop(hwd_context_t *ctx, hwd_control_state_t *ctl)
long long flags
Definition: iozone.c:12330
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
char events[MAX_EVENTS][BUFSIZ]

Here is the call graph for this function:

int _infiniband_reset ( hwd_context_t ctx,
hwd_control_state_t ctl 
)

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

649 {
650  (void) ctx;
651  (void) ctl;
652  return PAPI_OK;
653 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
int _infiniband_set_domain ( hwd_control_state_t ctl,
int  domain 
)

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

624 {
625  int found = 0;
626  (void) ctl;
627 
628  if (PAPI_DOM_USER & domain)
629  found = 1;
630 
631  if (PAPI_DOM_KERNEL & domain)
632  found = 1;
633 
634  if (PAPI_DOM_OTHER & domain)
635  found = 1;
636 
637  if (!found)
638  return (PAPI_EINVAL);
639 
640  return (PAPI_OK);
641 }
#define PAPI_DOM_KERNEL
Definition: papi.h:298
return PAPI_OK
Definition: linux-nvml.c:458
#define PAPI_DOM_USER
Definition: papi.h:296
void
Definition: iozone.c:18627
return PAPI_EINVAL
Definition: linux-nvml.c:408
long long found
Definition: libasync.c:735
#define PAPI_DOM_OTHER
Definition: papi.h:299
int _infiniband_shutdown_component ( void  )

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

555 {
556  /* Cleanup resources used by this component before leaving */
558 
559  return PAPI_OK;
560 }
static void deallocate_infiniband_resources()
return PAPI_OK
Definition: linux-nvml.c:458

Here is the call graph for this function:

int _infiniband_shutdown_thread ( hwd_context_t ctx)

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

564 {
565  ( void ) ctx;
566 
567  return PAPI_OK;
568 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
int _infiniband_start ( hwd_context_t ctx,
hwd_control_state_t ctl 
)

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

479 {
480  infiniband_context_t* context = (infiniband_context_t*) ctx;
482  long long now = PAPI_get_real_usec();
483  int i;
484 
485  for (i=0 ; i<INFINIBAND_MAX_COUNTERS ; ++i) {
486  if (control->being_measured[i] && control->need_difference[i]) {
487  context->start_value[i] = read_ib_counter_value(i);
488  }
489  }
490  control->lastupdate = now;
491 
492  return PAPI_OK;
493 }
static long long read_ib_counter_value(int index)
return PAPI_OK
Definition: linux-nvml.c:458
int i
Definition: fileop.c:140
long long PAPI_get_real_usec(void)
Definition: papi.c:6190
int being_measured[INFINIBAND_MAX_COUNTERS]
int need_difference[INFINIBAND_MAX_COUNTERS]
long long start_value[INFINIBAND_MAX_COUNTERS]
#define INFINIBAND_MAX_COUNTERS

Here is the call graph for this function:

int _infiniband_stop ( hwd_context_t ctx,
hwd_control_state_t ctl 
)

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

501 {
502  infiniband_context_t* context = (infiniband_context_t*) ctx;
504  long long now = PAPI_get_real_usec();
505  int i;
506  long long temp;
507 
508  for (i=0 ; i<INFINIBAND_MAX_COUNTERS ; ++i) {
509  if (control->being_measured[i])
510  {
511  temp = read_ib_counter_value(i);
512  if (context->start_value[i] && control->need_difference[i]) {
513  /* Must subtract values, but check for wraparound.
514  * We cannot even detect all wraparound cases. Using the short,
515  * auto-resetting IB counters is error prone.
516  */
517  if (temp < context->start_value[i]) {
518  SUBDBG("Wraparound!\nstart:\t%#016x\ttemp:\t%#016x",
519  (unsigned)context->start_value[i], (unsigned)temp);
520  /* The counters auto-reset. I cannot even adjust them to
521  * account for a simple wraparound.
522  * Just use the current reading of the counter, which is useless.
523  */
524  } else
525  temp -= context->start_value[i];
526  }
527  control->counts[i] = temp;
528  }
529  }
530  control->lastupdate = now;
531 
532  return PAPI_OK;
533 }
static long long read_ib_counter_value(int index)
return PAPI_OK
Definition: linux-nvml.c:458
int i
Definition: fileop.c:140
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
long long counts[INFINIBAND_MAX_COUNTERS]
long long PAPI_get_real_usec(void)
Definition: papi.c:6190
int temp
Definition: iozone.c:22158
int being_measured[INFINIBAND_MAX_COUNTERS]
int need_difference[INFINIBAND_MAX_COUNTERS]
long long start_value[INFINIBAND_MAX_COUNTERS]
#define INFINIBAND_MAX_COUNTERS

Here is the call graph for this function:

Here is the caller graph for this function:

int _infiniband_update_control_state ( hwd_control_state_t ctl,
NativeInfo_t native,
int  count,
hwd_context_t ctx 
)

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

591 {
592  int i, index;
593  ( void ) ctx;
594 
596 
597  for (i=0 ; i<INFINIBAND_MAX_COUNTERS ; ++i) {
598  control->being_measured[i] = 0;
599  }
600 
601  for (i=0 ; i<count ; ++i) {
602  index = native[i].ni_event & PAPI_NATIVE_AND_MASK;
603  native[i].ni_position =
605  control->being_measured[index] = 1;
606  control->need_difference[index] = 1;
607  }
608  return PAPI_OK;
609 }
static infiniband_native_event_entry_t * infiniband_native_events
infiniband_register_t resources
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
#define PAPI_NATIVE_AND_MASK
int being_measured[INFINIBAND_MAX_COUNTERS]
int need_difference[INFINIBAND_MAX_COUNTERS]
#define INFINIBAND_MAX_COUNTERS
static ib_counter_t* add_ib_counter ( const char *  name,
const char *  file_name,
int  extended,
ib_device_t device 
)
static

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

175 {
176  ib_counter_t *new_cnt = (ib_counter_t*) papi_calloc(sizeof(ib_counter_t), 1);
177  if (new_cnt == 0) {
178  PAPIERROR("cannot allocate memory for new IB counter structure");
179  return (0);
180  }
181 
182  new_cnt->ev_name = strdup(name);
183  new_cnt->ev_file_name = strdup(file_name);
184  new_cnt->extended = extended;
185  new_cnt->ev_device = device;
186  if (new_cnt->ev_name==0 || new_cnt->ev_file_name==0)
187  {
188  PAPIERROR("cannot allocate memory for counter internal fields");
189  papi_free(new_cnt);
190  return (0);
191  }
192 
193  // prepend the new counter to the counter list
194  new_cnt->next = root_counter;
195  root_counter = new_cnt;
196 
197  return (new_cnt);
198 }
#define papi_free(a)
Definition: papi_memory.h:35
void PAPIERROR(char *format,...)
struct _ib_counter_type * next
static DeviceData_t * device
Definition: linux-cuda.h:155
char * name
Definition: iozone.c:23648
static ib_counter_t * root_counter
ib_device_t * ev_device
#define papi_calloc(a, b)
Definition: papi_memory.h:37

Here is the call graph for this function:

Here is the caller graph for this function:

static ib_device_t* add_ib_device ( const char *  name,
int  port 
)
static

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

150 {
151  ib_device_t *new_dev = (ib_device_t*) papi_calloc(sizeof(ib_device_t), 1);
152  if (new_dev == 0) {
153  PAPIERROR("cannot allocate memory for new IB device structure");
154  return (0);
155  }
156 
157  new_dev->dev_name = strdup(name);
158  new_dev->dev_port = port;
159  if (new_dev->dev_name==0)
160  {
161  PAPIERROR("cannot allocate memory for device internal fields");
162  papi_free(new_dev);
163  return (0);
164  }
165 
166  // prepend the new device to the device list
167  new_dev->next = root_device;
168  root_device = new_dev;
169 
170  return (new_dev);
171 }
#define papi_free(a)
Definition: papi_memory.h:35
static ib_device_t * root_device
char * port
Definition: iozone.c:1620
void PAPIERROR(char *format,...)
char * name
Definition: iozone.c:23648
struct _ib_device_type * next
#define papi_calloc(a, b)
Definition: papi_memory.h:37

Here is the call graph for this function:

Here is the caller graph for this function:

static void deallocate_infiniband_resources ( )
static

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

384 {
385  int i;
386 
388  {
389  for (i=0 ; i<num_events ; ++i) {
392  if (infiniband_native_events[i].file_name)
393  free(infiniband_native_events[i].file_name);
394  if (infiniband_native_events[i].description)
395  papi_free(infiniband_native_events[i].description);
396  }
398  }
399 
401  while (iter != 0)
402  {
403  if (iter->dev_name)
404  free(iter->dev_name);
405 
406  ib_device_t *tmp = iter;
407  iter = iter->next;
408  papi_free(tmp);
409  }
410  root_device = 0;
411 }
static infiniband_native_event_entry_t * infiniband_native_events
#define papi_free(a)
Definition: papi_memory.h:35
static int num_events
long iter[MAX_THREADS]
int i
Definition: fileop.c:140
static ib_device_t * root_device
free(dummyfile[xx])
char * name
Definition: iozone.c:23648
struct _ib_device_type * next
long long tmp
Definition: iozone.c:12031

Here is the call graph for this function:

Here is the caller graph for this function:

static int find_ib_device_events ( ib_device_t dev,
int  extended 
)
static

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

203 {
204  int nevents = 0;
205  DIR *cnt_dir = NULL;
206  char counters_path[128];
207  snprintf(counters_path, sizeof(counters_path), "%s/%s/ports/%d/counters%s",
208  ib_dir_path, dev->dev_name, dev->dev_port, (extended?"_ext":""));
209 
210  cnt_dir = opendir(counters_path);
211  if (cnt_dir == NULL) {
212  SUBDBG("cannot open counters directory `%s'\n", counters_path);
213  goto out;
214  }
215 
216  struct dirent *ev_ent;
217  /* iterate over all the events */
218  while ((ev_ent = readdir(cnt_dir)) != NULL) {
219  char *ev_name = ev_ent->d_name;
220  long long value = -1;
221  char event_path[160];
222  char counter_name[80];
223 
224  if (ev_name[0] == '.')
225  continue;
226 
227  /* Check that we can read an integer from the counter file */
228  snprintf(event_path, sizeof(event_path), "%s/%s", counters_path, ev_name);
229  if (pscanf(event_path, "%lld", &value) != 1) {
230  SUBDBG("cannot read value for event '%s'\n", ev_name);
231  continue;
232  }
233 
234  /* Create new counter */
235  snprintf(counter_name, sizeof(counter_name), "%s_%d%s:%s",
236  dev->dev_name, dev->dev_port, (extended?"_ext":""), ev_name);
237  if (add_ib_counter(counter_name, ev_name, extended, dev))
238  {
239  SUBDBG("Added new counter `%s'\n", counter_name);
240  nevents += 1;
241  }
242  }
243 
244  out:
245  if (cnt_dir != NULL)
246  closedir(cnt_dir);
247 
248  return (nevents);
249 }
static const char * ib_dir_path
void double value
Definition: iozone.c:18781
static ib_counter_t * add_ib_counter(const char *name, const char *file_name, int extended, ib_device_t *device)
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
goto out
Definition: pscanf.h:20

Here is the call graph for this function:

Here is the caller graph for this function:

static int find_ib_devices ( )
static

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

253 {
254  DIR *ib_dir = NULL;
255  int result = PAPI_OK;
256  num_events = 0;
257 
258  ib_dir = opendir(ib_dir_path);
259  if (ib_dir == NULL) {
260  SUBDBG("cannot open `%s'\n", ib_dir_path);
262  "Infiniband sysfs interface not found", PAPI_MAX_STR_LEN);
263  result = PAPI_ENOSUPP;
264  goto out;
265  }
266 
267  struct dirent *hca_ent;
268  while ((hca_ent = readdir(ib_dir)) != NULL) {
269  char *hca = hca_ent->d_name;
270  char ports_path[80];
271  DIR *ports_dir = NULL;
272 
273  if (hca[0] == '.')
274  goto next_hca;
275 
276  snprintf(ports_path, sizeof(ports_path), "%s/%s/ports", ib_dir_path, hca);
277  ports_dir = opendir(ports_path);
278  if (ports_dir == NULL) {
279  SUBDBG("cannot open `%s'\n", ports_path);
280  goto next_hca;
281  }
282 
283  struct dirent *port_ent;
284  while ((port_ent = readdir(ports_dir)) != NULL) {
285  int port = atoi(port_ent->d_name);
286  if (port <= 0)
287  continue;
288 
289  /* Check that port is active. .../HCA/ports/PORT/state should read "4: ACTIVE." */
290  int state = -1;
291  char state_path[80];
292  snprintf(state_path, sizeof(state_path), "%s/%s/ports/%d/state", ib_dir_path, hca, port);
293  if (pscanf(state_path, "%d", &state) != 1) {
294  SUBDBG("cannot read state of IB HCA `%s' port %d\n", hca, port);
295  continue;
296  }
297 
298  if (state != 4) {
299  SUBDBG("skipping inactive IB HCA `%s', port %d, state %d\n", hca, port, state);
300  continue;
301  }
302 
303  /* Create dev name (HCA/PORT) and get stats for dev. */
304  SUBDBG("Found IB device `%s', port %d\n", hca, port);
305  ib_device_t *dev = add_ib_device(hca, port);
306  if (!dev)
307  continue;
308  // do we want to check for short counters only if no extended counters found?
309  num_events += find_ib_device_events(dev, 1); // check if we have extended (64bit) counters
310  num_events += find_ib_device_events(dev, 0); // check also for short counters
311  }
312 
313  next_hca:
314  if (ports_dir != NULL)
315  closedir(ports_dir);
316  }
317 
318  if (root_device == 0) // no active devices found
319  {
321  "No active Infiniband ports found", PAPI_MAX_STR_LEN);
322  result = PAPI_ENOIMPL;
323  } else if (num_events == 0)
324  {
326  "No supported Infiniband events found", PAPI_MAX_STR_LEN);
327  result = PAPI_ENOIMPL;
328  } else
329  {
330  // Events are stored in a linked list, in reverse order than how I found them
331  // Revert them again, so that they are in finding order, not that it matters.
332  int i = num_events - 1;
333  // now allocate memory to store the counters into the native table
337  while (iter != 0)
338  {
346 
347  ib_counter_t *tmp = iter;
348  iter = iter->next;
349  papi_free(tmp);
350  -- i;
351  }
352  root_counter = 0;
353  }
354 
355  out:
356  if (ib_dir != NULL)
357  closedir(ib_dir);
358 
359  return (result);
360 }
int atoi()
static infiniband_native_event_entry_t * infiniband_native_events
#define papi_free(a)
Definition: papi_memory.h:35
char * name
#define PAPI_ENOSUPP
Definition: papi.h:269
static int num_events
static const char * ib_dir_path
infiniband_register_t resources
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
char * description
ib_device_t * device
static int find_ib_device_events(ib_device_t *dev, int extended)
int extended
char disabled_reason[PAPI_MAX_STR_LEN]
Definition: papi.h:633
long iter[MAX_THREADS]
int i
Definition: fileop.c:140
static ib_device_t * root_device
static char * make_ib_event_description(const char *input_str, int extended)
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
char * port
Definition: iozone.c:1620
char * file_name
#define PAPI_ENOIMPL
Definition: papi.h:270
struct _ib_counter_type * next
goto out
Definition: pscanf.h:20
static ib_counter_t * root_counter
child_idents[x-1] state
Definition: iozone.c:21341
static ib_device_t * add_ib_device(const char *name, int port)
ib_device_t * ev_device
#define PAPI_MAX_STR_LEN
Definition: papi.h:463
long long tmp
Definition: iozone.c:12031
papi_vector_t _infiniband_vector
#define papi_calloc(a, b)
Definition: papi_memory.h:37

Here is the call graph for this function:

Here is the caller graph for this function:

static char* make_ib_event_description ( const char *  input_str,
int  extended 
)
static

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

124 {
125  int i, len;
126  char *desc = 0;
127  if (! input_str)
128  return (0);
129 
130  desc = (char*) papi_calloc(PAPI_MAX_STR_LEN, 1);
131  if (desc == 0) {
132  PAPIERROR("cannot allocate memory for event description");
133  return (0);
134  }
135  len = strlen(input_str);
136 
137  snprintf(desc, PAPI_MAX_STR_LEN, "%s (%s).",
138  input_str, (extended ? "free-running 64bit counter" :
139  "overflowing, auto-resetting counter"));
140  desc[0] = toupper(desc[0]);
141  for (i=0 ; i<len ; ++i)
142  if (desc[i] == '_')
143  desc[i] = ' ';
144 
145  return (desc);
146 }
int i
Definition: fileop.c:140
void PAPIERROR(char *format,...)
#define PAPI_MAX_STR_LEN
Definition: papi.h:463
#define papi_calloc(a, b)
Definition: papi_memory.h:37

Here is the call graph for this function:

Here is the caller graph for this function:

static long long read_ib_counter_value ( int  index)
static

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

364 {
365  char ev_file[128];
366  long long value = 0ll;
368  snprintf(ev_file, sizeof(ev_file), "%s/%s/ports/%d/counters%s/%s",
369  ib_dir_path, iter->device->dev_name,
370  iter->device->dev_port, (iter->extended?"_ext":""),
371  iter->file_name);
372 
373  if (pscanf(ev_file, "%lld", &value) != 1) {
374  PAPIERROR("cannot read value for counter '%s'\n", iter->name);
375  } else
376  {
377  SUBDBG("Counter '%s': %lld\n", iter->name, value);
378  }
379  return (value);
380 }
static infiniband_native_event_entry_t * infiniband_native_events
char * name
static const char * ib_dir_path
ib_device_t * device
void double value
Definition: iozone.c:18781
int extended
long iter[MAX_THREADS]
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
void PAPIERROR(char *format,...)
char * file_name

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

papi_vector_t _infiniband_vector

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

const char* ib_dir_path = "/sys/class/infiniband"
static

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

infiniband_native_event_entry_t* infiniband_native_events = 0
static

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

int num_events = 0
static

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

ib_counter_t* root_counter = 0
static

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

ib_device_t* root_device = 0
static

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