PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
appio.c File Reference

appio component This file contains the source code for a component that enables PAPI to access application level file and socket I/O information. It does this through function replacement in the first person and by trapping syscalls in the third person. More...

Include dependency graph for appio.c:

Go to the source code of this file.

Data Structures

struct  appio_counters
 

Enumerations

enum  _appio_stats_t {
  READ_BYTES = 0, READ_CALLS, READ_ERR, READ_INTERRUPTED,
  READ_WOULD_BLOCK, READ_SHORT, READ_EOF, READ_BLOCK_SIZE,
  READ_USEC, WRITE_BYTES, WRITE_CALLS, WRITE_ERR,
  WRITE_SHORT, WRITE_INTERRUPTED, WRITE_WOULD_BLOCK, WRITE_BLOCK_SIZE,
  WRITE_USEC, OPEN_CALLS, OPEN_ERR, OPEN_FDS,
  SELECT_USEC, RECV_BYTES, RECV_CALLS, RECV_ERR,
  RECV_INTERRUPTED, RECV_WOULD_BLOCK, RECV_SHORT, RECV_EOF,
  RECV_BLOCK_SIZE, RECV_USEC, SOCK_READ_BYTES, SOCK_READ_CALLS,
  SOCK_READ_ERR, SOCK_READ_SHORT, SOCK_READ_WOULD_BLOCK, SOCK_READ_USEC,
  SOCK_WRITE_BYTES, SOCK_WRITE_CALLS, SOCK_WRITE_ERR, SOCK_WRITE_SHORT,
  SOCK_WRITE_WOULD_BLOCK, SOCK_WRITE_USEC, SEEK_CALLS, SEEK_ABS_STRIDE_SIZE,
  SEEK_USEC
}
 

Functions

int __close (int fd)
 
int close (int fd)
 
int __open (const char *pathname, int flags, mode_t mode)
 
int open (const char *pathname, int flags, mode_t mode)
 
int __select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
 
int select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
 
off_t __lseek (int fd, off_t offset, int whence)
 
off_t lseek (int fd, off_t offset, int whence)
 
ssize_t __read (int fd, void *buf, size_t count)
 
ssize_t read (int fd, void *buf, size_t count)
 
size_t _IO_fread (void *ptr, size_t size, size_t nmemb, FILE *stream)
 
size_t fread (void *ptr, size_t size, size_t nmemb, FILE *stream)
 
ssize_t __write (int fd, const void *buf, size_t count)
 
ssize_t write (int fd, const void *buf, size_t count)
 
size_t _IO_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream)
 
size_t fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream)
 
int _appio_init_thread (hwd_context_t *ctx)
 
int _appio_init_component (int cidx)
 
int _appio_init_control_state (hwd_control_state_t *ctl)
 
int _appio_start (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
int _appio_read (hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags)
 
int _appio_stop (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
int _appio_shutdown_thread (hwd_context_t *ctx)
 
int _appio_shutdown_component (void)
 
int _appio_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
 
int _appio_update_control_state (hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
 
int _appio_set_domain (hwd_control_state_t *ctl, int domain)
 
int _appio_reset (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
int _appio_ntv_enum_events (unsigned int *EventCode, int modifier)
 
int _appio_ntv_name_to_code (char *name, unsigned int *EventCode)
 
int _appio_ntv_code_to_name (unsigned int EventCode, char *name, int len)
 
int _appio_ntv_code_to_descr (unsigned int EventCode, char *desc, int len)
 
int _appio_ntv_code_to_bits (unsigned int EventCode, hwd_register_t *bits)
 

Variables

papi_vector_t _appio_vector
 
static APPIO_native_event_entry_t_appio_native_events
 
static __thread long long _appio_register_current [APPIO_MAX_COUNTERS]
 
static struct appio_counters _appio_counter_info [APPIO_MAX_COUNTERS]
 
struct timeval zerotv
 
int errno
 

Detailed Description

Author
Philip Mucci phil..nosp@m.mucc.nosp@m.i@sam.nosp@m.arat.nosp@m.echno.nosp@m.logy.nosp@m.group.nosp@m..com
Tushar Mohan tusha.nosp@m.rmoh.nosp@m.an@gm.nosp@m.ail..nosp@m.com

Credit to: Jose Pedro Oliveira jpo@d.nosp@m.i.um.nosp@m.inho..nosp@m.pt whose code in the linux net component was used as a template for many sections of code in this component.

Definition in file appio.c.

Enumeration Type Documentation

Enumerator
READ_BYTES 
READ_CALLS 
READ_ERR 
READ_INTERRUPTED 
READ_WOULD_BLOCK 
READ_SHORT 
READ_EOF 
READ_BLOCK_SIZE 
READ_USEC 
WRITE_BYTES 
WRITE_CALLS 
WRITE_ERR 
WRITE_SHORT 
WRITE_INTERRUPTED 
WRITE_WOULD_BLOCK 
WRITE_BLOCK_SIZE 
WRITE_USEC 
OPEN_CALLS 
OPEN_ERR 
OPEN_FDS 
SELECT_USEC 
RECV_BYTES 
RECV_CALLS 
RECV_ERR 
RECV_INTERRUPTED 
RECV_WOULD_BLOCK 
RECV_SHORT 
RECV_EOF 
RECV_BLOCK_SIZE 
RECV_USEC 
SOCK_READ_BYTES 
SOCK_READ_CALLS 
SOCK_READ_ERR 
SOCK_READ_SHORT 
SOCK_READ_WOULD_BLOCK 
SOCK_READ_USEC 
SOCK_WRITE_BYTES 
SOCK_WRITE_CALLS 
SOCK_WRITE_ERR 
SOCK_WRITE_SHORT 
SOCK_WRITE_WOULD_BLOCK 
SOCK_WRITE_USEC 
SEEK_CALLS 
SEEK_ABS_STRIDE_SIZE 
SEEK_USEC 

Definition at line 70 of file appio.c.

70  {
71  READ_BYTES = 0,
72  READ_CALLS,
73  READ_ERR,
76  READ_SHORT,
77  READ_EOF,
79  READ_USEC,
82  WRITE_ERR,
87  WRITE_USEC,
88  OPEN_CALLS,
89  OPEN_ERR,
90  OPEN_FDS,
92  RECV_BYTES,
93  RECV_CALLS,
94  RECV_ERR,
97  RECV_SHORT,
98  RECV_EOF,
100  RECV_USEC,
113  SEEK_CALLS,
115  SEEK_USEC
116 } _appio_stats_t ;
Definition: appio.c:73
Definition: appio.c:90
Definition: appio.c:77
Definition: appio.c:94
Definition: appio.c:98
Definition: appio.c:89
_appio_stats_t
Definition: appio.c:70

Function Documentation

int __close ( int  fd)

Here is the caller graph for this function:

off_t __lseek ( int  fd,
off_t  offset,
int  whence 
)

Here is the caller graph for this function:

int __open ( const char *  pathname,
int  flags,
mode_t  mode 
)

Here is the caller graph for this function:

ssize_t __read ( int  fd,
void buf,
size_t  count 
)

Here is the caller graph for this function:

int __select ( int  nfds,
fd_set *  readfds,
fd_set *  writefds,
fd_set *  exceptfds,
struct timeval *  timeout 
)

Here is the caller graph for this function:

ssize_t __write ( int  fd,
const void buf,
size_t  count 
)

Here is the caller graph for this function:

int _appio_ctl ( hwd_context_t ctx,
int  code,
_papi_int_option_t option 
)

Definition at line 553 of file appio.c.

554 {
555  ( void ) ctx;
556  ( void ) code;
557  ( void ) option;
558 
559  return PAPI_OK;
560 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
int _appio_init_component ( int  cidx)

Definition at line 426 of file appio.c.

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++) {
441  }
442 
443  /* Export the total number of events available */
445 
446  /* Export the component id */
448 
449  return PAPI_OK;
450 }
const char * name
Definition: appio.h:54
#define APPIO_MAX_COUNTERS
Definition: appio.h:32
Definition: appio.h:51
static APPIO_native_event_entry_t * _appio_native_events
Definition: appio.c:65
return PAPI_OK
Definition: linux-nvml.c:458
const char * description
Definition: appio.c:120
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
APPIO_register_t resources
Definition: appio.h:53
const char * description
Definition: appio.h:55
int i
Definition: fileop.c:140
static int cidx
Definition: event_info.c:40
static struct appio_counters _appio_counter_info[APPIO_MAX_COUNTERS]
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
void PAPIERROR(char *format,...)
const char * name
Definition: appio.c:119
#define PAPI_ENOMEM
Definition: papi.h:252
unsigned int selector
Definition: appio.h:38
papi_vector_t _appio_vector
Definition: appio.c:57
#define papi_calloc(a, b)
Definition: papi_memory.h:37

Here is the call graph for this function:

int _appio_init_control_state ( hwd_control_state_t ctl)

Definition at line 458 of file appio.c.

459 {
460  ( void ) ctl;
461 
462  return PAPI_OK;
463 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
int _appio_init_thread ( hwd_context_t ctx)

Definition at line 413 of file appio.c.

414 {
415  ( void ) ctx;
416  SUBDBG("_appio_init_thread %p\n", ctx);
417  return PAPI_OK;
418 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
int _appio_ntv_code_to_bits ( unsigned int  EventCode,
hwd_register_t bits 
)

Definition at line 711 of file appio.c.

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 }
#define PAPI_ENOEVNT
Definition: papi.h:258
#define APPIO_MAX_COUNTERS
Definition: appio.h:32
static APPIO_native_event_entry_t * _appio_native_events
Definition: appio.c:65
return PAPI_OK
Definition: linux-nvml.c:458
int _appio_ntv_code_to_descr ( unsigned int  EventCode,
char *  desc,
int  len 
)

Definition at line 694 of file appio.c.

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 }
#define PAPI_ENOEVNT
Definition: papi.h:258
#define APPIO_MAX_COUNTERS
Definition: appio.h:32
return PAPI_OK
Definition: linux-nvml.c:458
static struct appio_counters _appio_counter_info[APPIO_MAX_COUNTERS]
int _appio_ntv_code_to_name ( unsigned int  EventCode,
char *  name,
int  len 
)

Definition at line 677 of file appio.c.

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 }
#define PAPI_ENOEVNT
Definition: papi.h:258
#define APPIO_MAX_COUNTERS
Definition: appio.h:32
return PAPI_OK
Definition: linux-nvml.c:458
static struct appio_counters _appio_counter_info[APPIO_MAX_COUNTERS]
char * name
Definition: iozone.c:23648
int _appio_ntv_enum_events ( unsigned int EventCode,
int  modifier 
)

Definition at line 626 of file appio.c.

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 }
#define PAPI_ENOEVNT
Definition: papi.h:258
#define APPIO_MAX_COUNTERS
Definition: appio.h:32
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
int _appio_ntv_name_to_code ( char *  name,
unsigned int EventCode 
)

Definition at line 658 of file appio.c.

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 }
#define PAPI_ENOEVNT
Definition: papi.h:258
#define APPIO_MAX_COUNTERS
Definition: appio.h:32
return PAPI_OK
Definition: linux-nvml.c:458
int i
Definition: fileop.c:140
static struct appio_counters _appio_counter_info[APPIO_MAX_COUNTERS]
char * name
Definition: iozone.c:23648
int _appio_read ( hwd_context_t ctx,
hwd_control_state_t ctl,
long long **  events,
int  flags 
)

Definition at line 485 of file appio.c.

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 }
long long flags
Definition: iozone.c:12330
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
char events[MAX_EVENTS][BUFSIZ]
int i
Definition: fileop.c:140
long long values[APPIO_MAX_COUNTERS]
Definition: appio.h:69
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static __thread long long _appio_register_current[APPIO_MAX_COUNTERS]
Definition: appio.c:69
int counter_bits[APPIO_MAX_COUNTERS]
Definition: appio.h:68
int _appio_reset ( hwd_context_t ctx,
hwd_control_state_t ctl 
)

Definition at line 613 of file appio.c.

614 {
615  ( void ) ctx;
616  ( void ) ctl;
617 
618  return PAPI_OK;
619 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
int _appio_set_domain ( hwd_control_state_t ctl,
int  domain 
)

Definition at line 597 of file appio.c.

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 }
return PAPI_OK
Definition: linux-nvml.c:458
#define PAPI_DOM_USER
Definition: papi.h:296
void
Definition: iozone.c:18627
return PAPI_EINVAL
Definition: linux-nvml.c:408
long long found
Definition: libasync.c:735
int _appio_shutdown_component ( void  )

Definition at line 540 of file appio.c.

541 {
543  return PAPI_OK;
544 }
#define papi_free(a)
Definition: papi_memory.h:35
static APPIO_native_event_entry_t * _appio_native_events
Definition: appio.c:65
return PAPI_OK
Definition: linux-nvml.c:458
int _appio_shutdown_thread ( hwd_context_t ctx)

Definition at line 528 of file appio.c.

529 {
530  ( void ) ctx;
531 
532  return PAPI_OK;
533 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
int _appio_start ( hwd_context_t ctx,
hwd_control_state_t ctl 
)

Definition at line 467 of file appio.c.

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 }
#define APPIO_MAX_COUNTERS
Definition: appio.h:32
memset(eventId, 0, size)
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
long long values[APPIO_MAX_COUNTERS]
Definition: appio.h:69
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static __thread long long _appio_register_current[APPIO_MAX_COUNTERS]
Definition: appio.c:69

Here is the call graph for this function:

int _appio_stop ( hwd_context_t ctx,
hwd_control_state_t ctl 
)

Definition at line 507 of file appio.c.

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 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
int i
Definition: fileop.c:140
long long values[APPIO_MAX_COUNTERS]
Definition: appio.h:69
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static __thread long long _appio_register_current[APPIO_MAX_COUNTERS]
Definition: appio.c:69
int counter_bits[APPIO_MAX_COUNTERS]
Definition: appio.h:68
int _appio_update_control_state ( hwd_control_state_t ctl,
NativeInfo_t native,
int  count,
hwd_context_t ctx 
)

Definition at line 564 of file appio.c.

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 }
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
void
Definition: iozone.c:18627
int i
Definition: fileop.c:140
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
int counter_bits[APPIO_MAX_COUNTERS]
Definition: appio.h:68
size_t _IO_fread ( void ptr,
size_t  size,
size_t  nmemb,
FILE *  stream 
)

Here is the caller graph for this function:

size_t _IO_fwrite ( const void ptr,
size_t  size,
size_t  nmemb,
FILE *  stream 
)

Here is the caller graph for this function:

int close ( int  fd)

Definition at line 175 of file appio.c.

175  {
176  int retval;
177  SUBDBG("appio: intercepted close(%d)\n", fd);
178  retval = __close(fd);
180  return retval;
181 }
int fd
Definition: iozone.c:1291
Definition: appio.c:90
int __close(int fd)
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static __thread long long _appio_register_current[APPIO_MAX_COUNTERS]
Definition: appio.c:69
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

size_t fread ( void ptr,
size_t  size,
size_t  nmemb,
FILE *  stream 
)

Definition at line 275 of file appio.c.

275  {
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 }
size_t _IO_fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
Definition: appio.c:73
Definition: appio.c:77
char *long long size
Definition: iozone.c:12023
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static __thread long long _appio_register_current[APPIO_MAX_COUNTERS]
Definition: appio.c:69
long long PAPI_get_real_usec(void)
Definition: papi.c:6190
ssize_t retval
Definition: libasync.c:338
int n
Definition: mendes-alt.c:164
char * ptr
Definition: iozone.c:23586

Here is the call graph for this function:

Here is the caller graph for this function:

size_t fwrite ( const void ptr,
size_t  size,
size_t  nmemb,
FILE *  stream 
)

Definition at line 387 of file appio.c.

387  {
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 }
char *long long size
Definition: iozone.c:12023
size_t _IO_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static __thread long long _appio_register_current[APPIO_MAX_COUNTERS]
Definition: appio.c:69
long long PAPI_get_real_usec(void)
Definition: papi.c:6190
ssize_t retval
Definition: libasync.c:338
int n
Definition: mendes-alt.c:164
char * ptr
Definition: iozone.c:23586

Here is the call graph for this function:

Here is the caller graph for this function:

off_t lseek ( int  fd,
off_t  offset,
int  whence 
)

Definition at line 210 of file appio.c.

210  {
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 }
off_t __lseek(int fd, off_t offset, int whence)
off64_t offset
Definition: iozone.c:1279
int fd
Definition: iozone.c:1291
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static __thread long long _appio_register_current[APPIO_MAX_COUNTERS]
Definition: appio.c:69
long long PAPI_get_real_usec(void)
Definition: papi.c:6190
ssize_t retval
Definition: libasync.c:338
int n
Definition: mendes-alt.c:164

Here is the call graph for this function:

Here is the caller graph for this function:

int open ( const char *  pathname,
int  flags,
mode_t  mode 
)

Definition at line 184 of file appio.c.

184  {
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 }
int __open(const char *pathname, int flags, mode_t mode)
long long flags
Definition: iozone.c:12330
Definition: appio.c:90
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static __thread long long _appio_register_current[APPIO_MAX_COUNTERS]
Definition: appio.c:69
Definition: appio.c:89
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

ssize_t read ( int  fd,
void buf,
size_t  count 
)

Definition at line 225 of file appio.c.

225  {
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 }
int errno
int fd
Definition: iozone.c:1291
struct timeval zerotv
Definition: appio.c:196
int count
Definition: iozone.c:22422
ssize_t __read(int fd, void *buf, size_t count)
int __select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
Definition: appio.c:73
Definition: appio.c:77
char buf[200]
Definition: iozone.c:19609
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static __thread long long _appio_register_current[APPIO_MAX_COUNTERS]
Definition: appio.c:69
long long PAPI_get_real_usec(void)
Definition: papi.c:6190
ssize_t retval
Definition: libasync.c:338
int n
Definition: mendes-alt.c:164

Here is the call graph for this function:

Here is the caller graph for this function:

int select ( int  nfds,
fd_set *  readfds,
fd_set *  writefds,
fd_set *  exceptfds,
struct timeval *  timeout 
)

Definition at line 199 of file appio.c.

199  {
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 }
int __select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
double timeout
Definition: iozone.c:19099
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static __thread long long _appio_register_current[APPIO_MAX_COUNTERS]
Definition: appio.c:69
long long PAPI_get_real_usec(void)
Definition: papi.c:6190
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

ssize_t write ( int  fd,
const void buf,
size_t  count 
)

Definition at line 298 of file appio.c.

298  {
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 }
int errno
ssize_t __write(int fd, const void *buf, size_t count)
int fd
Definition: iozone.c:1291
struct timeval zerotv
Definition: appio.c:196
int count
Definition: iozone.c:22422
int __select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
char buf[200]
Definition: iozone.c:19609
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static __thread long long _appio_register_current[APPIO_MAX_COUNTERS]
Definition: appio.c:69
long long PAPI_get_real_usec(void)
Definition: papi.c:6190
ssize_t retval
Definition: libasync.c:338
int n
Definition: mendes-alt.c:164

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

struct appio_counters _appio_counter_info[APPIO_MAX_COUNTERS]
static
APPIO_native_event_entry_t* _appio_native_events
static

Definition at line 65 of file appio.c.

__thread long long _appio_register_current[APPIO_MAX_COUNTERS]
static

Definition at line 69 of file appio.c.

papi_vector_t _appio_vector

Definition at line 57 of file appio.c.

int errno
struct timeval zerotv

Definition at line 196 of file appio.c.