PAPI  5.6.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
linux-infiniband.c
Go to the documentation of this file.
1 
23 /* Headers required by infiniband */
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <unistd.h>
27 #include <errno.h>
28 #include <ctype.h>
29 #include <string.h>
30 #include <dirent.h>
31 #include <error.h>
32 #include <time.h>
33 #include "pscanf.h"
34 
35 /* Headers required by PAPI */
36 #include "papi.h"
37 #include "papi_internal.h"
38 #include "papi_vector.h"
39 #include "papi_memory.h"
40 
41 /************************* DEFINES SECTION ***********************************
42  *******************************************************************************/
43 /* this number assumes that there will never be more events than indicated */
44 #define INFINIBAND_MAX_COUNTERS 128
45 
47 typedef struct infiniband_register
48 {
49  /* This is used by the framework.It likes it to be !=0 to do somehting */
50  unsigned int selector;
52 
53 /*
54  * The following structures mimic the ones used by other components. It is more
55  * convenient to use them like that as programming with PAPI makes specific
56  * assumptions for them.
57  */
58 
59 typedef struct _ib_device_type
60 {
61  char* dev_name;
62  int dev_port;
63  struct _ib_device_type *next;
64 } ib_device_t;
65 
66 typedef struct _ib_counter_type
67 {
68  char* ev_name;
69  char* ev_file_name;
71  int extended; // if this is an extended (64-bit) counter
72  struct _ib_counter_type *next;
73 } ib_counter_t;
74 
75 static const char *ib_dir_path = "/sys/class/infiniband";
76 
78 typedef struct _infiniband_native_event_entry
79 {
81  char *name;
82  char *description;
83  char* file_name;
85  int extended; /* if this is an extended (64-bit) counter */
87 
88 
89 typedef struct _infiniband_control_state
90 {
91  long long counts[INFINIBAND_MAX_COUNTERS];
92  int being_measured[INFINIBAND_MAX_COUNTERS];
93  /* all IB counters need difference, but use a flag for generality */
94  int need_difference[INFINIBAND_MAX_COUNTERS];
95  long long lastupdate;
97 
98 
99 typedef struct _infiniband_context
100 {
102  long long start_value[INFINIBAND_MAX_COUNTERS];
104 
105 
106 
107 /************************* GLOBALS SECTION ***********************************
108  *******************************************************************************/
109 /* This table contains the component native events */
111 /* number of events in the table*/
112 static int num_events = 0;
113 
114 
116 
117 /******************************************************************************
118  ******** BEGIN FUNCTIONS USED INTERNALLY SPECIFIC TO THIS COMPONENT ********
119  *****************************************************************************/
120 
123 
124 static char*
125 make_ib_event_description(const char* input_str, int extended)
126 {
127  int i, len;
128  char *desc = 0;
129  if (! input_str)
130  return (0);
131 
132  desc = (char*) papi_calloc(PAPI_MAX_STR_LEN, 1);
133  if (desc == 0) {
134  PAPIERROR("cannot allocate memory for event description");
135  return (0);
136  }
137  len = strlen(input_str);
138 
139  snprintf(desc, PAPI_MAX_STR_LEN, "%s (%s).",
140  input_str, (extended ? "free-running 64bit counter" :
141  "overflowing, auto-resetting counter"));
142  desc[0] = toupper(desc[0]);
143  for (i=0 ; i<len ; ++i)
144  if (desc[i] == '_')
145  desc[i] = ' ';
146 
147  return (desc);
148 }
149 
150 static ib_device_t*
151 add_ib_device(const char* name, int port)
152 {
153  ib_device_t *new_dev = (ib_device_t*) papi_calloc(sizeof(ib_device_t), 1);
154  if (new_dev == 0) {
155  PAPIERROR("cannot allocate memory for new IB device structure");
156  return (0);
157  }
158 
159  new_dev->dev_name = strdup(name);
160  new_dev->dev_port = port;
161  if (new_dev->dev_name==0)
162  {
163  PAPIERROR("cannot allocate memory for device internal fields");
164  papi_free(new_dev);
165  return (0);
166  }
167 
168  // prepend the new device to the device list
169  new_dev->next = root_device;
170  root_device = new_dev;
171 
172  return (new_dev);
173 }
174 
175 static ib_counter_t*
176 add_ib_counter(const char* name, const char* file_name, int extended, ib_device_t *device)
177 {
178  ib_counter_t *new_cnt = (ib_counter_t*) papi_calloc(sizeof(ib_counter_t), 1);
179  if (new_cnt == 0) {
180  PAPIERROR("cannot allocate memory for new IB counter structure");
181  return (0);
182  }
183 
184  new_cnt->ev_name = strdup(name);
185  new_cnt->ev_file_name = strdup(file_name);
186  new_cnt->extended = extended;
187  new_cnt->ev_device = device;
188  if (new_cnt->ev_name==0 || new_cnt->ev_file_name==0)
189  {
190  PAPIERROR("cannot allocate memory for counter internal fields");
191  papi_free(new_cnt);
192  return (0);
193  }
194 
195  // prepend the new counter to the counter list
196  new_cnt->next = root_counter;
197  root_counter = new_cnt;
198 
199  return (new_cnt);
200 }
201 
202 
203 static int
205 {
206  int nevents = 0;
207  DIR *cnt_dir = NULL;
208  char counters_path[128];
209 
210  if ( extended ) {
211  /* mofed driver version <4.0 */
212  snprintf(counters_path, sizeof(counters_path), "%s/%s/ports/%d/counters%s",
213  ib_dir_path, dev->dev_name, dev->dev_port, (extended?"_ext":""));
214 
215  cnt_dir = opendir(counters_path);
216  if (cnt_dir == NULL) {
217  /* directory counters_ext in sysfs fs has changed to hw_counters */
218  /* in 4.0 version of mofed driver */
219  SUBDBG("cannot open counters directory `%s'\n", counters_path);
220 
221  snprintf(counters_path, sizeof(counters_path), "%s/%s/ports/%d/%scounters",
222  ib_dir_path, dev->dev_name, dev->dev_port, "hw_");
223 
224  cnt_dir = opendir(counters_path);
225  }
226  }
227  else {
228  snprintf(counters_path, sizeof(counters_path), "%s/%s/ports/%d/counters",
229  ib_dir_path, dev->dev_name, dev->dev_port);
230  cnt_dir = opendir(counters_path);
231  }
232 
233  if (cnt_dir == NULL) {
234  SUBDBG("cannot open counters directory `%s'\n", counters_path);
235  goto out;
236  }
237 
238  struct dirent *ev_ent;
239  /* iterate over all the events */
240  while ((ev_ent = readdir(cnt_dir)) != NULL) {
241  char *ev_name = ev_ent->d_name;
242  long long value = -1;
243  char event_path[160];
244  char counter_name[80];
245 
246  if (ev_name[0] == '.')
247  continue;
248 
249  /* Check that we can read an integer from the counter file */
250  snprintf(event_path, sizeof(event_path), "%s/%s", counters_path, ev_name);
251  if (pscanf(event_path, "%lld", &value) != 1) {
252  SUBDBG("cannot read value for event '%s'\n", ev_name);
253  continue;
254  }
255 
256  /* Create new counter */
257  snprintf(counter_name, sizeof(counter_name), "%s_%d%s:%s",
258  dev->dev_name, dev->dev_port, (extended?"_ext":""), ev_name);
259  if (add_ib_counter(counter_name, ev_name, extended, dev))
260  {
261  SUBDBG("Added new counter `%s'\n", counter_name);
262  nevents += 1;
263  }
264  }
265 
266  out:
267  if (cnt_dir != NULL)
268  closedir(cnt_dir);
269 
270  return (nevents);
271 }
272 
273 static int
275 {
276  DIR *ib_dir = NULL;
277  int result = PAPI_OK;
278  num_events = 0;
279 
280  ib_dir = opendir(ib_dir_path);
281  if (ib_dir == NULL) {
282  SUBDBG("cannot open `%s'\n", ib_dir_path);
283  strncpy(_infiniband_vector.cmp_info.disabled_reason,
284  "Infiniband sysfs interface not found", PAPI_MAX_STR_LEN);
285  result = PAPI_ENOSUPP;
286  goto out;
287  }
288 
289  struct dirent *hca_ent;
290  while ((hca_ent = readdir(ib_dir)) != NULL) {
291  char *hca = hca_ent->d_name;
292  char ports_path[80];
293  DIR *ports_dir = NULL;
294 
295  if (hca[0] == '.')
296  goto next_hca;
297 
298  snprintf(ports_path, sizeof(ports_path), "%s/%s/ports", ib_dir_path, hca);
299  ports_dir = opendir(ports_path);
300  if (ports_dir == NULL) {
301  SUBDBG("cannot open `%s'\n", ports_path);
302  goto next_hca;
303  }
304 
305  struct dirent *port_ent;
306  while ((port_ent = readdir(ports_dir)) != NULL) {
307  int port = atoi(port_ent->d_name);
308  if (port <= 0)
309  continue;
310 
311  /* Check that port is active. .../HCA/ports/PORT/state should read "4: ACTIVE." */
312  int state = -1;
313  char state_path[80];
314  snprintf(state_path, sizeof(state_path), "%s/%s/ports/%d/state", ib_dir_path, hca, port);
315  if (pscanf(state_path, "%d", &state) != 1) {
316  SUBDBG("cannot read state of IB HCA `%s' port %d\n", hca, port);
317  continue;
318  }
319 
320  if (state != 4) {
321  SUBDBG("skipping inactive IB HCA `%s', port %d, state %d\n", hca, port, state);
322  continue;
323  }
324 
325  /* Create dev name (HCA/PORT) and get stats for dev. */
326  SUBDBG("Found IB device `%s', port %d\n", hca, port);
327  ib_device_t *dev = add_ib_device(hca, port);
328  if (!dev)
329  continue;
330  // do we want to check for short counters only if no extended counters found?
331  num_events += find_ib_device_events(dev, 1); // check if we have extended (64bit) counters
332  num_events += find_ib_device_events(dev, 0); // check also for short counters
333  }
334 
335  next_hca:
336  if (ports_dir != NULL)
337  closedir(ports_dir);
338  }
339 
340  if (root_device == 0) // no active devices found
341  {
342  strncpy(_infiniband_vector.cmp_info.disabled_reason,
343  "No active Infiniband ports found", PAPI_MAX_STR_LEN);
344  result = PAPI_ENOIMPL;
345  } else if (num_events == 0)
346  {
347  strncpy(_infiniband_vector.cmp_info.disabled_reason,
348  "No supported Infiniband events found", PAPI_MAX_STR_LEN);
349  result = PAPI_ENOIMPL;
350  } else
351  {
352  // Events are stored in a linked list, in reverse order than how I found them
353  // Revert them again, so that they are in finding order, not that it matters.
354  int i = num_events - 1;
355  // now allocate memory to store the counters into the native table
356  infiniband_native_events = (infiniband_native_event_entry_t*)
359  while (iter != 0)
360  {
361  infiniband_native_events[i].name = iter->ev_name;
362  infiniband_native_events[i].file_name = iter->ev_file_name;
363  infiniband_native_events[i].device = iter->ev_device;
364  infiniband_native_events[i].extended = iter->extended;
365  infiniband_native_events[i].resources.selector = i + 1;
366  infiniband_native_events[i].description =
368 
369  ib_counter_t *tmp = iter;
370  iter = iter->next;
371  papi_free(tmp);
372  -- i;
373  }
374  root_counter = 0;
375  }
376 
377  out:
378  if (ib_dir != NULL)
379  closedir(ib_dir);
380 
381  return (result);
382 }
383 
384 static long long
386 {
387  char ev_file[128];
388  char counters_path[128];
389  DIR *cnt_dir = NULL;
390  long long value = 0ll;
391  infiniband_native_event_entry_t *iter = &infiniband_native_events[index];
392 
393  if ( iter->extended ) {
394  /* mofed driver version <4.0 */
395  snprintf(counters_path, sizeof(counters_path), "%s/%s/ports/%d/counters%s",
396  ib_dir_path, iter->device->dev_name, iter->device->dev_port, "_ext");
397 
398  cnt_dir = opendir(counters_path);
399  if (cnt_dir == NULL) {
400  /* directory counters_ext in sysfs fs has changed to hw_counters */
401  /* in 4.0 version of mofed driver */
402  snprintf(counters_path, sizeof(counters_path), "%s/%s/ports/%d/%scounters",
403  ib_dir_path, iter->device->dev_name, iter->device->dev_port, "hw_");
404 
405  cnt_dir = opendir(counters_path);
406  }
407  }
408  else {
409  snprintf(counters_path, sizeof(counters_path), "%s/%s/ports/%d/counters",
410  ib_dir_path, iter->device->dev_name, iter->device->dev_port );
411  cnt_dir = opendir(counters_path);
412  }
413 
414 
415  if (cnt_dir != NULL)
416  closedir(cnt_dir);
417 
418 
419  snprintf(ev_file, sizeof(ev_file), "%s/%s",
420  counters_path, iter->file_name);
421 
422  if (pscanf(ev_file, "%lld", &value) != 1) {
423  PAPIERROR("cannot read value for counter '%s'\n", iter->name);
424  } else
425  {
426  SUBDBG("Counter '%s': %lld\n", iter->name, value);
427  }
428  return (value);
429 }
430 
431 static void
433 {
434  int i;
435 
436  if (infiniband_native_events)
437  {
438  for (i=0 ; i<num_events ; ++i) {
439  if (infiniband_native_events[i].name)
440  free(infiniband_native_events[i].name);
441  if (infiniband_native_events[i].file_name)
442  free(infiniband_native_events[i].file_name);
443  if (infiniband_native_events[i].description)
444  papi_free(infiniband_native_events[i].description);
445  }
446  papi_free(infiniband_native_events);
447  }
448 
450  while (iter != 0)
451  {
452  if (iter->dev_name)
453  free(iter->dev_name);
454 
455  ib_device_t *tmp = iter;
456  iter = iter->next;
457  papi_free(tmp);
458  }
459  root_device = 0;
460 }
461 
462 /*****************************************************************************
463  ******************* BEGIN PAPI's COMPONENT REQUIRED FUNCTIONS *************
464  *****************************************************************************/
465 
466 /*
467  * This is called whenever a thread is initialized
468  */
469 static int
471 {
472  (void) ctx;
473  return PAPI_OK;
474 }
475 
476 
477 /* Initialize hardware counters, setup the function vector table
478  * and get hardware information, this routine is called when the
479  * PAPI process is initialized (IE PAPI_library_init)
480  */
481 static int
483 {
484  /* discover Infiniband devices and available events */
485  int result = find_ib_devices();
486 
487  if (result != PAPI_OK) // we couldn't initialize the component
488  {
489  // deallocate any eventually allocated memory
491  }
492 
493  _infiniband_vector.cmp_info.num_native_events = num_events;
494 
495  _infiniband_vector.cmp_info.num_cntrs = num_events;
496  _infiniband_vector.cmp_info.num_mpx_cntrs = num_events;
497 
498 
499  /* Export the component id */
500  _infiniband_vector.cmp_info.CmpIdx = cidx;
501 
502  return (result);
503 }
504 
505 
506 /*
507  * Control of counters (Reading/Writing/Starting/Stopping/Setup)
508  * functions
509  */
510 static int
512 {
514  int i;
515 
516  for (i=0 ; i<INFINIBAND_MAX_COUNTERS ; ++i) {
517  control->being_measured[i] = 0;
518  }
519 
520  return PAPI_OK;
521 }
522 
523 /*
524  *
525  */
526 static int
528 {
529  infiniband_context_t* context = (infiniband_context_t*) ctx;
531  long long now = PAPI_get_real_usec();
532  int i;
533 
534  for (i=0 ; i<INFINIBAND_MAX_COUNTERS ; ++i) {
535  if (control->being_measured[i] && control->need_difference[i]) {
536  context->start_value[i] = read_ib_counter_value(i);
537  }
538  }
539  control->lastupdate = now;
540 
541  return PAPI_OK;
542 }
543 
544 
545 /*
546  *
547  */
548 static int
550 {
551  infiniband_context_t* context = (infiniband_context_t*) ctx;
553  long long now = PAPI_get_real_usec();
554  int i;
555  long long temp;
556 
557  for (i=0 ; i<INFINIBAND_MAX_COUNTERS ; ++i) {
558  if (control->being_measured[i])
559  {
560  temp = read_ib_counter_value(i);
561  if (context->start_value[i] && control->need_difference[i]) {
562  /* Must subtract values, but check for wraparound.
563  * We cannot even detect all wraparound cases. Using the short,
564  * auto-resetting IB counters is error prone.
565  */
566  if (temp < context->start_value[i]) {
567  SUBDBG("Wraparound!\nstart:\t%#016x\ttemp:\t%#016x",
568  (unsigned)context->start_value[i], (unsigned)temp);
569  /* The counters auto-reset. I cannot even adjust them to
570  * account for a simple wraparound.
571  * Just use the current reading of the counter, which is useless.
572  */
573  } else
574  temp -= context->start_value[i];
575  }
576  control->counts[i] = temp;
577  }
578  }
579  control->lastupdate = now;
580 
581  return PAPI_OK;
582 }
583 
584 
585 /*
586  *
587  */
588 static int
590  long_long ** events, int flags )
591 {
592  ( void ) flags;
593 
594  _infiniband_stop(ctx, ctl); /* we cannot actually stop the counters */
595  /* Pass back a pointer to our results */
596  *events = ((infiniband_control_state_t*) ctl)->counts;
597 
598  return PAPI_OK;
599 }
600 
601 
602 static int
604 {
605  /* Cleanup resources used by this component before leaving */
607 
608  return PAPI_OK;
609 }
610 
611 static int
613 {
614  ( void ) ctx;
615 
616  return PAPI_OK;
617 }
618 
619 
620 
621 /* This function sets various options in the component
622  * The valid codes being passed in are PAPI_SET_DEFDOM,
623  * PAPI_SET_DOMAIN, PAPI_SETDEFGRN, PAPI_SET_GRANUL * and PAPI_SET_INHERIT
624  */
625 static int
627 {
628  ( void ) ctx;
629  ( void ) code;
630  ( void ) option;
631  return PAPI_OK;
632 }
633 
634 
635 static int
637  NativeInfo_t * native,
638  int count,
639  hwd_context_t *ctx )
640 {
641  int i, index;
642  ( void ) ctx;
643 
645 
646  for (i=0 ; i<INFINIBAND_MAX_COUNTERS ; ++i) {
647  control->being_measured[i] = 0;
648  }
649 
650  for (i=0 ; i<count ; ++i) {
651  index = native[i].ni_event & PAPI_NATIVE_AND_MASK;
652  native[i].ni_position =
653  infiniband_native_events[index].resources.selector - 1;
654  control->being_measured[index] = 1;
655  control->need_difference[index] = 1;
656  }
657  return PAPI_OK;
658 }
659 
660 
661 /*
662  * This function has to set the bits needed to count different domains
663  * In particular: PAPI_DOM_USER, PAPI_DOM_KERNEL PAPI_DOM_OTHER
664  * By default return PAPI_EINVAL if none of those are specified
665  * and PAPI_OK with success
666  * PAPI_DOM_USER is only user context is counted
667  * PAPI_DOM_KERNEL is only the Kernel/OS context is counted
668  * PAPI_DOM_OTHER is Exception/transient mode (like user TLB misses)
669  * PAPI_DOM_ALL is all of the domains
670  */
671 static int
673 {
674  int found = 0;
675  (void) ctl;
676 
677  if (PAPI_DOM_USER & domain)
678  found = 1;
679 
680  if (PAPI_DOM_KERNEL & domain)
681  found = 1;
682 
683  if (PAPI_DOM_OTHER & domain)
684  found = 1;
685 
686  if (!found)
687  return (PAPI_EINVAL);
688 
689  return (PAPI_OK);
690 }
691 
692 
693 /*
694  * Cannot reset the counters using the sysfs interface.
695  */
696 static int
698 {
699  (void) ctx;
700  (void) ctl;
701  return PAPI_OK;
702 }
703 
704 
705 /*
706  * Native Event functions
707  */
708 static int
709 _infiniband_ntv_enum_events( unsigned int *EventCode, int modifier )
710 {
711  switch (modifier) {
712  case PAPI_ENUM_FIRST:
713  if (num_events == 0)
714  return (PAPI_ENOEVNT);
715 
716  *EventCode = 0;
717  return PAPI_OK;
718 
719  case PAPI_ENUM_EVENTS:
720  {
721  int index = *EventCode & PAPI_NATIVE_AND_MASK;
722 
723  if (index < num_events - 1) {
724  *EventCode = *EventCode + 1;
725  return PAPI_OK;
726  } else
727  return PAPI_ENOEVNT;
728 
729  break;
730  }
731  default:
732  return PAPI_EINVAL;
733  }
734  return PAPI_EINVAL;
735 }
736 
737 /*
738  *
739  */
740 static int
741 _infiniband_ntv_code_to_name( unsigned int EventCode, char *name, int len )
742 {
743  int index = EventCode;
744 
745  if (index>=0 && index<num_events) {
746  strncpy( name, infiniband_native_events[index].name, len );
747  }
748 
749  return PAPI_OK;
750 }
751 
752 /*
753  *
754  */
755 static int
756 _infiniband_ntv_code_to_descr( unsigned int EventCode, char *name, int len )
757 {
758  int index = EventCode;
759 
760  if (index>=0 && index<num_events) {
761  strncpy(name, infiniband_native_events[index].description, len);
762  }
763  return PAPI_OK;
764 }
765 
766 static int
767 _infiniband_ntv_code_to_info(unsigned int EventCode, PAPI_event_info_t *info)
768 {
769  int index = EventCode;
770 
771  if ( ( index < 0) || (index >= num_events )) return PAPI_ENOEVNT;
772 
773  if (infiniband_native_events[index].name)
774  {
775  unsigned int len = strlen(infiniband_native_events[index].name);
776  if (len > sizeof(info->symbol)-1) len = sizeof(info->symbol)-1;
777  strncpy(info->symbol, infiniband_native_events[index].name, len);
778  info->symbol[len] = '\0';
779  }
780  if (infiniband_native_events[index].description)
781  {
782  unsigned int len = strlen(infiniband_native_events[index].description);
783  if (len > sizeof(info->long_descr)-1) len = sizeof(info->long_descr)-1;
784  strncpy(info->long_descr, infiniband_native_events[index].description, len);
785  info->long_descr[len] = '\0';
786  }
787 
788  strncpy(info->units, "\0", 1);
789  /* infiniband_native_events[index].units, sizeof(info->units)); */
790 
791 /* info->data_type = infiniband_native_events[index].return_type;
792  */
793  return PAPI_OK;
794 }
795 
796 
797 /*
798  *
799  */
800 papi_vector_t _infiniband_vector = {
801  .cmp_info = {
802  /* component information (unspecified values are initialized to 0) */
803  .name = "infiniband",
804  .short_name = "infiniband",
805  .version = "5.3.0",
806  .description = "Linux Infiniband statistics using the sysfs interface",
807  .num_mpx_cntrs = INFINIBAND_MAX_COUNTERS,
808  .num_cntrs = INFINIBAND_MAX_COUNTERS,
809  .default_domain = PAPI_DOM_USER | PAPI_DOM_KERNEL,
810  .available_domains = PAPI_DOM_USER | PAPI_DOM_KERNEL,
811  .default_granularity = PAPI_GRN_SYS,
812  .available_granularities = PAPI_GRN_SYS,
813  .hardware_intr_sig = PAPI_INT_SIGNAL,
814 
815  /* component specific cmp_info initializations */
816  .fast_real_timer = 0,
817  .fast_virtual_timer = 0,
818  .attach = 0,
819  .attach_must_ptrace = 0,
820  },
821 
822  /* sizes of framework-opaque component-private structures */
823  .size = {
824  .context = sizeof (infiniband_context_t),
825  .control_state = sizeof (infiniband_control_state_t),
826  .reg_value = sizeof (infiniband_register_t),
827  /* .reg_alloc = sizeof (infiniband_reg_alloc_t), */
828  },
829  /* function pointers in this component */
830  .init_thread = _infiniband_init_thread,
831  .init_component = _infiniband_init_component,
832  .init_control_state = _infiniband_init_control_state,
836  .shutdown_thread = _infiniband_shutdown_thread,
837  .shutdown_component = _infiniband_shutdown_component,
838  .ctl = _infiniband_ctl,
839  .update_control_state = _infiniband_update_control_state,
841  .reset = _infiniband_reset,
842 
843  .ntv_enum_events = _infiniband_ntv_enum_events,
844  .ntv_code_to_name = _infiniband_ntv_code_to_name,
845  .ntv_code_to_descr = _infiniband_ntv_code_to_descr,
846  .ntv_code_to_info = _infiniband_ntv_code_to_info,
847 };
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:629
#define PAPI_ENOEVNT
Definition: papi.h:260
int atoi()
ssize_t read(int fd, void *buf, size_t count)
Definition: appio.c:225
static infiniband_native_event_entry_t * infiniband_native_events
static void deallocate_infiniband_resources()
long long flags
Definition: iozone.c:12330
#define papi_free(a)
Definition: papi_memory.h:35
char * name
start
Definition: iozone.c:22736
static int num_events
static long long read_ib_counter_value(int index)
#define PAPI_ENOSUPP
Definition: papi.h:271
#define PAPI_DOM_KERNEL
Definition: papi.h:300
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:969
infiniband_control_state_t state
static const char * ib_dir_path
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:966
infiniband_register_t resources
return PAPI_OK
Definition: linux-nvml.c:497
int count
Definition: iozone.c:22422
#define PAPI_DOM_USER
Definition: papi.h:298
void
Definition: iozone.c:18627
return PAPI_EINVAL
Definition: linux-nvml.c:436
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
char * description
ib_device_t * device
void double value
Definition: iozone.c:18781
static int find_ib_device_events(ib_device_t *dev, int extended)
Return codes and api definitions.
static int _infiniband_read(hwd_context_t *ctx, hwd_control_state_t *ctl, long_long **events, int flags)
char events[MAX_EVENTS][BUFSIZ]
static ib_counter_t * add_ib_counter(const char *name, const char *file_name, int extended, ib_device_t *device)
static int _infiniband_ntv_code_to_name(unsigned int EventCode, char *name, int len)
int extended
static int _infiniband_start(hwd_context_t *ctx, hwd_control_state_t *ctl)
static int _infiniband_init_thread(hwd_context_t *ctx)
static int cidx
char disabled_reason[PAPI_MAX_STR_LEN]
Definition: papi.h:636
static long iter[MAX_THREADS]
int i
Definition: fileop.c:140
static int _infiniband_reset(hwd_context_t *ctx, hwd_control_state_t *ctl)
static int set_domain(hwd_control_state_t *cntrl, unsigned int domain)
static ib_device_t * root_device
static char * make_ib_event_description(const char *input_str, int extended)
static int _infiniband_shutdown_component(void)
long long found
Definition: libasync.c:735
free(dummyfile[xx])
static int _infiniband_shutdown_thread(hwd_context_t *ctx)
static int _infiniband_init_component(int cidx)
stop
Definition: iozone.c:22741
static int native
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
char * port
Definition: iozone.c:1620
void PAPIERROR(char *format,...)
static int _infiniband_ctl(hwd_context_t *ctx, int code, _papi_int_option_t *option)
static int _infiniband_update_control_state(hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
#define PAPI_INT_SIGNAL
Definition: papi_internal.h:53
char * file_name
static int _infiniband_stop(hwd_context_t *ctx, hwd_control_state_t *ctl)
#define PAPI_ENOIMPL
Definition: papi.h:272
struct _ib_counter_type * next
static int _infiniband_init_control_state(hwd_control_state_t *ctl)
goto out
Definition: pscanf.h:20
long long counts[INFINIBAND_MAX_COUNTERS]
long long PAPI_get_real_usec(void)
Definition: papi.c:6264
char * name
Definition: iozone.c:23648
static int find_ib_devices()
static ib_counter_t * root_counter
int temp
Definition: iozone.c:22158
#define long_long
Definition: papi.h:552
child_idents[x-1] state
Definition: iozone.c:21341
#define PAPI_NATIVE_AND_MASK
static ib_device_t * add_ib_device(const char *name, int port)
int being_measured[INFINIBAND_MAX_COUNTERS]
ib_device_t * ev_device
#define PAPI_MAX_STR_LEN
Definition: papi.h:465
static int _infiniband_ntv_code_to_descr(unsigned int EventCode, char *name, int len)
#define PAPI_DOM_OTHER
Definition: papi.h:301
struct _ib_device_type * next
int need_difference[INFINIBAND_MAX_COUNTERS]
static int _infiniband_set_domain(hwd_control_state_t *ctl, int domain)
#define PAPI_GRN_SYS
Definition: papi.h:366
static int _infiniband_ntv_code_to_info(unsigned int EventCode, PAPI_event_info_t *info)
static int _infiniband_ntv_enum_events(unsigned int *EventCode, int modifier)
long long tmp
Definition: iozone.c:12031
papi_vector_t _infiniband_vector
long long start_value[INFINIBAND_MAX_COUNTERS]
char units[PAPI_MIN_STR_LEN]
Definition: papi.h:975
#define papi_calloc(a, b)
Definition: papi_memory.h:37
#define INFINIBAND_MAX_COUNTERS