io component This component provides access to the I/O statistics in the system file /proc/self/io. It typically contains 7 counters, but for robusness we read the file and create whatever events it contains.
More...
Go to the source code of this file.
|
| static int | io_count_events (_io_context_t *myCtx) |
| |
| static int | io_hardware_read (_io_context_t *ctx, _io_control_state_t *ctl) |
| |
| static int | _io_init_component (int cidx) |
| |
| static int | _io_init_thread (hwd_context_t *ctx) |
| |
| static int | _io_init_control_state (hwd_control_state_t *ctl) |
| |
| static int | _io_update_control_state (hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx) |
| |
| static int | _io_start (hwd_context_t *ctx, hwd_control_state_t *ctl) |
| |
| static int | _io_stop (hwd_context_t *ctx, hwd_control_state_t *ctl) |
| |
| static int | _io_read (hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags) |
| |
| static int | _io_write (hwd_context_t *ctx, hwd_control_state_t *ctl, long long *events) |
| |
| static int | _io_reset (hwd_context_t *ctx, hwd_control_state_t *ctl) |
| |
| static int | _io_shutdown_component (void) |
| |
| static int | _io_shutdown_thread (hwd_context_t *ctx) |
| |
| static int | _io_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option) |
| |
| static int | _io_set_domain (hwd_control_state_t *cntrl, int domain) |
| |
| static int | _io_ntv_enum_events (unsigned int *EventCode, int modifier) |
| |
| static int | _io_ntv_code_to_name (unsigned int EventCode, char *name, int len) |
| |
| static int | _io_ntv_code_to_descr (unsigned int EventCode, char *descr, int len) |
| |
◆ FILE_LINE_SIZE
| #define FILE_LINE_SIZE 256 |
◆ HANDLE_STRING_ERROR
| #define HANDLE_STRING_ERROR {fprintf(stderr,"%s:%i unexpected string function error.\n",__FILE__,__LINE__); exit(-1);} |
◆ IO_COUNTERS
◆ IO_FILENAME
| #define IO_FILENAME "/proc/self/io" |
◆ _io_ctl()
This function sets various options in the component
- Parameters
-
| [in] | ctx | – hardware context |
| [in] | code | valid are PAPI_SET_DEFDOM, PAPI_SET_DOMAIN, PAPI_SETDEFGRN, PAPI_SET_GRANUL and PAPI_SET_INHERIT |
| [in] | option | – options to be set |
Definition at line 431 of file linux-io.c.
432{
433 (void) ctx;
434 (void) code;
435 (void) option;
438}
#define SUBDBG(format, args...)
◆ _io_init_component()
| static int _io_init_component |
( |
int |
cidx | ) |
|
|
static |
Initialize hardware counters, setup the function vector table and get hardware information, this routine is called when the PAPI process is initialized (IE PAPI_library_init)
Definition at line 170 of file linux-io.c.
171{
173 int ret, fileIdx;
174 SUBDBG(
"_io_init_component..." );
175
179 "Failed counting events.");
182 goto fn_fail;
183 }
184
186
194 goto fn_fail;
195 }
196
197
199
210 goto fn_fail;
211 }
212
213 for (fileIdx = 0; fileIdx <
gEventCount; fileIdx++) {
216 long long tmplong = 0LL;
217
218 (void) sscanf(myCtx.
line,
"%s %lld\n",
name, &tmplong);
223 if (strcmp(
"rchar",
name) == 0) {
225 }
226 if (strcmp(
"wchar",
name) == 0) {
228 }
229 if (strcmp(
"syscr",
name) == 0) {
230 strcpy(
io_native_table[fileIdx].desc,
"Characters read by system calls.");
231 }
232 if (strcmp(
"syscw",
name) == 0) {
233 strcpy(
io_native_table[fileIdx].desc,
"Characters written by system calls.");
234 }
235 if (strcmp(
"read_bytes",
name) == 0) {
237 }
238 if (strcmp(
"write_bytes",
name) == 0) {
240 }
241 if (strcmp(
"cancelled_write_bytes",
name) == 0) {
242 strcpy(
io_native_table[fileIdx].desc,
"Binary write bytes cancelled.");
243 }
244
245
248 }
249 }
250
252
256
257
259 fn_exit:
261 return ret;
262 fn_fail:
263 goto fn_exit;
264}
struct papi_vectors * _papi_hwd[]
static IO_native_event_entry_t * io_native_table
static int io_count_events(_io_context_t *myCtx)
#define HANDLE_STRING_ERROR
int fclose(FILE *__stream)
#define papi_calloc(a, b)
char desc[PAPI_MAX_STR_LEN]
char disabled_reason[PAPI_HUGE_STR_LEN]
char line[FILE_LINE_SIZE]
PAPI_component_info_t cmp_info
◆ _io_init_control_state()
◆ _io_init_thread()
Definition at line 271 of file linux-io.c.
272{
274 int ret;
276 if (ret !=
PAPI_OK)
return(ret);
277
278
283 }
284
287}
◆ _io_ntv_code_to_descr()
| static int _io_ntv_code_to_descr |
( |
unsigned int |
EventCode, |
|
|
char * |
descr, |
|
|
int |
len |
|
) |
| |
|
static |
Takes a native event code and passes back the event description
- Parameters
-
| EventCode | is the native event code |
| descr | is a pointer for the description to be copied to |
| len | is the size of the descr string |
Definition at line 549 of file linux-io.c.
550{
551 int index;
552 index = EventCode;
553
554
558 }
559
561}
◆ _io_ntv_code_to_name()
| static int _io_ntv_code_to_name |
( |
unsigned int |
EventCode, |
|
|
char * |
name, |
|
|
int |
len |
|
) |
| |
|
static |
Takes a native event code and passes back the name
- Parameters
-
| EventCode | is the native event code |
| name | is a pointer for the name to be copied to |
| len | is the size of the name string |
Definition at line 529 of file linux-io.c.
530{
531 int index;
532 index = EventCode;
533
534
538 }
539
541}
◆ _io_ntv_enum_events()
| static int _io_ntv_enum_events |
( |
unsigned int * |
EventCode, |
|
|
int |
modifier |
|
) |
| |
|
static |
Enumerate Native Events
- Parameters
-
| EventCode | is the event of interest |
| modifier | is one of PAPI_ENUM_FIRST, PAPI_ENUM_EVENTS If your component has attribute masks then these need to be handled here as well. |
Definition at line 492 of file linux-io.c.
493{
494 int index;
495
496 switch ( modifier ) {
497
498
500 *EventCode = 0;
502
503
505 index = *EventCode;
506
507
509 *EventCode = *EventCode + 1;
511 } else {
513 }
514 break;
515
516 default:
518 }
519
521}
◆ _io_read()
Definition at line 358 of file linux-io.c.
360{
361
362 (void) flags;
366 SUBDBG(
"io_read... %p %d", ctx, flags );
367
368
372 }
373
374
376
378}
char events[MAX_EVENTS][BUFSIZ]
static int io_hardware_read(_io_context_t *ctx, _io_control_state_t *ctl)
long long EventSetReport[IO_COUNTERS]
int EventSetIdx[IO_COUNTERS]
long long EventSetVal[IO_COUNTERS]
◆ _io_reset()
Triggered by PAPI_reset() but only if the EventSet is currently running
Definition at line 399 of file linux-io.c.
400{
401 (void) ctx;
402 (void) ctl;
405}
◆ _io_set_domain()
This function has to set the bits needed to count different domains In particular: PAPI_DOM_USER, PAPI_DOM_KERNEL PAPI_DOM_OTHER By default return PAPI_EINVAL if none of those are specified and PAPI_OK with success PAPI_DOM_USER is only user context is counted PAPI_DOM_KERNEL is only the Kernel/OS context is counted PAPI_DOM_OTHER is Exception/transient mode (like user TLB misses) PAPI_DOM_ALL is all of the domains
Definition at line 450 of file linux-io.c.
451{
452 (void) cntrl;
453
454 int found = 0;
455 SUBDBG(
"io_set_domain..." );
456
458 SUBDBG(
" PAPI_DOM_USER " );
459 found = 1;
460 }
462 SUBDBG(
" PAPI_DOM_KERNEL " );
463 found = 1;
464 }
466 SUBDBG(
" PAPI_DOM_OTHER " );
467 found = 1;
468 }
470 SUBDBG(
" PAPI_DOM_ALL " );
471 found = 1;
472 }
473 if ( !found )
475
477}
◆ _io_shutdown_component()
| static int _io_shutdown_component |
( |
void |
| ) |
|
|
static |
◆ _io_shutdown_thread()
Definition at line 417 of file linux-io.c.
418{
419 (void) ctx;
420 SUBDBG(
"io_shutdown_thread... %p", ctx );
422}
◆ _io_start()
Triggered by PAPI_start()
Definition at line 332 of file linux-io.c.
333{
334 (void) ctl;
335 (void) ctx;
336 SUBDBG(
"io_start %p %p...", ctx, ctl );
338}
◆ _io_stop()
Triggered by PAPI_stop()
Definition at line 343 of file linux-io.c.
344{
345 (void) ctx;
346 (void) ctl;
347 SUBDBG(
"io_stop %p %p...", ctx, ctl );
348
349
351}
◆ _io_update_control_state()
Definition at line 303 of file linux-io.c.
307{
308 (void) ctx;
310
312
314
315
317
321
322
323
325 }
326
328}
◆ _io_write()
Triggered by PAPI_write(), but only if the counters are running
Definition at line 383 of file linux-io.c.
385{
386 (void) ctx;
387 (void) ctl;
389
391}
◆ io_count_events()
Definition at line 82 of file linux-io.c.
83{
86 if (myCtx->
pFile == NULL) {
92 }
93
94
95 while (1) {
96 char *res;
97
99 if (res == NULL) break;
100
108 }
109
111 long long tmplong = 0LL;
112 int nf = sscanf( myCtx->
line,
"%s %lld\n",
dummy, &tmplong);
120 }
121
123 }
124
125
126
128}
◆ io_hardware_read()
Definition at line 135 of file linux-io.c.
136{
139
140
141 int idx;
145 long long tmplong = 0LL;
146 int nf = sscanf(ctx->
line,
"%s %lld\n",
dummy, &tmplong);
149 }
150
152 } else {
154 }
155 }
156
159}
◆ _io_vector
Vector that points to entry points for our component
Definition at line 28 of file linux-io.c.
◆ gEventCount
◆ io_native_table