PAPI 7.1.0.0
Loading...
Searching...
No Matches
appio.c
Go to the documentation of this file.
1/****************************/
2/* THIS IS OPEN SOURCE CODE */
3/****************************/
4
29#include <stdlib.h>
30#include <ctype.h>
31#include <string.h>
32#include <errno.h>
33#include <sys/select.h>
34#include <sys/types.h>
35#include <unistd.h>
36#include <sys/stat.h>
37
38/* Headers required by PAPI */
39#include "papi.h"
40#include "papi_internal.h"
41#include "papi_vector.h"
42#include "papi_memory.h"
43
44#include "appio.h"
45
46// The PIC test implies it's built for shared linkage
47#ifdef PIC
48# include "dlfcn.h"
49#endif
50
51/*
52#pragma weak dlerror
53static void *_dlsym_fake(void *handle, const char* symbol) { (void) handle; (void) symbol; return NULL; }
54void *dlsym(void *handle, const char* symbol) __attribute__ ((weak, alias ("_dlsym_fake")));
55*/
56
58
59/*********************************************************************
60 * Private
61 ********************************************************************/
62
63//#define APPIO_FOO 1
64
66
67
68/* If you modify the appio_stats_t below, you MUST update APPIO_MAX_COUNTERS */
70typedef enum {
117
118static const struct appio_counters {
119 const char *name;
120 const char *description;
122 { "READ_BYTES", "Bytes read"},
123 { "READ_CALLS", "Number of read calls"},
124 { "READ_ERR", "Number of read calls that resulted in an error"},
125 { "READ_INTERRUPTED","Number of read calls that timed out or were interruped"},
126 { "READ_WOULD_BLOCK","Number of read calls that would have blocked"},
127 { "READ_SHORT", "Number of read calls that returned less bytes than requested"},
128 { "READ_EOF", "Number of read calls that returned an EOF"},
129 { "READ_BLOCK_SIZE", "Average block size of reads"},
130 { "READ_USEC", "Real microseconds spent in reads"},
131 { "WRITE_BYTES", "Bytes written"},
132 { "WRITE_CALLS", "Number of write calls"},
133 { "WRITE_ERR", "Number of write calls that resulted in an error"},
134 { "WRITE_SHORT", "Number of write calls that wrote less bytes than requested"},
135 { "WRITE_INTERRUPTED","Number of write calls that timed out or were interrupted"},
136 { "WRITE_WOULD_BLOCK","Number of write calls that would have blocked"},
137 { "WRITE_BLOCK_SIZE","Mean block size of writes"},
138 { "WRITE_USEC", "Real microseconds spent in writes"},
139 { "OPEN_CALLS", "Number of open calls"},
140 { "OPEN_ERR", "Number of open calls that resulted in an error"},
141 { "OPEN_FDS", "Number of currently open descriptors"},
142 { "SELECT_USEC", "Real microseconds spent in select calls"},
143 { "RECV_BYTES", "Bytes read in recv/recvmsg/recvfrom"},
144 { "RECV_CALLS", "Number of recv/recvmsg/recvfrom calls"},
145 { "RECV_ERR", "Number of recv/recvmsg/recvfrom calls that resulted in an error"},
146 { "RECV_INTERRUPTED","Number of recv/recvmsg/recvfrom calls that timed out or were interruped"},
147 { "RECV_WOULD_BLOCK","Number of recv/recvmsg/recvfrom calls that would have blocked"},
148 { "RECV_SHORT", "Number of recv/recvmsg/recvfrom calls that returned less bytes than requested"},
149 { "RECV_EOF", "Number of recv/recvmsg/recvfrom calls that returned an EOF"},
150 { "RECV_BLOCK_SIZE", "Average block size of recv/recvmsg/recvfrom"},
151 { "RECV_USEC", "Real microseconds spent in recv/recvmsg/recvfrom"},
152 { "SOCK_READ_BYTES", "Bytes read from socket"},
153 { "SOCK_READ_CALLS", "Number of read calls on socket"},
154 { "SOCK_READ_ERR", "Number of read calls on socket that resulted in an error"},
155 { "SOCK_READ_SHORT", "Number of read calls on socket that returned less bytes than requested"},
156 { "SOCK_READ_WOULD_BLOCK", "Number of read calls on socket that would have blocked"},
157 { "SOCK_READ_USEC", "Real microseconds spent in read(s) on socket(s)"},
158 { "SOCK_WRITE_BYTES","Bytes written to socket"},
159 { "SOCK_WRITE_CALLS","Number of write calls to socket"},
160 { "SOCK_WRITE_ERR", "Number of write calls to socket that resulted in an error"},
161 { "SOCK_WRITE_SHORT","Number of write calls to socket that wrote less bytes than requested"},
162 { "SOCK_WRITE_WOULD_BLOCK","Number of write calls to socket that would have blocked"},
163 { "SOCK_WRITE_USEC", "Real microseconds spent in write(s) to socket(s)"},
164 { "SEEK_CALLS", "Number of seek calls"},
165 { "SEEK_ABS_STRIDE_SIZE", "Average absolute stride size of seeks"},
166 { "SEEK_USEC", "Real microseconds spent in seek calls"}
168
169// The following macro follows if a string function has an error. It should
170// never happen; but it is necessary to prevent compiler warnings. We print
171// something just in case there is programmer error in invoking the function.
172#define HANDLE_STRING_ERROR {fprintf(stderr,"%s:%i unexpected string function error.\n",__FILE__,__LINE__); exit(-1);}
173
174/*********************************************************************
175 *** BEGIN FUNCTIONS USED INTERNALLY SPECIFIC TO THIS COMPONENT ****
176 ********************************************************************/
177
178int __close(int fd);
179int close(int fd) {
180 int retval;
181 SUBDBG("appio: intercepted close(%d)\n", fd);
182 retval = __close(fd);
184 return retval;
185}
186
187int __open(const char *pathname, int flags, mode_t mode);
188int open(const char *pathname, int flags, mode_t mode) {
189 int retval;
190 SUBDBG("appio: intercepted open(%s,%d,%d)\n", pathname, flags, mode);
191 retval = __open(pathname,flags,mode);
195 return retval;
196}
197
198/* we use timeval as a zero value timeout to select in read/write
199 for polling if the operation would block */
200struct timeval zerotv; /* this has to be zero, so define it here */
201
202int __select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
203int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) {
204 int retval;
205 SUBDBG("appio: intercepted select(%d,%p,%p,%p,%p)\n", nfds,readfds,writefds,exceptfds,timeout);
206 long long start_ts = PAPI_get_real_usec();
207 retval = __select(nfds,readfds,writefds,exceptfds,timeout);
208 long long duration = PAPI_get_real_usec() - start_ts;
210 return retval;
211}
212
213off_t __lseek(int fd, off_t offset, int whence);
214off_t lseek(int fd, off_t offset, int whence) {
216 SUBDBG("appio: intercepted lseek(%d,%ld,%d)\n", fd, offset, whence);
217 long long start_ts = PAPI_get_real_usec();
218 retval = __lseek(fd, offset, whence);
219 long long duration = PAPI_get_real_usec() - start_ts;
222 if (offset < 0) offset = -offset; // get abs offset
223 _appio_register_current[SEEK_ABS_STRIDE_SIZE]= (n * _appio_register_current[SEEK_ABS_STRIDE_SIZE] + offset)/(n+1); // mean absolute stride size
224 return retval;
225}
226
227extern int errno;
228ssize_t __read(int fd, void *buf, size_t count);
229ssize_t read(int fd, void *buf, size_t count) {
230 int retval;
231 SUBDBG("appio: intercepted read(%d,%p,%lu)\n", fd, buf, (unsigned long)count);
232
233 struct stat st;
234 int issocket = 0;
235 if (fstat(fd, &st) == 0) {
236 if ((st.st_mode & S_IFMT) == S_IFSOCK) issocket = 1;
237 }
238 // check if read would block on descriptor
239 fd_set readfds;
240 FD_ZERO(&readfds);
241 FD_SET(fd, &readfds);
242 int ready = __select(fd+1, &readfds, NULL, NULL, &zerotv);
243 if (ready == 0) {
246 }
247
248 long long start_ts = PAPI_get_real_usec();
249 retval = __read(fd,buf, count);
250 long long duration = PAPI_get_real_usec() - start_ts;
251 int n = _appio_register_current[READ_CALLS]++; // read calls
252 if (issocket) _appio_register_current[SOCK_READ_CALLS]++; // read calls
253 if (retval > 0) {
255 _appio_register_current[READ_BYTES] += retval; // read bytes
257 if (retval < (int)count) {
258 _appio_register_current[READ_SHORT]++; // read short
259 if (issocket) _appio_register_current[SOCK_READ_SHORT]++; // read short
260 }
262 if (issocket) _appio_register_current[SOCK_READ_USEC] += duration;
263 }
264 if (retval < 0) {
265 _appio_register_current[READ_ERR]++; // read err
266 if (issocket) _appio_register_current[SOCK_READ_ERR]++; // read err
267 if (EINTR == errno)
268 _appio_register_current[READ_INTERRUPTED]++; // signal interrupted the read
269 //if ((EAGAIN == errno) || (EWOULDBLOCK == errno)) {
270 // _appio_register_current[READ_WOULD_BLOCK]++; //read would block on descriptor marked as non-blocking
271 // if (issocket) _appio_register_current[SOCK_READ_WOULD_BLOCK]++; //read would block on descriptor marked as non-blocking
272 //}
273 }
274 if (retval == 0) _appio_register_current[READ_EOF]++; // read eof
275 return retval;
276}
277
278size_t _IO_fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
279size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) {
280 size_t retval;
281 SUBDBG("appio: intercepted fread(%p,%lu,%lu,%p)\n", ptr, (unsigned long) size, (unsigned long) nmemb, (void*) stream);
282 long long start_ts = PAPI_get_real_usec();
283 retval = _IO_fread(ptr,size,nmemb,stream);
284 long long duration = PAPI_get_real_usec() - start_ts;
285 int n = _appio_register_current[READ_CALLS]++; // read calls
286 if (retval > 0) {
288 _appio_register_current[READ_BYTES]+= retval * size; // read bytes
289 if (retval < nmemb) _appio_register_current[READ_SHORT]++; // read short
291 }
292
293 /* A value of zero returned means one of two things..*/
294 if (retval == 0) {
295 if (feof(stream)) _appio_register_current[READ_EOF]++; // read eof
296 else _appio_register_current[READ_ERR]++; // read err
297 }
298 return retval;
299}
300
301ssize_t __write(int fd, const void *buf, size_t count);
302ssize_t write(int fd, const void *buf, size_t count) {
303 int retval;
304 SUBDBG("appio: intercepted write(%d,%p,%lu)\n", fd, buf, (unsigned long)count);
305 struct stat st;
306 int issocket = 0;
307 if (fstat(fd, &st) == 0) {
308 if ((st.st_mode & S_IFMT) == S_IFSOCK) issocket = 1;
309 }
310
311 // check if write would block on descriptor
312 fd_set writefds;
313 FD_ZERO(&writefds);
314 FD_SET(fd, &writefds);
315 int ready = __select(fd+1, NULL, &writefds, NULL, &zerotv);
316 if (ready == 0) {
319 }
320
321 long long start_ts = PAPI_get_real_usec();
322 retval = __write(fd,buf, count);
323 long long duration = PAPI_get_real_usec() - start_ts;
324 int n = _appio_register_current[WRITE_CALLS]++; // write calls
325 if (issocket) _appio_register_current[SOCK_WRITE_CALLS]++; // socket write
326 if (retval >= 0) {
330 if (retval < (int)count) {
331 _appio_register_current[WRITE_SHORT]++; // short write
333 }
335 if (issocket) _appio_register_current[SOCK_WRITE_USEC] += duration;
336 }
337 if (retval < 0) {
340 if (EINTR == errno)
341 _appio_register_current[WRITE_INTERRUPTED]++; // signal interrupted the op
342 //if ((EAGAIN == errno) || (EWOULDBLOCK == errno)) {
343 // _appio_register_current[WRITE_WOULD_BLOCK]++; //op would block on descriptor marked as non-blocking
344 // if (issocket) _appio_register_current[SOCK_WRITE_WOULD_BLOCK]++;
345 //}
346 }
347 return retval;
348}
349
350// The PIC test implies it's built for shared linkage
351#ifdef PIC
352static ssize_t (*__recv)(int sockfd, void *buf, size_t len, int flags) = NULL;
353ssize_t recv(int sockfd, void *buf, size_t len, int flags) {
354 int retval;
355 SUBDBG("appio: intercepted recv(%d,%p,%lu,%d)\n", sockfd, buf, (unsigned long)len, flags);
356 if (!__recv) __recv = dlsym(RTLD_NEXT, "recv");
357 if (!__recv) {
358 fprintf(stderr, "appio,c Internal Error: Could not obtain handle for real recv\n");
359 exit(1);
360 }
361 // check if recv would block on descriptor
362 fd_set readfds;
363 FD_ZERO(&readfds);
364 FD_SET(sockfd, &readfds);
365 int ready = __select(sockfd+1, &readfds, NULL, NULL, &zerotv);
366 if (ready == 0) _appio_register_current[RECV_WOULD_BLOCK]++;
367
368 long long start_ts = PAPI_get_real_usec();
369 retval = __recv(sockfd, buf, len, flags);
370 long long duration = PAPI_get_real_usec() - start_ts;
371 int n = _appio_register_current[RECV_CALLS]++; // read calls
372 if (retval > 0) {
374 _appio_register_current[RECV_BYTES] += retval; // read bytes
375 if (retval < (int)len) _appio_register_current[RECV_SHORT]++; // read short
377 }
378 if (retval < 0) {
379 _appio_register_current[RECV_ERR]++; // read err
380 if (EINTR == errno)
381 _appio_register_current[RECV_INTERRUPTED]++; // signal interrupted the read
382 if ((EAGAIN == errno) || (EWOULDBLOCK == errno))
383 _appio_register_current[RECV_WOULD_BLOCK]++; //read would block on descriptor marked as non-blocking
384 }
385 if (retval == 0) _appio_register_current[RECV_EOF]++; // read eof
386 return retval;
387}
388#endif /* PIC */
389
390size_t _IO_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
391size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) {
392 size_t retval;
393 SUBDBG("appio: intercepted fwrite(%p,%lu,%lu,%p)\n", ptr, (unsigned long) size, (unsigned long) nmemb, (void*) stream);
394 long long start_ts = PAPI_get_real_usec();
395 retval = _IO_fwrite(ptr,size,nmemb,stream);
396 long long duration = PAPI_get_real_usec() - start_ts;
397 int n = _appio_register_current[WRITE_CALLS]++; // write calls
398 if (retval > 0) {
399 _appio_register_current[WRITE_BLOCK_SIZE]= (n * _appio_register_current[WRITE_BLOCK_SIZE] + size*nmemb)/(n+1); // mean block size
400 _appio_register_current[WRITE_BYTES]+= retval * size; // write bytes
401 if (retval < nmemb) _appio_register_current[WRITE_SHORT]++; // short write
403 }
404 if (retval == 0) _appio_register_current[WRITE_ERR]++; // err
405 return retval;
406}
407
408
409/*********************************************************************
410 *************** BEGIN PAPI's COMPONENT REQUIRED FUNCTIONS *********
411 *********************************************************************/
412
413/*
414 * This is called whenever a thread is initialized
415 */
416static int
418{
419 ( void ) ctx;
420 SUBDBG("_appio_init_thread %p\n", ctx);
421 return PAPI_OK;
422}
423
424
425/* Initialize hardware counters, setup the function vector table
426 * and get hardware information, this routine is called when the
427 * PAPI process is initialized (IE PAPI_library_init)
428 */
429
430static int
432{
433 int strErr;
434 int retval = PAPI_OK;
435 SUBDBG("_appio_component %d\n", cidx);
437
438 if (_appio_native_events == NULL ) {
439 PAPIERROR( "malloc():Could not get memory for events table" );
440 strErr=snprintf(_appio_vector.cmp_info.disabled_reason, PAPI_MAX_STR_LEN, "malloc() failed in %s for %lu bytes.", __func__, APPIO_MAX_COUNTERS*sizeof(APPIO_native_event_entry_t));
444 goto fn_fail;
445 }
446 int i;
447 for (i=0; i<APPIO_MAX_COUNTERS; i++) {
451 }
452
453 /* Export the total number of events available */
455
456 /* Export the component id */
458
459 fn_exit:
460 _papi_hwd[cidx]->cmp_info.disabled = retval;
461 return retval;
462 fn_fail:
463 goto fn_exit;
464}
465
466
467/*
468 * Control of counters (Reading/Writing/Starting/Stopping/Setup)
469 * functions
470 */
471static int
473{
474 ( void ) ctl;
475
476 return PAPI_OK;
477}
478
479
480static int
482{
483 ( void ) ctx;
484
485 SUBDBG("_appio_start %p %p\n", ctx, ctl);
486 APPIO_control_state_t *appio_ctl = (APPIO_control_state_t *) ctl;
487
488 /* this memset needs to move to thread_init */
490
491 /* set initial values to 0 */
492 memset(appio_ctl->values, 0, APPIO_MAX_COUNTERS*sizeof(appio_ctl->values[0]));
493
494 return PAPI_OK;
495}
496
497
498static int
500 long long ** events, int flags )
501{
502 (void) flags;
503 (void) ctx;
504
505 SUBDBG("_appio_read %p %p\n", ctx, ctl);
506 APPIO_control_state_t *appio_ctl = (APPIO_control_state_t *) ctl;
507 int i;
508
509 for ( i=0; i<appio_ctl->num_events; i++ ) {
510 int index = appio_ctl->counter_bits[i];
511 SUBDBG("event=%d, index=%d, val=%lld\n", i, index, _appio_register_current[index]);
512 appio_ctl->values[index] = _appio_register_current[index];
513 }
514 *events = appio_ctl->values;
515
516 return PAPI_OK;
517}
518
519
520static int
522{
523 (void) ctx;
524
525 SUBDBG("_appio_stop ctx=%p ctl=%p\n", ctx, ctl);
526 APPIO_control_state_t *appio_ctl = (APPIO_control_state_t *) ctl;
527 int i;
528 for ( i=0; i<appio_ctl->num_events; i++ ) {
529 int index = appio_ctl->counter_bits[i];
530 SUBDBG("event=%d, index=%d, val=%lld\n", i, index, _appio_register_current[index]);
531 appio_ctl->values[i] = _appio_register_current[index];
532 }
533
534 return PAPI_OK;
535}
536
537
538/*
539 * Thread shutdown
540 */
541static int
543{
544 ( void ) ctx;
545
546 return PAPI_OK;
547}
548
549
550/*
551 * Clean up what was setup in appio_init_component().
552 */
553static int
555{
557 return PAPI_OK;
558}
559
560
561/* This function sets various options in the component
562 * The valid codes being passed in are PAPI_SET_DEFDOM,
563 * PAPI_SET_DOMAIN, PAPI_SETDEFGRN, PAPI_SET_GRANUL and
564 * PAPI_SET_INHERIT
565 */
566static int
568{
569 ( void ) ctx;
570 ( void ) code;
571 ( void ) option;
572
573 return PAPI_OK;
574}
575
576
577static int
580{
581 ( void ) ctx;
582 ( void ) ctl;
583
584 SUBDBG("_appio_update_control_state ctx=%p ctl=%p num_events=%d\n", ctx, ctl, count);
585 int i, index;
586 APPIO_control_state_t *appio_ctl = (APPIO_control_state_t *) ctl;
587 (void) ctx;
588
589 for ( i = 0; i < count; i++ ) {
590 index = native[i].ni_event;
591 appio_ctl->counter_bits[i] = index;
592 native[i].ni_position = index;
593 }
594 appio_ctl->num_events = count;
595
596 return PAPI_OK;
597}
598
599
600/*
601 * This function has to set the bits needed to count different domains
602 * In particular: PAPI_DOM_USER, PAPI_DOM_KERNEL PAPI_DOM_OTHER
603 * By default return PAPI_EINVAL if none of those are specified
604 * and PAPI_OK with success
605 * PAPI_DOM_USER is only user context is counted
606 * PAPI_DOM_KERNEL is only the Kernel/OS context is counted
607 * PAPI_DOM_OTHER is Exception/transient mode (like user TLB misses)
608 * PAPI_DOM_ALL is all of the domains
609 */
610static int
612{
613 ( void ) ctl;
614
615 int found = 0;
616
617 if ( PAPI_DOM_USER == domain ) found = 1;
618
619 if ( !found )
620 return PAPI_EINVAL;
621
622 return PAPI_OK;
623}
624
625
626static int
628{
629 ( void ) ctx;
630 ( void ) ctl;
631
632 return PAPI_OK;
633}
634
635
636/*
637 * Native Event functions
638 */
639static int
640_appio_ntv_enum_events( unsigned int *EventCode, int modifier )
641{
642 int index;
643
644 switch ( modifier ) {
645 case PAPI_ENUM_FIRST:
646 *EventCode = 0;
647 return PAPI_OK;
648 break;
649
650 case PAPI_ENUM_EVENTS:
651 index = *EventCode;
652 if ( index < APPIO_MAX_COUNTERS - 1 ) {
653 *EventCode = *EventCode + 1;
654 return PAPI_OK;
655 } else {
656 return PAPI_ENOEVNT;
657 }
658 break;
659
660 default:
661 return PAPI_EINVAL;
662 break;
663 }
664 return PAPI_EINVAL;
665}
666
667
668/*
669 *
670 */
671static int
672_appio_ntv_name_to_code( const char *name, unsigned int *EventCode )
673{
674 int i;
675
676 for ( i=0; i<APPIO_MAX_COUNTERS; i++) {
677 if (strcmp(name, _appio_counter_info[i].name) == 0) {
678 *EventCode = i;
679 return PAPI_OK;
680 }
681 }
682
683 return PAPI_ENOEVNT;
684}
685
686
687/*
688 *
689 */
690static int
691_appio_ntv_code_to_name( unsigned int EventCode, char *name, int len )
692{
693 int index = EventCode;
694
695 if ( index >= 0 && index < APPIO_MAX_COUNTERS ) {
696 strncpy( name, _appio_counter_info[index].name, len );
697 return PAPI_OK;
698 }
699
700 return PAPI_ENOEVNT;
701}
702
703
704/*
705 *
706 */
707static int
708_appio_ntv_code_to_descr( unsigned int EventCode, char *desc, int len )
709{
710 int index = EventCode;
711
712 if ( index >= 0 && index < APPIO_MAX_COUNTERS ) {
713 strncpy(desc, _appio_counter_info[index].description, len );
714 return PAPI_OK;
715 }
716
717 return PAPI_ENOEVNT;
718}
719
720
721/*
722 *
723 */
724static int
725_appio_ntv_code_to_bits( unsigned int EventCode, hwd_register_t *bits )
726{
727 int index = EventCode;
728
729 if ( index >= 0 && index < APPIO_MAX_COUNTERS ) {
730 memcpy( ( APPIO_register_t * ) bits,
731 &( _appio_native_events[index].resources ),
732 sizeof ( APPIO_register_t ) );
733 return PAPI_OK;
734 }
735
736 return PAPI_ENOEVNT;
737}
738
739
740/*
741 *
742 */
744 .cmp_info = {
745 /* default component information (unspecified values are initialized to 0) */
746 .name = "appio",
747 .short_name = "appio",
748 .version = "1.1.2.4",
749 .CmpIdx = 0, /* set by init_component */
750 .num_mpx_cntrs = APPIO_MAX_COUNTERS,
751 .num_cntrs = APPIO_MAX_COUNTERS,
752 .default_domain = PAPI_DOM_USER,
753 .available_domains = PAPI_DOM_USER,
754 .default_granularity = PAPI_GRN_THR,
755 .available_granularities = PAPI_GRN_THR,
756 .hardware_intr_sig = PAPI_INT_SIGNAL,
757
758 /* component specific cmp_info initializations */
759 .fast_real_timer = 0,
760 .fast_virtual_timer = 0,
761 .attach = 0,
762 .attach_must_ptrace = 0,
763 },
764
765 /* sizes of framework-opaque component-private structures */
766 .size = {
767 .context = sizeof ( APPIO_context_t ),
768 .control_state = sizeof ( APPIO_control_state_t ),
769 .reg_value = sizeof ( APPIO_register_t ),
770 .reg_alloc = sizeof ( APPIO_reg_alloc_t ),
771 },
772
773 /* function pointers in this component */
774 .init_thread = _appio_init_thread,
775 .init_component = _appio_init_component,
776 .init_control_state = _appio_init_control_state,
777 .start = _appio_start,
778 .stop = _appio_stop,
779 .read = _appio_read,
780 .shutdown_thread = _appio_shutdown_thread,
781 .shutdown_component = _appio_shutdown_component,
782 .ctl = _appio_ctl,
783
784 .update_control_state = _appio_update_control_state,
785 .set_domain = _appio_set_domain,
786 .reset = _appio_reset,
787
788 .ntv_enum_events = _appio_ntv_enum_events,
789 .ntv_name_to_code = _appio_ntv_name_to_code,
790 .ntv_code_to_name = _appio_ntv_code_to_name,
791 .ntv_code_to_descr = _appio_ntv_code_to_descr,
792 .ntv_code_to_bits = _appio_ntv_code_to_bits
793 /* .ntv_bits_to_info = NULL, */
794};
795
796/* vim:set ts=4 sw=4 sts=4 et: */
int i
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
Definition: appio.c:279
static int _appio_ntv_code_to_bits(unsigned int EventCode, hwd_register_t *bits)
Definition: appio.c:725
ssize_t __read(int fd, void *buf, size_t count)
static __thread long long _appio_register_current[APPIO_MAX_COUNTERS]
Definition: appio.c:69
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
Definition: appio.c:391
static const struct appio_counters _appio_counter_info[APPIO_MAX_COUNTERS]
static int _appio_reset(hwd_context_t *ctx, hwd_control_state_t *ctl)
Definition: appio.c:627
static int _appio_read(hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags)
Definition: appio.c:499
static int _appio_ntv_code_to_descr(unsigned int EventCode, char *desc, int len)
Definition: appio.c:708
static APPIO_native_event_entry_t * _appio_native_events
Definition: appio.c:65
static int _appio_ntv_name_to_code(const char *name, unsigned int *EventCode)
Definition: appio.c:672
int __select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
int open(const char *pathname, int flags, mode_t mode)
Definition: appio.c:188
static int _appio_ntv_enum_events(unsigned int *EventCode, int modifier)
Definition: appio.c:640
off_t __lseek(int fd, off_t offset, int whence)
int __close(int fd)
struct timeval zerotv
Definition: appio.c:200
static int _appio_shutdown_component(void)
Definition: appio.c:554
static int _appio_set_domain(hwd_control_state_t *ctl, int domain)
Definition: appio.c:611
static int _appio_ntv_code_to_name(unsigned int EventCode, char *name, int len)
Definition: appio.c:691
size_t _IO_fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
static int _appio_init_component(int cidx)
Definition: appio.c:431
off_t lseek(int fd, off_t offset, int whence)
Definition: appio.c:214
papi_vector_t _appio_vector
Definition: appio.c:57
static int _appio_stop(hwd_context_t *ctx, hwd_control_state_t *ctl)
Definition: appio.c:521
ssize_t __write(int fd, const void *buf, size_t count)
static int _appio_shutdown_thread(hwd_context_t *ctx)
Definition: appio.c:542
static int _appio_init_control_state(hwd_control_state_t *ctl)
Definition: appio.c:472
size_t _IO_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
static int _appio_start(hwd_context_t *ctx, hwd_control_state_t *ctl)
Definition: appio.c:481
int close(int fd)
Definition: appio.c:179
static int _appio_ctl(hwd_context_t *ctx, int code, _papi_int_option_t *option)
Definition: appio.c:567
ssize_t write(int fd, const void *buf, size_t count)
Definition: appio.c:302
int __open(const char *pathname, int flags, mode_t mode)
static int _appio_init_thread(hwd_context_t *ctx)
Definition: appio.c:417
int errno
static int _appio_update_control_state(hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
Definition: appio.c:578
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
Definition: appio.c:203
ssize_t read(int fd, void *buf, size_t count)
Definition: appio.c:229
#define HANDLE_STRING_ERROR
Definition: appio.c:172
_appio_stats_t
Definition: appio.c:70
@ WRITE_USEC
Definition: appio.c:87
@ WRITE_WOULD_BLOCK
Definition: appio.c:85
@ OPEN_FDS
Definition: appio.c:90
@ RECV_EOF
Definition: appio.c:98
@ SOCK_READ_WOULD_BLOCK
Definition: appio.c:105
@ SOCK_READ_USEC
Definition: appio.c:106
@ RECV_ERR
Definition: appio.c:94
@ RECV_SHORT
Definition: appio.c:97
@ SEEK_ABS_STRIDE_SIZE
Definition: appio.c:114
@ READ_SHORT
Definition: appio.c:76
@ OPEN_CALLS
Definition: appio.c:88
@ SOCK_WRITE_CALLS
Definition: appio.c:108
@ READ_WOULD_BLOCK
Definition: appio.c:75
@ SEEK_CALLS
Definition: appio.c:113
@ SOCK_WRITE_SHORT
Definition: appio.c:110
@ WRITE_BLOCK_SIZE
Definition: appio.c:86
@ RECV_INTERRUPTED
Definition: appio.c:95
@ SOCK_READ_SHORT
Definition: appio.c:104
@ READ_USEC
Definition: appio.c:79
@ SEEK_USEC
Definition: appio.c:115
@ RECV_USEC
Definition: appio.c:100
@ RECV_CALLS
Definition: appio.c:93
@ READ_ERR
Definition: appio.c:73
@ WRITE_INTERRUPTED
Definition: appio.c:84
@ WRITE_BYTES
Definition: appio.c:80
@ RECV_BYTES
Definition: appio.c:92
@ READ_BYTES
Definition: appio.c:71
@ WRITE_ERR
Definition: appio.c:82
@ SOCK_WRITE_USEC
Definition: appio.c:112
@ SOCK_WRITE_ERR
Definition: appio.c:109
@ SOCK_READ_ERR
Definition: appio.c:103
@ SOCK_WRITE_BYTES
Definition: appio.c:107
@ RECV_WOULD_BLOCK
Definition: appio.c:96
@ RECV_BLOCK_SIZE
Definition: appio.c:99
@ READ_EOF
Definition: appio.c:77
@ READ_INTERRUPTED
Definition: appio.c:74
@ WRITE_SHORT
Definition: appio.c:83
@ SELECT_USEC
Definition: appio.c:91
@ SOCK_READ_BYTES
Definition: appio.c:101
@ READ_CALLS
Definition: appio.c:72
@ SOCK_WRITE_WOULD_BLOCK
Definition: appio.c:111
@ SOCK_READ_CALLS
Definition: appio.c:102
@ READ_BLOCK_SIZE
Definition: appio.c:78
@ OPEN_ERR
Definition: appio.c:89
@ WRITE_CALLS
Definition: appio.c:81
appio component This file contains the source code for a component that enables PAPI to access applic...
#define APPIO_MAX_COUNTERS
Definition: appio.h:32
static long count
get real time counter value in microseconds
struct papi_vectors * _papi_hwd[]
volatile int buf[CACHE_FLUSH_BUFFER_SIZE_INTS]
Definition: do_loops.c:12
#define PAPI_DOM_USER
Definition: f90papi.h:174
#define PAPI_ENUM_EVENTS
Definition: f90papi.h:224
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
#define PAPI_ENOEVNT
Definition: f90papi.h:139
#define PAPI_EINVAL
Definition: f90papi.h:115
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
#define PAPI_ENOMEM
Definition: f90papi.h:16
#define PAPI_GRN_THR
Definition: f90papi.h:265
long long PAPI_get_real_usec(void)
Definition: papi.c:6824
char events[MAX_EVENTS][BUFSIZ]
Return codes and api definitions.
#define SUBDBG(format, args...)
Definition: papi_debug.h:64
__off_t off_t
__ssize_t ssize_t
FILE * stderr
void PAPIERROR(char *format,...)
#define PAPI_INT_SIGNAL
Definition: papi_internal.h:52
#define papi_calloc(a, b)
Definition: papi_memory.h:37
#define papi_free(a)
Definition: papi_memory.h:35
static int native
static int cidx
const char * name
Definition: rocs.c:225
int counter_bits[APPIO_MAX_COUNTERS]
Definition: appio.h:68
long long values[APPIO_MAX_COUNTERS]
Definition: appio.h:69
Definition: appio.h:52
const char * description
Definition: appio.h:55
APPIO_register_t resources
Definition: appio.h:53
const char * name
Definition: appio.h:54
unsigned int selector
Definition: appio.h:38
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:627
char disabled_reason[PAPI_HUGE_STR_LEN]
Definition: papi.h:634
const char * name
Definition: appio.c:119
const char * description
Definition: appio.c:120
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
int retval
Definition: zero_fork.c:53