33#include <sys/select.h>
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"}
172#define HANDLE_STRING_ERROR {fprintf(stderr,"%s:%i unexpected string function error.\n",__FILE__,__LINE__); exit(-1);}
181 SUBDBG(
"appio: intercepted close(%d)\n", fd);
187int __open(
const char *pathname,
int flags, mode_t mode);
188int open(
const char *pathname,
int flags, mode_t mode) {
190 SUBDBG(
"appio: intercepted open(%s,%d,%d)\n", pathname, flags, mode);
205 SUBDBG(
"appio: intercepted select(%d,%p,%p,%p,%p)\n", nfds,readfds,writefds,exceptfds,timeout);
216 SUBDBG(
"appio: intercepted lseek(%d,%ld,%d)\n", fd, offset, whence);
222 if (offset < 0) offset = -offset;
231 SUBDBG(
"appio: intercepted read(%d,%p,%lu)\n", fd,
buf, (
unsigned long)
count);
235 if (fstat(fd, &st) == 0) {
236 if ((st.st_mode & S_IFMT) == S_IFSOCK) issocket = 1;
241 FD_SET(fd, &readfds);
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) {
281 SUBDBG(
"appio: intercepted fread(%p,%lu,%lu,%p)\n", ptr, (
unsigned long) size, (
unsigned long) nmemb, (
void*) stream);
304 SUBDBG(
"appio: intercepted write(%d,%p,%lu)\n", fd,
buf, (
unsigned long)
count);
307 if (fstat(fd, &st) == 0) {
308 if ((st.st_mode & S_IFMT) == S_IFSOCK) issocket = 1;
314 FD_SET(fd, &writefds);
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) {
355 SUBDBG(
"appio: intercepted recv(%d,%p,%lu,%d)\n", sockfd,
buf, (
unsigned long)len, flags);
356 if (!__recv) __recv = dlsym(RTLD_NEXT,
"recv");
358 fprintf(
stderr,
"appio,c Internal Error: Could not obtain handle for real recv\n");
364 FD_SET(sockfd, &readfds);
369 retval = __recv(sockfd,
buf, len, flags);
382 if ((EAGAIN ==
errno) || (EWOULDBLOCK ==
errno))
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) {
393 SUBDBG(
"appio: intercepted fwrite(%p,%lu,%lu,%p)\n", ptr, (
unsigned long) size, (
unsigned long) nmemb, (
void*) stream);
420 SUBDBG(
"_appio_init_thread %p\n", ctx);
439 PAPIERROR(
"malloc():Could not get memory for events table" );
485 SUBDBG(
"_appio_start %p %p\n", ctx, ctl);
500 long long **
events,
int flags )
505 SUBDBG(
"_appio_read %p %p\n", ctx, ctl);
525 SUBDBG(
"_appio_stop ctx=%p ctl=%p\n", ctx, ctl);
584 SUBDBG(
"_appio_update_control_state ctx=%p ctl=%p num_events=%d\n", ctx, ctl,
count);
644 switch ( modifier ) {
653 *EventCode = *EventCode + 1;
693 int index = EventCode;
710 int index = EventCode;
727 int index = EventCode;
747 .short_name =
"appio",
748 .version =
"1.1.2.4",
759 .fast_real_timer = 0,
760 .fast_virtual_timer = 0,
762 .attach_must_ptrace = 0,
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
static int _appio_ntv_code_to_bits(unsigned int EventCode, hwd_register_t *bits)
ssize_t __read(int fd, void *buf, size_t count)
static __thread long long _appio_register_current[APPIO_MAX_COUNTERS]
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
static const struct appio_counters _appio_counter_info[APPIO_MAX_COUNTERS]
static int _appio_reset(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_ntv_code_to_descr(unsigned int EventCode, char *desc, int len)
static APPIO_native_event_entry_t * _appio_native_events
static int _appio_ntv_name_to_code(const char *name, unsigned int *EventCode)
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)
static int _appio_ntv_enum_events(unsigned int *EventCode, int modifier)
off_t __lseek(int fd, off_t offset, int whence)
static int _appio_shutdown_component(void)
static int _appio_set_domain(hwd_control_state_t *ctl, int domain)
static int _appio_ntv_code_to_name(unsigned int EventCode, char *name, int len)
size_t _IO_fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
static int _appio_init_component(int cidx)
off_t lseek(int fd, off_t offset, int whence)
papi_vector_t _appio_vector
static int _appio_stop(hwd_context_t *ctx, hwd_control_state_t *ctl)
ssize_t __write(int fd, const void *buf, size_t count)
static int _appio_shutdown_thread(hwd_context_t *ctx)
static int _appio_init_control_state(hwd_control_state_t *ctl)
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)
static int _appio_ctl(hwd_context_t *ctx, int code, _papi_int_option_t *option)
ssize_t write(int fd, const void *buf, size_t count)
int __open(const char *pathname, int flags, mode_t mode)
static int _appio_init_thread(hwd_context_t *ctx)
static int _appio_update_control_state(hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
ssize_t read(int fd, void *buf, size_t count)
#define HANDLE_STRING_ERROR
appio component This file contains the source code for a component that enables PAPI to access applic...
#define APPIO_MAX_COUNTERS
get real time counter value in microseconds
struct papi_vectors * _papi_hwd[]
volatile int buf[CACHE_FLUSH_BUFFER_SIZE_INTS]
long long PAPI_get_real_usec(void)
char events[MAX_EVENTS][BUFSIZ]
Return codes and api definitions.
#define SUBDBG(format, args...)
void PAPIERROR(char *format,...)
#define papi_calloc(a, b)
int counter_bits[APPIO_MAX_COUNTERS]
long long values[APPIO_MAX_COUNTERS]
APPIO_register_t resources
char name[PAPI_MAX_STR_LEN]
char disabled_reason[PAPI_HUGE_STR_LEN]
PAPI_component_info_t cmp_info