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...
Go to the source code of this file.
|
| static char * | make_ib_event_description (const char *input_str, int extended) |
| |
| static ib_device_t * | add_ib_device (const char *name, int port) |
| |
| static ib_counter_t * | add_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 () |
| |
| static int | _infiniband_init_thread (hwd_context_t *ctx) |
| |
| static int | _infiniband_init_component (int cidx) |
| |
| static int | _infiniband_init_control_state (hwd_control_state_t *ctl) |
| |
| static int | _infiniband_start (hwd_context_t *ctx, hwd_control_state_t *ctl) |
| |
| static int | _infiniband_stop (hwd_context_t *ctx, hwd_control_state_t *ctl) |
| |
| static int | _infiniband_read (hwd_context_t *ctx, hwd_control_state_t *ctl, long_long **events, int flags) |
| |
| static int | _infiniband_shutdown_component (void) |
| |
| static int | _infiniband_shutdown_thread (hwd_context_t *ctx) |
| |
| 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) |
| |
| static int | _infiniband_set_domain (hwd_control_state_t *ctl, int domain) |
| |
| static int | _infiniband_reset (hwd_context_t *ctx, hwd_control_state_t *ctl) |
| |
| static int | _infiniband_ntv_enum_events (unsigned int *EventCode, int modifier) |
| |
| static int | _infiniband_ntv_code_to_name (unsigned int EventCode, char *name, int len) |
| |
| static int | _infiniband_ntv_code_to_descr (unsigned int EventCode, char *name, int len) |
| |
| static int | _infiniband_ntv_code_to_info (unsigned int EventCode, PAPI_event_info_t *info) |
| |
◆ INFINIBAND_MAX_COUNTERS
| #define INFINIBAND_MAX_COUNTERS 128 |
◆ _infiniband_ctl()
◆ _infiniband_init_component()
| static int _infiniband_init_component |
( |
int |
cidx | ) |
|
|
static |
Definition at line 482 of file linux-infiniband.c.
static void deallocate_infiniband_resources()
PAPI_component_info_t cmp_info
static int find_ib_devices()
papi_vector_t _infiniband_vector
◆ _infiniband_init_control_state()
Definition at line 511 of file linux-infiniband.c.
int being_measured[INFINIBAND_MAX_COUNTERS]
#define INFINIBAND_MAX_COUNTERS
◆ _infiniband_init_thread()
◆ _infiniband_ntv_code_to_descr()
| static int _infiniband_ntv_code_to_descr |
( |
unsigned int |
EventCode, |
|
|
char * |
name, |
|
|
int |
len |
|
) |
| |
|
static |
Definition at line 756 of file linux-infiniband.c.
758 int index = EventCode;
static infiniband_native_event_entry_t * infiniband_native_events
◆ _infiniband_ntv_code_to_info()
| static int _infiniband_ntv_code_to_info |
( |
unsigned int |
EventCode, |
|
|
PAPI_event_info_t * |
info |
|
) |
| |
|
static |
Definition at line 767 of file linux-infiniband.c.
769 int index = EventCode;
776 if (len >
sizeof(info->
symbol)-1) len =
sizeof(info->
symbol)-1;
788 strncpy(info->
units,
"\0", 1);
static infiniband_native_event_entry_t * infiniband_native_events
char units[PAPI_MIN_STR_LEN]
char long_descr[PAPI_HUGE_STR_LEN]
char symbol[PAPI_HUGE_STR_LEN]
◆ _infiniband_ntv_code_to_name()
| static int _infiniband_ntv_code_to_name |
( |
unsigned int |
EventCode, |
|
|
char * |
name, |
|
|
int |
len |
|
) |
| |
|
static |
Definition at line 741 of file linux-infiniband.c.
743 int index = EventCode;
static infiniband_native_event_entry_t * infiniband_native_events
◆ _infiniband_ntv_enum_events()
| static int _infiniband_ntv_enum_events |
( |
unsigned int * |
EventCode, |
|
|
int |
modifier |
|
) |
| |
|
static |
Definition at line 709 of file linux-infiniband.c.
724 *EventCode = *EventCode + 1;
#define PAPI_NATIVE_AND_MASK
◆ _infiniband_read()
Definition at line 589 of file linux-infiniband.c.
char events[MAX_EVENTS][BUFSIZ]
static int _infiniband_stop(hwd_context_t *ctx, hwd_control_state_t *ctl)
◆ _infiniband_reset()
◆ _infiniband_set_domain()
◆ _infiniband_shutdown_component()
| static int _infiniband_shutdown_component |
( |
void |
| ) |
|
|
static |
◆ _infiniband_shutdown_thread()
◆ _infiniband_start()
Definition at line 527 of file linux-infiniband.c.
static long long read_ib_counter_value(int index)
long long PAPI_get_real_usec(void)
int being_measured[INFINIBAND_MAX_COUNTERS]
int need_difference[INFINIBAND_MAX_COUNTERS]
long long start_value[INFINIBAND_MAX_COUNTERS]
#define INFINIBAND_MAX_COUNTERS
◆ _infiniband_stop()
Definition at line 549 of file linux-infiniband.c.
566 if (temp < context->start_value[
i]) {
567 SUBDBG(
"Wraparound!\nstart:\t%#016x\ttemp:\t%#016x",
static long long read_ib_counter_value(int index)
#define SUBDBG(format, args...)
long long counts[INFINIBAND_MAX_COUNTERS]
long long PAPI_get_real_usec(void)
int being_measured[INFINIBAND_MAX_COUNTERS]
int need_difference[INFINIBAND_MAX_COUNTERS]
long long start_value[INFINIBAND_MAX_COUNTERS]
#define INFINIBAND_MAX_COUNTERS
◆ _infiniband_update_control_state()
Definition at line 636 of file linux-infiniband.c.
static infiniband_native_event_entry_t * infiniband_native_events
infiniband_register_t resources
#define PAPI_NATIVE_AND_MASK
int being_measured[INFINIBAND_MAX_COUNTERS]
int need_difference[INFINIBAND_MAX_COUNTERS]
#define INFINIBAND_MAX_COUNTERS
◆ add_ib_counter()
| static ib_counter_t* add_ib_counter |
( |
const char * |
name, |
|
|
const char * |
file_name, |
|
|
int |
extended, |
|
|
ib_device_t * |
device |
|
) |
| |
|
static |
Definition at line 176 of file linux-infiniband.c.
180 PAPIERROR(
"cannot allocate memory for new IB counter structure");
190 PAPIERROR(
"cannot allocate memory for counter internal fields");
void PAPIERROR(char *format,...)
struct _ib_counter_type * next
static ib_counter_t * root_counter
#define papi_calloc(a, b)
◆ add_ib_device()
| static ib_device_t* add_ib_device |
( |
const char * |
name, |
|
|
int |
port |
|
) |
| |
|
static |
Definition at line 151 of file linux-infiniband.c.
155 PAPIERROR(
"cannot allocate memory for new IB device structure");
163 PAPIERROR(
"cannot allocate memory for device internal fields");
static ib_device_t * root_device
void PAPIERROR(char *format,...)
struct _ib_device_type * next
#define papi_calloc(a, b)
◆ deallocate_infiniband_resources()
| static void deallocate_infiniband_resources |
( |
| ) |
|
|
static |
Definition at line 432 of file linux-infiniband.c.
453 free(
iter->dev_name);
static infiniband_native_event_entry_t * infiniband_native_events
static long iter[MAX_THREADS]
static ib_device_t * root_device
◆ find_ib_device_events()
| static int find_ib_device_events |
( |
ib_device_t * |
dev, |
|
|
int |
extended |
|
) |
| |
|
static |
Definition at line 204 of file linux-infiniband.c.
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);
static const char * ib_dir_path
static ib_counter_t * add_ib_counter(const char *name, const char *file_name, int extended, ib_device_t *device)
#define SUBDBG(format, args...)
◆ find_ib_devices()
| static int find_ib_devices |
( |
| ) |
|
|
static |
Definition at line 274 of file linux-infiniband.c.
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)
static infiniband_native_event_entry_t * infiniband_native_events
char disabled_reason[PAPI_MAX_STR_LEN]
static const char * ib_dir_path
infiniband_register_t resources
PAPI_component_info_t cmp_info
static int find_ib_device_events(ib_device_t *dev, int extended)
static long iter[MAX_THREADS]
static ib_device_t * root_device
static char * make_ib_event_description(const char *input_str, int extended)
#define SUBDBG(format, args...)
static ib_counter_t * root_counter
static ib_device_t * add_ib_device(const char *name, int port)
papi_vector_t _infiniband_vector
#define papi_calloc(a, b)
◆ make_ib_event_description()
| static char* make_ib_event_description |
( |
const char * |
input_str, |
|
|
int |
extended |
|
) |
| |
|
static |
Definition at line 125 of file linux-infiniband.c.
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)
void PAPIERROR(char *format,...)
#define papi_calloc(a, b)
◆ read_ib_counter_value()
| static long long read_ib_counter_value |
( |
int |
index | ) |
|
|
static |
Definition at line 385 of file linux-infiniband.c.
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);
static infiniband_native_event_entry_t * infiniband_native_events
static const char * ib_dir_path
static long iter[MAX_THREADS]
#define SUBDBG(format, args...)
void PAPIERROR(char *format,...)
◆ _infiniband_vector
◆ ib_dir_path
| const char* ib_dir_path = "/sys/class/infiniband" |
|
static |
◆ infiniband_native_events
◆ num_events
◆ root_counter
◆ root_device