PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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
53 static void *_dlsym_fake(void *handle, const char* symbol) { (void) handle; (void) symbol; return NULL; }
54 void *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 */
69 static __thread long long _appio_register_current[APPIO_MAX_COUNTERS];
70 typedef enum {
116 } _appio_stats_t ;
117 
118 static 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"}
167 };
168 
169 
170 /*********************************************************************
171  *** BEGIN FUNCTIONS USED INTERNALLY SPECIFIC TO THIS COMPONENT ****
172  ********************************************************************/
173 
174 int __close(int fd);
175 int close(int fd) {
176  int retval;
177  SUBDBG("appio: intercepted close(%d)\n", fd);
178  retval = __close(fd);
180  return retval;
181 }
182 
183 int __open(const char *pathname, int flags, mode_t mode);
184 int open(const char *pathname, int flags, mode_t mode) {
185  int retval;
186  SUBDBG("appio: intercepted open(%s,%d,%d)\n", pathname, flags, mode);
187  retval = __open(pathname,flags,mode);
189  if (retval < 0) _appio_register_current[OPEN_ERR]++;
191  return retval;
192 }
193 
194 /* we use timeval as a zero value timeout to select in read/write
195  for polling if the operation would block */
196 struct timeval zerotv; /* this has to be zero, so define it here */
197 
198 int __select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
199 int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) {
200  int retval;
201  SUBDBG("appio: intercepted select(%d,%p,%p,%p,%p)\n", nfds,readfds,writefds,exceptfds,timeout);
202  long long start_ts = PAPI_get_real_usec();
203  retval = __select(nfds,readfds,writefds,exceptfds,timeout);
204  long long duration = PAPI_get_real_usec() - start_ts;
206  return retval;
207 }
208 
209 off_t __lseek(int fd, off_t offset, int whence);
210 off_t lseek(int fd, off_t offset, int whence) {
211  off_t retval;
212  SUBDBG("appio: intercepted lseek(%d,%ld,%d)\n", fd, offset, whence);
213  long long start_ts = PAPI_get_real_usec();
214  retval = __lseek(fd, offset, whence);
215  long long duration = PAPI_get_real_usec() - start_ts;
217  _appio_register_current[SEEK_USEC] += duration;
218  if (offset < 0) offset = -offset; // get abs offset
220  return retval;
221 }
222 
223 extern int errno;
224 ssize_t __read(int fd, void *buf, size_t count);
225 ssize_t read(int fd, void *buf, size_t count) {
226  int retval;
227  SUBDBG("appio: intercepted read(%d,%p,%lu)\n", fd, buf, (unsigned long)count);
228 
229  struct stat st;
230  int issocket = 0;
231  if (fstat(fd, &st) == 0) {
232  if ((st.st_mode & S_IFMT) == S_IFSOCK) issocket = 1;
233  }
234  // check if read would block on descriptor
235  fd_set readfds;
236  FD_ZERO(&readfds);
237  FD_SET(fd, &readfds);
238  int ready = __select(fd+1, &readfds, NULL, NULL, &zerotv);
239  if (ready == 0) {
242  }
243 
244  long long start_ts = PAPI_get_real_usec();
245  retval = __read(fd,buf, count);
246  long long duration = PAPI_get_real_usec() - start_ts;
247  int n = _appio_register_current[READ_CALLS]++; // read calls
248  if (issocket) _appio_register_current[SOCK_READ_CALLS]++; // read calls
249  if (retval > 0) {
251  _appio_register_current[READ_BYTES] += retval; // read bytes
253  if (retval < (int)count) {
254  _appio_register_current[READ_SHORT]++; // read short
255  if (issocket) _appio_register_current[SOCK_READ_SHORT]++; // read short
256  }
257  _appio_register_current[READ_USEC] += duration;
258  if (issocket) _appio_register_current[SOCK_READ_USEC] += duration;
259  }
260  if (retval < 0) {
261  _appio_register_current[READ_ERR]++; // read err
262  if (issocket) _appio_register_current[SOCK_READ_ERR]++; // read err
263  if (EINTR == errno)
264  _appio_register_current[READ_INTERRUPTED]++; // signal interrupted the read
265  //if ((EAGAIN == errno) || (EWOULDBLOCK == errno)) {
266  // _appio_register_current[READ_WOULD_BLOCK]++; //read would block on descriptor marked as non-blocking
267  // if (issocket) _appio_register_current[SOCK_READ_WOULD_BLOCK]++; //read would block on descriptor marked as non-blocking
268  //}
269  }
270  if (retval == 0) _appio_register_current[READ_EOF]++; // read eof
271  return retval;
272 }
273 
274 size_t _IO_fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
275 size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) {
276  size_t retval;
277  SUBDBG("appio: intercepted fread(%p,%lu,%lu,%p)\n", ptr, (unsigned long) size, (unsigned long) nmemb, (void*) stream);
278  long long start_ts = PAPI_get_real_usec();
279  retval = _IO_fread(ptr,size,nmemb,stream);
280  long long duration = PAPI_get_real_usec() - start_ts;
281  int n = _appio_register_current[READ_CALLS]++; // read calls
282  if (retval > 0) {
284  _appio_register_current[READ_BYTES]+= retval * size; // read bytes
285  if (retval < nmemb) _appio_register_current[READ_SHORT]++; // read short
286  _appio_register_current[READ_USEC] += duration;
287  }
288 
289  /* A value of zero returned means one of two things..*/
290  if (retval == 0) {
291  if (feof(stream)) _appio_register_current[READ_EOF]++; // read eof
292  else _appio_register_current[READ_ERR]++; // read err
293  }
294  return retval;
295 }
296 
297 ssize_t __write(int fd, const void *buf, size_t count);
298 ssize_t write(int fd, const void *buf, size_t count) {
299  int retval;
300  SUBDBG("appio: intercepted write(%d,%p,%lu)\n", fd, buf, (unsigned long)count);
301  struct stat st;
302  int issocket = 0;
303  if (fstat(fd, &st) == 0) {
304  if ((st.st_mode & S_IFMT) == S_IFSOCK) issocket = 1;
305  }
306 
307  // check if write would block on descriptor
308  fd_set writefds;
309  FD_ZERO(&writefds);
310  FD_SET(fd, &writefds);
311  int ready = __select(fd+1, NULL, &writefds, NULL, &zerotv);
312  if (ready == 0) {
315  }
316 
317  long long start_ts = PAPI_get_real_usec();
318  retval = __write(fd,buf, count);
319  long long duration = PAPI_get_real_usec() - start_ts;
320  int n = _appio_register_current[WRITE_CALLS]++; // write calls
321  if (issocket) _appio_register_current[SOCK_WRITE_CALLS]++; // socket write
322  if (retval >= 0) {
324  _appio_register_current[WRITE_BYTES]+= retval; // write bytes
326  if (retval < (int)count) {
327  _appio_register_current[WRITE_SHORT]++; // short write
328  if (issocket) _appio_register_current[SOCK_WRITE_SHORT]++;
329  }
330  _appio_register_current[WRITE_USEC] += duration;
331  if (issocket) _appio_register_current[SOCK_WRITE_USEC] += duration;
332  }
333  if (retval < 0) {
335  if (issocket) _appio_register_current[SOCK_WRITE_ERR]++;
336  if (EINTR == errno)
337  _appio_register_current[WRITE_INTERRUPTED]++; // signal interrupted the op
338  //if ((EAGAIN == errno) || (EWOULDBLOCK == errno)) {
339  // _appio_register_current[WRITE_WOULD_BLOCK]++; //op would block on descriptor marked as non-blocking
340  // if (issocket) _appio_register_current[SOCK_WRITE_WOULD_BLOCK]++;
341  //}
342  }
343  return retval;
344 }
345 
346 // The PIC test implies it's built for shared linkage
347 #ifdef PIC
348 static ssize_t (*__recv)(int sockfd, void *buf, size_t len, int flags) = NULL;
349 ssize_t recv(int sockfd, void *buf, size_t len, int flags) {
350  int retval;
351  SUBDBG("appio: intercepted recv(%d,%p,%lu,%d)\n", sockfd, buf, (unsigned long)len, flags);
352  if (!__recv) __recv = dlsym(RTLD_NEXT, "recv");
353  if (!__recv) {
354  fprintf(stderr, "appio,c Internal Error: Could not obtain handle for real recv\n");
355  exit(1);
356  }
357  // check if recv would block on descriptor
358  fd_set readfds;
359  FD_ZERO(&readfds);
360  FD_SET(sockfd, &readfds);
361  int ready = __select(sockfd+1, &readfds, NULL, NULL, &zerotv);
362  if (ready == 0) _appio_register_current[RECV_WOULD_BLOCK]++;
363 
364  long long start_ts = PAPI_get_real_usec();
365  retval = __recv(sockfd, buf, len, flags);
366  long long duration = PAPI_get_real_usec() - start_ts;
367  int n = _appio_register_current[RECV_CALLS]++; // read calls
368  if (retval > 0) {
370  _appio_register_current[RECV_BYTES] += retval; // read bytes
371  if (retval < (int)len) _appio_register_current[RECV_SHORT]++; // read short
372  _appio_register_current[RECV_USEC] += duration;
373  }
374  if (retval < 0) {
375  _appio_register_current[RECV_ERR]++; // read err
376  if (EINTR == errno)
377  _appio_register_current[RECV_INTERRUPTED]++; // signal interrupted the read
378  if ((EAGAIN == errno) || (EWOULDBLOCK == errno))
379  _appio_register_current[RECV_WOULD_BLOCK]++; //read would block on descriptor marked as non-blocking
380  }
381  if (retval == 0) _appio_register_current[RECV_EOF]++; // read eof
382  return retval;
383 }
384 #endif /* PIC */
385 
386 size_t _IO_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
387 size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) {
388  size_t retval;
389  SUBDBG("appio: intercepted fwrite(%p,%lu,%lu,%p)\n", ptr, (unsigned long) size, (unsigned long) nmemb, (void*) stream);
390  long long start_ts = PAPI_get_real_usec();
391  retval = _IO_fwrite(ptr,size,nmemb,stream);
392  long long duration = PAPI_get_real_usec() - start_ts;
393  int n = _appio_register_current[WRITE_CALLS]++; // write calls
394  if (retval > 0) {
395  _appio_register_current[WRITE_BLOCK_SIZE]= (n * _appio_register_current[WRITE_BLOCK_SIZE] + size*nmemb)/(n+1); // mean block size
396  _appio_register_current[WRITE_BYTES]+= retval * size; // write bytes
397  if (retval < nmemb) _appio_register_current[WRITE_SHORT]++; // short write
398  _appio_register_current[WRITE_USEC] += duration;
399  }
400  if (retval == 0) _appio_register_current[WRITE_ERR]++; // err
401  return retval;
402 }
403 
404 
405 /*********************************************************************
406  *************** BEGIN PAPI's COMPONENT REQUIRED FUNCTIONS *********
407  *********************************************************************/
408 
409 /*
410  * This is called whenever a thread is initialized
411  */
412 int
414 {
415  ( void ) ctx;
416  SUBDBG("_appio_init_thread %p\n", ctx);
417  return PAPI_OK;
418 }
419 
420 
421 /* Initialize hardware counters, setup the function vector table
422  * and get hardware information, this routine is called when the
423  * PAPI process is initialized (IE PAPI_library_init)
424  */
425 int
427 {
428 
429  SUBDBG("_appio_component %d\n", cidx);
431 
432  if (_appio_native_events == NULL ) {
433  PAPIERROR( "malloc():Could not get memory for events table" );
434  return PAPI_ENOMEM;
435  }
436  int i;
437  for (i=0; i<APPIO_MAX_COUNTERS; i++) {
438  _appio_native_events[i].name = _appio_counter_info[i].name;
439  _appio_native_events[i].description = _appio_counter_info[i].description;
440  _appio_native_events[i].resources.selector = i + 1;
441  }
442 
443  /* Export the total number of events available */
445 
446  /* Export the component id */
447  _appio_vector.cmp_info.CmpIdx = cidx;
448 
449  return PAPI_OK;
450 }
451 
452 
453 /*
454  * Control of counters (Reading/Writing/Starting/Stopping/Setup)
455  * functions
456  */
457 int
459 {
460  ( void ) ctl;
461 
462  return PAPI_OK;
463 }
464 
465 
466 int
468 {
469  ( void ) ctx;
470 
471  SUBDBG("_appio_start %p %p\n", ctx, ctl);
472  APPIO_control_state_t *appio_ctl = (APPIO_control_state_t *) ctl;
473 
474  /* this memset needs to move to thread_init */
476 
477  /* set initial values to 0 */
478  memset(appio_ctl->values, 0, APPIO_MAX_COUNTERS*sizeof(appio_ctl->values[0]));
479 
480  return PAPI_OK;
481 }
482 
483 
484 int
486  long long ** events, int flags )
487 {
488  (void) flags;
489  (void) ctx;
490 
491  SUBDBG("_appio_read %p %p\n", ctx, ctl);
492  APPIO_control_state_t *appio_ctl = (APPIO_control_state_t *) ctl;
493  int i;
494 
495  for ( i=0; i<appio_ctl->num_events; i++ ) {
496  int index = appio_ctl->counter_bits[i];
497  SUBDBG("event=%d, index=%d, val=%lld\n", i, index, _appio_register_current[index]);
498  appio_ctl->values[index] = _appio_register_current[index];
499  }
500  *events = appio_ctl->values;
501 
502  return PAPI_OK;
503 }
504 
505 
506 int
508 {
509  (void) ctx;
510 
511  SUBDBG("_appio_stop ctx=%p ctl=%p\n", ctx, ctl);
512  APPIO_control_state_t *appio_ctl = (APPIO_control_state_t *) ctl;
513  int i;
514  for ( i=0; i<appio_ctl->num_events; i++ ) {
515  int index = appio_ctl->counter_bits[i];
516  SUBDBG("event=%d, index=%d, val=%lld\n", i, index, _appio_register_current[index]);
517  appio_ctl->values[i] = _appio_register_current[index];
518  }
519 
520  return PAPI_OK;
521 }
522 
523 
524 /*
525  * Thread shutdown
526  */
527 int
529 {
530  ( void ) ctx;
531 
532  return PAPI_OK;
533 }
534 
535 
536 /*
537  * Clean up what was setup in appio_init_component().
538  */
539 int
541 {
542  papi_free( _appio_native_events );
543  return PAPI_OK;
544 }
545 
546 
547 /* This function sets various options in the component
548  * The valid codes being passed in are PAPI_SET_DEFDOM,
549  * PAPI_SET_DOMAIN, PAPI_SETDEFGRN, PAPI_SET_GRANUL and
550  * PAPI_SET_INHERIT
551  */
552 int
553 _appio_ctl( hwd_context_t *ctx, int code, _papi_int_option_t *option )
554 {
555  ( void ) ctx;
556  ( void ) code;
557  ( void ) option;
558 
559  return PAPI_OK;
560 }
561 
562 
563 int
565  NativeInfo_t *native, int count, hwd_context_t *ctx )
566 {
567  ( void ) ctx;
568  ( void ) ctl;
569 
570  SUBDBG("_appio_update_control_state ctx=%p ctl=%p num_events=%d\n", ctx, ctl, count);
571  int i, index;
572  APPIO_control_state_t *appio_ctl = (APPIO_control_state_t *) ctl;
573  (void) ctx;
574 
575  for ( i = 0; i < count; i++ ) {
576  index = native[i].ni_event;
577  appio_ctl->counter_bits[i] = index;
578  native[i].ni_position = index;
579  }
580  appio_ctl->num_events = count;
581 
582  return PAPI_OK;
583 }
584 
585 
586 /*
587  * This function has to set the bits needed to count different domains
588  * In particular: PAPI_DOM_USER, PAPI_DOM_KERNEL PAPI_DOM_OTHER
589  * By default return PAPI_EINVAL if none of those are specified
590  * and PAPI_OK with success
591  * PAPI_DOM_USER is only user context is counted
592  * PAPI_DOM_KERNEL is only the Kernel/OS context is counted
593  * PAPI_DOM_OTHER is Exception/transient mode (like user TLB misses)
594  * PAPI_DOM_ALL is all of the domains
595  */
596 int
598 {
599  ( void ) ctl;
600 
601  int found = 0;
602 
603  if ( PAPI_DOM_USER == domain ) found = 1;
604 
605  if ( !found )
606  return PAPI_EINVAL;
607 
608  return PAPI_OK;
609 }
610 
611 
612 int
614 {
615  ( void ) ctx;
616  ( void ) ctl;
617 
618  return PAPI_OK;
619 }
620 
621 
622 /*
623  * Native Event functions
624  */
625 int
626 _appio_ntv_enum_events( unsigned int *EventCode, int modifier )
627 {
628  int index;
629 
630  switch ( modifier ) {
631  case PAPI_ENUM_FIRST:
632  *EventCode = 0;
633  return PAPI_OK;
634  break;
635 
636  case PAPI_ENUM_EVENTS:
637  index = *EventCode;
638  if ( index < APPIO_MAX_COUNTERS - 1 ) {
639  *EventCode = *EventCode + 1;
640  return PAPI_OK;
641  } else {
642  return PAPI_ENOEVNT;
643  }
644  break;
645 
646  default:
647  return PAPI_EINVAL;
648  break;
649  }
650  return PAPI_EINVAL;
651 }
652 
653 
654 /*
655  *
656  */
657 int
658 _appio_ntv_name_to_code( char *name, unsigned int *EventCode )
659 {
660  int i;
661 
662  for ( i=0; i<APPIO_MAX_COUNTERS; i++) {
663  if (strcmp(name, _appio_counter_info[i].name) == 0) {
664  *EventCode = i;
665  return PAPI_OK;
666  }
667  }
668 
669  return PAPI_ENOEVNT;
670 }
671 
672 
673 /*
674  *
675  */
676 int
677 _appio_ntv_code_to_name( unsigned int EventCode, char *name, int len )
678 {
679  int index = EventCode;
680 
681  if ( index >= 0 && index < APPIO_MAX_COUNTERS ) {
682  strncpy( name, _appio_counter_info[index].name, len );
683  return PAPI_OK;
684  }
685 
686  return PAPI_ENOEVNT;
687 }
688 
689 
690 /*
691  *
692  */
693 int
694 _appio_ntv_code_to_descr( unsigned int EventCode, char *desc, int len )
695 {
696  int index = EventCode;
697 
698  if ( index >= 0 && index < APPIO_MAX_COUNTERS ) {
699  strncpy(desc, _appio_counter_info[index].description, len );
700  return PAPI_OK;
701  }
702 
703  return PAPI_ENOEVNT;
704 }
705 
706 
707 /*
708  *
709  */
710 int
711 _appio_ntv_code_to_bits( unsigned int EventCode, hwd_register_t *bits )
712 {
713  int index = EventCode;
714 
715  if ( index >= 0 && index < APPIO_MAX_COUNTERS ) {
716  memcpy( ( APPIO_register_t * ) bits,
717  &( _appio_native_events[index].resources ),
718  sizeof ( APPIO_register_t ) );
719  return PAPI_OK;
720  }
721 
722  return PAPI_ENOEVNT;
723 }
724 
725 
726 /*
727  *
728  */
729 papi_vector_t _appio_vector = {
730  .cmp_info = {
731  /* default component information (unspecified values are initialized to 0) */
732  .name = "appio",
733  .short_name = "appio",
734  .version = "1.1.2.4",
735  .CmpIdx = 0, /* set by init_component */
736  .num_mpx_cntrs = APPIO_MAX_COUNTERS,
737  .num_cntrs = APPIO_MAX_COUNTERS,
738  .default_domain = PAPI_DOM_USER,
739  .available_domains = PAPI_DOM_USER,
740  .default_granularity = PAPI_GRN_THR,
741  .available_granularities = PAPI_GRN_THR,
742  .hardware_intr_sig = PAPI_INT_SIGNAL,
743 
744  /* component specific cmp_info initializations */
745  .fast_real_timer = 0,
746  .fast_virtual_timer = 0,
747  .attach = 0,
748  .attach_must_ptrace = 0,
749  },
750 
751  /* sizes of framework-opaque component-private structures */
752  .size = {
753  .context = sizeof ( APPIO_context_t ),
754  .control_state = sizeof ( APPIO_control_state_t ),
755  .reg_value = sizeof ( APPIO_register_t ),
756  .reg_alloc = sizeof ( APPIO_reg_alloc_t ),
757  },
758 
759  /* function pointers in this component */
760  .init_thread = _appio_init_thread,
761  .init_component = _appio_init_component,
762  .init_control_state = _appio_init_control_state,
763  .start = _appio_start,
764  .stop = _appio_stop,
765  .read = _appio_read,
766  .shutdown_thread = _appio_shutdown_thread,
767  .shutdown_component = _appio_shutdown_component,
768  .ctl = _appio_ctl,
769 
770  .update_control_state = _appio_update_control_state,
771  .set_domain = _appio_set_domain,
772  .reset = _appio_reset,
773 
774  .ntv_enum_events = _appio_ntv_enum_events,
775  .ntv_name_to_code = _appio_ntv_name_to_code,
776  .ntv_code_to_name = _appio_ntv_code_to_name,
777  .ntv_code_to_descr = _appio_ntv_code_to_descr,
778  .ntv_code_to_bits = _appio_ntv_code_to_bits
779  /* .ntv_bits_to_info = NULL, */
780 };
781 
782 /* vim:set ts=4 sw=4 sts=4 et: */
int _appio_set_domain(hwd_control_state_t *ctl, int domain)
Definition: appio.c:597
const char * name
Definition: appio.h:54
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:626
#define PAPI_ENOEVNT
Definition: papi.h:258
#define APPIO_MAX_COUNTERS
Definition: appio.h:32
ssize_t read(int fd, void *buf, size_t count)
Definition: appio.c:225
memset(eventId, 0, size)
int errno
int _appio_ntv_code_to_descr(unsigned int EventCode, char *desc, int len)
Definition: appio.c:694
int close(int fd)
Definition: appio.c:175
int _appio_init_control_state(hwd_control_state_t *ctl)
Definition: appio.c:458
ssize_t __write(int fd, const void *buf, size_t count)
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
Definition: appio.c:387
int __open(const char *pathname, int flags, mode_t mode)
off_t __lseek(int fd, off_t offset, int whence)
long long flags
Definition: iozone.c:12330
Definition: appio.h:51
size_t _IO_fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
#define papi_free(a)
Definition: papi_memory.h:35
static APPIO_native_event_entry_t * _appio_native_events
Definition: appio.c:65
off64_t offset
Definition: iozone.c:1279
off_t lseek(int fd, off_t offset, int whence)
Definition: appio.c:210
int fd
Definition: iozone.c:1291
int _appio_reset(hwd_context_t *ctx, hwd_control_state_t *ctl)
Definition: appio.c:613
struct timeval zerotv
Definition: appio.c:196
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
Definition: appio.c:275
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
const char * description
Definition: appio.c:120
int _appio_init_component(int cidx)
Definition: appio.c:426
#define PAPI_DOM_USER
Definition: papi.h:296
int _appio_init_thread(hwd_context_t *ctx)
Definition: appio.c:413
int _appio_ntv_enum_events(unsigned int *EventCode, int modifier)
Definition: appio.c:626
void
Definition: iozone.c:18627
return PAPI_EINVAL
Definition: linux-nvml.c:408
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
Return codes and api definitions.
int _appio_ntv_code_to_name(unsigned int EventCode, char *name, int len)
Definition: appio.c:677
APPIO_register_t resources
Definition: appio.h:53
ssize_t __read(int fd, void *buf, size_t count)
int _appio_stop(hwd_context_t *ctx, hwd_control_state_t *ctl)
Definition: appio.c:507
char events[MAX_EVENTS][BUFSIZ]
int __select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
Definition: appio.c:73
const char * description
Definition: appio.h:55
Definition: appio.c:90
int _appio_read(hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags)
Definition: appio.c:485
int open(const char *pathname, int flags, mode_t mode)
Definition: appio.c:184
int _appio_ntv_code_to_bits(unsigned int EventCode, hwd_register_t *bits)
Definition: appio.c:711
int i
Definition: fileop.c:140
double timeout
Definition: iozone.c:19099
Definition: appio.c:77
char buf[200]
Definition: iozone.c:19609
ssize_t write(int fd, const void *buf, size_t count)
Definition: appio.c:298
int _appio_shutdown_component(void)
Definition: appio.c:540
int __close(int fd)
long long found
Definition: libasync.c:735
long long values[APPIO_MAX_COUNTERS]
Definition: appio.h:69
char *long long size
Definition: iozone.c:12023
static int cidx
Definition: event_info.c:40
size_t _IO_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
static int native
Definition: event_info.c:39
static struct appio_counters _appio_counter_info[APPIO_MAX_COUNTERS]
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
Definition: appio.c:199
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
void PAPIERROR(char *format,...)
appio component This file contains the source code for a component that enables PAPI to access applic...
const char * name
Definition: appio.c:119
#define PAPI_INT_SIGNAL
Definition: papi_internal.h:53
#define PAPI_GRN_THR
Definition: papi.h:360
#define PAPI_ENOMEM
Definition: papi.h:252
static __thread long long _appio_register_current[APPIO_MAX_COUNTERS]
Definition: appio.c:69
int _appio_ntv_name_to_code(char *name, unsigned int *EventCode)
Definition: appio.c:658
long long PAPI_get_real_usec(void)
Definition: papi.c:6190
char * name
Definition: iozone.c:23648
int _appio_ctl(hwd_context_t *ctx, int code, _papi_int_option_t *option)
Definition: appio.c:553
Definition: appio.c:94
Definition: appio.c:98
int _appio_start(hwd_context_t *ctx, hwd_control_state_t *ctl)
Definition: appio.c:467
int _appio_update_control_state(hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
Definition: appio.c:564
Definition: appio.c:89
unsigned int selector
Definition: appio.h:38
ssize_t retval
Definition: libasync.c:338
_appio_stats_t
Definition: appio.c:70
int counter_bits[APPIO_MAX_COUNTERS]
Definition: appio.h:68
void exit()
papi_vector_t _appio_vector
Definition: appio.c:57
#define papi_calloc(a, b)
Definition: papi_memory.h:37
int n
Definition: mendes-alt.c:164
int _appio_shutdown_thread(hwd_context_t *ctx)
Definition: appio.c:528
char * ptr
Definition: iozone.c:23586