44 #define INFINIBAND_MAX_COUNTERS 128 47 typedef struct infiniband_register
59 typedef struct _ib_device_type
63 struct _ib_device_type *
next;
66 typedef struct _ib_counter_type
72 struct _ib_counter_type *
next;
78 typedef struct _infiniband_native_event_entry
89 typedef struct _infiniband_control_state
99 typedef struct _infiniband_context
134 PAPIERROR(
"cannot allocate memory for event description");
137 len = strlen(input_str);
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)
155 PAPIERROR(
"cannot allocate memory for new IB device structure");
163 PAPIERROR(
"cannot allocate memory for device internal fields");
180 PAPIERROR(
"cannot allocate memory for new IB counter structure");
190 PAPIERROR(
"cannot allocate memory for counter internal fields");
208 char counters_path[128];
212 snprintf(counters_path,
sizeof(counters_path),
"%s/%s/ports/%d/counters%s",
215 cnt_dir = opendir(counters_path);
216 if (cnt_dir == NULL) {
219 SUBDBG(
"cannot open counters directory `%s'\n", counters_path);
221 snprintf(counters_path,
sizeof(counters_path),
"%s/%s/ports/%d/%scounters",
224 cnt_dir = opendir(counters_path);
228 snprintf(counters_path,
sizeof(counters_path),
"%s/%s/ports/%d/counters",
230 cnt_dir = opendir(counters_path);
233 if (cnt_dir == NULL) {
234 SUBDBG(
"cannot open counters directory `%s'\n", counters_path);
238 struct dirent *ev_ent;
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];
246 if (ev_name[0] ==
'.')
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);
257 snprintf(counter_name,
sizeof(counter_name),
"%s_%d%s:%s",
261 SUBDBG(
"Added new counter `%s'\n", counter_name);
281 if (ib_dir == NULL) {
289 struct dirent *hca_ent;
290 while ((hca_ent = readdir(ib_dir)) != NULL) {
291 char *hca = hca_ent->d_name;
293 DIR *ports_dir = NULL;
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);
305 struct dirent *port_ent;
306 while ((port_ent = readdir(ports_dir)) != NULL) {
307 int port =
atoi(port_ent->d_name);
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);
321 SUBDBG(
"skipping inactive IB HCA `%s', port %d, state %d\n", hca, port, state);
326 SUBDBG(
"Found IB device `%s', port %d\n", hca, port);
336 if (ports_dir != NULL)
388 char counters_path[128];
390 long long value = 0ll;
393 if (
iter->extended ) {
395 snprintf(counters_path,
sizeof(counters_path),
"%s/%s/ports/%d/counters%s",
398 cnt_dir = opendir(counters_path);
399 if (cnt_dir == NULL) {
402 snprintf(counters_path,
sizeof(counters_path),
"%s/%s/ports/%d/%scounters",
405 cnt_dir = opendir(counters_path);
409 snprintf(counters_path,
sizeof(counters_path),
"%s/%s/ports/%d/counters",
411 cnt_dir = opendir(counters_path);
419 snprintf(ev_file,
sizeof(ev_file),
"%s/%s",
420 counters_path,
iter->file_name);
422 if (pscanf(ev_file,
"%lld", &value) != 1) {
423 PAPIERROR(
"cannot read value for counter '%s'\n",
iter->name);
426 SUBDBG(
"Counter '%s': %lld\n",
iter->name, value);
453 free(
iter->dev_name);
566 if (temp < context->start_value[
i]) {
567 SUBDBG(
"Wraparound!\nstart:\t%#016x\ttemp:\t%#016x",
724 *EventCode = *EventCode + 1;
743 int index = EventCode;
758 int index = EventCode;
769 int index = EventCode;
776 if (len >
sizeof(info->
symbol)-1) len =
sizeof(info->
symbol)-1;
788 strncpy(info->
units,
"\0", 1);
803 .
name =
"infiniband",
804 .short_name =
"infiniband",
806 .description =
"Linux Infiniband statistics using the sysfs interface",
816 .fast_real_timer = 0,
817 .fast_virtual_timer = 0,
819 .attach_must_ptrace = 0,
static infiniband_native_event_entry_t * infiniband_native_events
char disabled_reason[PAPI_MAX_STR_LEN]
static void deallocate_infiniband_resources()
char units[PAPI_MIN_STR_LEN]
static long long read_ib_counter_value(int index)
infiniband_control_state_t state
static const char * ib_dir_path
infiniband_register_t resources
char long_descr[PAPI_HUGE_STR_LEN]
PAPI_component_info_t cmp_info
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)
static int _infiniband_start(hwd_context_t *ctx, hwd_control_state_t *ctl)
static int _infiniband_init_thread(hwd_context_t *ctx)
static long iter[MAX_THREADS]
static int _infiniband_reset(hwd_context_t *ctx, hwd_control_state_t *ctl)
static ib_device_t * root_device
static char * make_ib_event_description(const char *input_str, int extended)
static int _infiniband_shutdown_component(void)
static int _infiniband_shutdown_thread(hwd_context_t *ctx)
char symbol[PAPI_HUGE_STR_LEN]
static int _infiniband_init_component(int cidx)
#define SUBDBG(format, args...)
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)
char name[PAPI_MAX_STR_LEN]
static int _infiniband_stop(hwd_context_t *ctx, hwd_control_state_t *ctl)
struct _ib_counter_type * next
static int _infiniband_init_control_state(hwd_control_state_t *ctl)
long long counts[INFINIBAND_MAX_COUNTERS]
long long PAPI_get_real_usec(void)
static int find_ib_devices()
static ib_counter_t * root_counter
#define PAPI_NATIVE_AND_MASK
static ib_device_t * add_ib_device(const char *name, int port)
int being_measured[INFINIBAND_MAX_COUNTERS]
static int _infiniband_ntv_code_to_descr(unsigned int EventCode, char *name, int len)
struct _ib_device_type * next
int need_difference[INFINIBAND_MAX_COUNTERS]
static int _infiniband_set_domain(hwd_control_state_t *ctl, int domain)
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)
papi_vector_t _infiniband_vector
long long start_value[INFINIBAND_MAX_COUNTERS]
#define papi_calloc(a, b)
#define INFINIBAND_MAX_COUNTERS