PAPI 7.1.0.0
Loading...
Searching...
No Matches
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
 

Macros

#define HANDLE_STRING_ERROR   {fprintf(stderr,"%s:%i unexpected string function error.\n",__FILE__,__LINE__); exit(-1);}
 

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)
 
static int _appio_init_thread (hwd_context_t *ctx)
 
static int _appio_init_component (int cidx)
 
static int _appio_init_control_state (hwd_control_state_t *ctl)
 
static int _appio_start (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
static int _appio_read (hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags)
 
static int _appio_stop (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
static int _appio_shutdown_thread (hwd_context_t *ctx)
 
static int _appio_shutdown_component (void)
 
static int _appio_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
 
static int _appio_update_control_state (hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
 
static int _appio_set_domain (hwd_control_state_t *ctl, int domain)
 
static int _appio_reset (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
static int _appio_ntv_enum_events (unsigned int *EventCode, int modifier)
 
static int _appio_ntv_name_to_code (const char *name, unsigned int *EventCode)
 
static int _appio_ntv_code_to_name (unsigned int EventCode, char *name, int len)
 
static int _appio_ntv_code_to_descr (unsigned int EventCode, char *desc, int len)
 
static 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 const 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.

Macro Definition Documentation

◆ HANDLE_STRING_ERROR

#define HANDLE_STRING_ERROR   {fprintf(stderr,"%s:%i unexpected string function error.\n",__FILE__,__LINE__); exit(-1);}

Definition at line 172 of file appio.c.

Enumeration Type Documentation

◆ _appio_stats_t

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,
100 RECV_USEC,
_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

Function Documentation

◆ __close()

int __close ( int  fd)
Here is the caller graph for this function:

◆ __lseek()

off_t __lseek ( int  fd,
off_t  offset,
int  whence 
)
Here is the caller graph for this function:

◆ __open()

int __open ( const char *  pathname,
int  flags,
mode_t  mode 
)
Here is the caller graph for this function:

◆ __read()

ssize_t __read ( int  fd,
void *  buf,
size_t  count 
)
Here is the caller graph for this function:

◆ __select()

int __select ( int  nfds,
fd_set readfds,
fd_set writefds,
fd_set exceptfds,
struct timeval timeout 
)
Here is the caller graph for this function:

◆ __write()

ssize_t __write ( int  fd,
const void *  buf,
size_t  count 
)
Here is the caller graph for this function:

◆ _appio_ctl()

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

Definition at line 567 of file appio.c.

568{
569 ( void ) ctx;
570 ( void ) code;
571 ( void ) option;
572
573 return PAPI_OK;
574}
#define PAPI_OK
Definition: f90papi.h:73

◆ _appio_init_component()

static int _appio_init_component ( int  cidx)
static

Definition at line 431 of file appio.c.

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}
int i
static const struct appio_counters _appio_counter_info[APPIO_MAX_COUNTERS]
static APPIO_native_event_entry_t * _appio_native_events
Definition: appio.c:65
papi_vector_t _appio_vector
Definition: appio.c:57
#define HANDLE_STRING_ERROR
Definition: appio.c:172
#define APPIO_MAX_COUNTERS
Definition: appio.h:32
struct papi_vectors * _papi_hwd[]
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
#define PAPI_ENOMEM
Definition: f90papi.h:16
#define SUBDBG(format, args...)
Definition: papi_debug.h:64
void PAPIERROR(char *format,...)
#define papi_calloc(a, b)
Definition: papi_memory.h:37
static int cidx
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 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
Here is the call graph for this function:

◆ _appio_init_control_state()

static int _appio_init_control_state ( hwd_control_state_t ctl)
static

Definition at line 472 of file appio.c.

473{
474 ( void ) ctl;
475
476 return PAPI_OK;
477}

◆ _appio_init_thread()

static int _appio_init_thread ( hwd_context_t ctx)
static

Definition at line 417 of file appio.c.

418{
419 ( void ) ctx;
420 SUBDBG("_appio_init_thread %p\n", ctx);
421 return PAPI_OK;
422}

◆ _appio_ntv_code_to_bits()

static int _appio_ntv_code_to_bits ( unsigned int  EventCode,
hwd_register_t bits 
)
static

Definition at line 725 of file appio.c.

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}
#define PAPI_ENOEVNT
Definition: f90papi.h:139

◆ _appio_ntv_code_to_descr()

static int _appio_ntv_code_to_descr ( unsigned int  EventCode,
char *  desc,
int  len 
)
static

Definition at line 708 of file appio.c.

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}

◆ _appio_ntv_code_to_name()

static int _appio_ntv_code_to_name ( unsigned int  EventCode,
char *  name,
int  len 
)
static

Definition at line 691 of file appio.c.

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}
const char * name
Definition: rocs.c:225

◆ _appio_ntv_enum_events()

static int _appio_ntv_enum_events ( unsigned int EventCode,
int  modifier 
)
static

Definition at line 640 of file appio.c.

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}
#define PAPI_ENUM_EVENTS
Definition: f90papi.h:224
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
#define PAPI_EINVAL
Definition: f90papi.h:115

◆ _appio_ntv_name_to_code()

static int _appio_ntv_name_to_code ( const char *  name,
unsigned int EventCode 
)
static

Definition at line 672 of file appio.c.

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}

◆ _appio_read()

static int _appio_read ( hwd_context_t ctx,
hwd_control_state_t ctl,
long long **  events,
int  flags 
)
static

Definition at line 499 of file appio.c.

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}
static __thread long long _appio_register_current[APPIO_MAX_COUNTERS]
Definition: appio.c:69
char events[MAX_EVENTS][BUFSIZ]
int counter_bits[APPIO_MAX_COUNTERS]
Definition: appio.h:68
long long values[APPIO_MAX_COUNTERS]
Definition: appio.h:69

◆ _appio_reset()

static int _appio_reset ( hwd_context_t ctx,
hwd_control_state_t ctl 
)
static

Definition at line 627 of file appio.c.

628{
629 ( void ) ctx;
630 ( void ) ctl;
631
632 return PAPI_OK;
633}

◆ _appio_set_domain()

static int _appio_set_domain ( hwd_control_state_t ctl,
int  domain 
)
static

Definition at line 611 of file appio.c.

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}
#define PAPI_DOM_USER
Definition: f90papi.h:174

◆ _appio_shutdown_component()

static int _appio_shutdown_component ( void  )
static

Definition at line 554 of file appio.c.

555{
557 return PAPI_OK;
558}
#define papi_free(a)
Definition: papi_memory.h:35

◆ _appio_shutdown_thread()

static int _appio_shutdown_thread ( hwd_context_t ctx)
static

Definition at line 542 of file appio.c.

543{
544 ( void ) ctx;
545
546 return PAPI_OK;
547}

◆ _appio_start()

static int _appio_start ( hwd_context_t ctx,
hwd_control_state_t ctl 
)
static

Definition at line 481 of file appio.c.

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}

◆ _appio_stop()

static int _appio_stop ( hwd_context_t ctx,
hwd_control_state_t ctl 
)
static

Definition at line 521 of file appio.c.

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}

◆ _appio_update_control_state()

static int _appio_update_control_state ( hwd_control_state_t ctl,
NativeInfo_t native,
int  count,
hwd_context_t ctx 
)
static

Definition at line 578 of file appio.c.

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}
static long count
static int native

◆ _IO_fread()

size_t _IO_fread ( void *  ptr,
size_t  size,
size_t  nmemb,
FILE *  stream 
)
Here is the caller graph for this function:

◆ _IO_fwrite()

size_t _IO_fwrite ( const void *  ptr,
size_t  size,
size_t  nmemb,
FILE *  stream 
)
Here is the caller graph for this function:

◆ close()

int close ( int  fd)

Definition at line 179 of file appio.c.

179 {
180 int retval;
181 SUBDBG("appio: intercepted close(%d)\n", fd);
182 retval = __close(fd);
184 return retval;
185}
int __close(int fd)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fread()

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

Definition at line 279 of file appio.c.

279 {
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}
size_t _IO_fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
get real time counter value in microseconds
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fwrite()

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

Definition at line 391 of file appio.c.

391 {
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}
size_t _IO_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lseek()

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

Definition at line 214 of file appio.c.

214 {
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}
off_t __lseek(int fd, off_t offset, int whence)
__off_t off_t
Here is the call graph for this function:
Here is the caller graph for this function:

◆ open()

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

Definition at line 188 of file appio.c.

188 {
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}
int __open(const char *pathname, int flags, mode_t mode)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read()

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

Definition at line 229 of file appio.c.

229 {
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}
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)
struct timeval zerotv
Definition: appio.c:200
int errno
volatile int buf[CACHE_FLUSH_BUFFER_SIZE_INTS]
Definition: do_loops.c:12
Here is the call graph for this function:
Here is the caller graph for this function:

◆ select()

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

Definition at line 203 of file appio.c.

203 {
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}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ write()

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

Definition at line 302 of file appio.c.

302 {
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}
ssize_t __write(int fd, const void *buf, size_t count)
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _appio_counter_info

const struct appio_counters _appio_counter_info[APPIO_MAX_COUNTERS]
static

◆ _appio_native_events

APPIO_native_event_entry_t* _appio_native_events
static

Definition at line 65 of file appio.c.

◆ _appio_register_current

__thread long long _appio_register_current[APPIO_MAX_COUNTERS]
static

Definition at line 69 of file appio.c.

◆ _appio_vector

papi_vector_t _appio_vector

Definition at line 57 of file appio.c.

◆ errno

int errno
extern

◆ zerotv

struct timeval zerotv

Definition at line 200 of file appio.c.