33 #include <sys/select.h> 34 #include <sys/types.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"}
177 SUBDBG(
"appio: intercepted close(%d)\n",
fd);
183 int __open(
const char *pathname,
int flags, mode_t mode);
184 int open(
const char *pathname,
int flags, mode_t mode) {
186 SUBDBG(
"appio: intercepted open(%s,%d,%d)\n", pathname, flags, mode);
201 SUBDBG(
"appio: intercepted select(%d,%p,%p,%p,%p)\n", nfds,readfds,writefds,exceptfds,timeout);
212 SUBDBG(
"appio: intercepted lseek(%d,%ld,%d)\n",
fd,
offset, whence);
227 SUBDBG(
"appio: intercepted read(%d,%p,%lu)\n",
fd,
buf, (
unsigned long)
count);
231 if (fstat(
fd, &st) == 0) {
232 if ((st.st_mode & S_IFMT) == S_IFSOCK) issocket = 1;
237 FD_SET(
fd, &readfds);
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) {
277 SUBDBG(
"appio: intercepted fread(%p,%lu,%lu,%p)\n", ptr, (
unsigned long) size, (
unsigned long) nmemb, (
void*) stream);
300 SUBDBG(
"appio: intercepted write(%d,%p,%lu)\n",
fd,
buf, (
unsigned long)
count);
303 if (fstat(
fd, &st) == 0) {
304 if ((st.st_mode & S_IFMT) == S_IFSOCK) issocket = 1;
310 FD_SET(
fd, &writefds);
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) {
351 SUBDBG(
"appio: intercepted recv(%d,%p,%lu,%d)\n", sockfd,
buf, (
unsigned long)len, flags);
352 if (!__recv) __recv = dlsym(RTLD_NEXT,
"recv");
354 fprintf(stderr,
"appio,c Internal Error: Could not obtain handle for real recv\n");
360 FD_SET(sockfd, &readfds);
365 retval = __recv(sockfd,
buf, len, flags);
378 if ((EAGAIN ==
errno) || (EWOULDBLOCK ==
errno))
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) {
389 SUBDBG(
"appio: intercepted fwrite(%p,%lu,%lu,%p)\n", ptr, (
unsigned long) size, (
unsigned long) nmemb, (
void*) stream);
416 SUBDBG(
"_appio_init_thread %p\n", ctx);
433 PAPIERROR(
"malloc():Could not get memory for events table" );
471 SUBDBG(
"_appio_start %p %p\n", ctx, ctl);
486 long long **
events,
int flags )
491 SUBDBG(
"_appio_read %p %p\n", ctx, ctl);
511 SUBDBG(
"_appio_stop ctx=%p ctl=%p\n", ctx, ctl);
570 SUBDBG(
"_appio_update_control_state ctx=%p ctl=%p num_events=%d\n", ctx, ctl,
count);
630 switch ( modifier ) {
639 *EventCode = *EventCode + 1;
679 int index = EventCode;
696 int index = EventCode;
713 int index = EventCode;
733 .short_name =
"appio",
734 .version =
"1.1.2.4",
745 .fast_real_timer = 0,
746 .fast_virtual_timer = 0,
748 .attach_must_ptrace = 0,
#define APPIO_MAX_COUNTERS
ssize_t read(int fd, void *buf, size_t count)
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)
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
int __open(const char *pathname, int flags, mode_t mode)
off_t __lseek(int fd, off_t offset, int whence)
size_t _IO_fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
static APPIO_native_event_entry_t * _appio_native_events
off_t lseek(int fd, off_t offset, int whence)
static int _appio_ntv_code_to_descr(unsigned int EventCode, char *desc, int len)
static int _appio_stop(hwd_context_t *ctx, hwd_control_state_t *ctl)
static int _appio_init_control_state(hwd_control_state_t *ctl)
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
static int _appio_shutdown_component(void)
PAPI_component_info_t cmp_info
Return codes and api definitions.
APPIO_register_t resources
ssize_t __read(int fd, void *buf, size_t count)
static int _appio_ntv_code_to_bits(unsigned int EventCode, hwd_register_t *bits)
char events[MAX_EVENTS][BUFSIZ]
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)
ssize_t write(int fd, const void *buf, size_t count)
long long values[APPIO_MAX_COUNTERS]
static int _appio_ntv_name_to_code(const char *name, unsigned int *EventCode)
static int _appio_set_domain(hwd_control_state_t *ctl, int domain)
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_ntv_enum_events(unsigned int *EventCode, int modifier)
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
static int _appio_reset(hwd_context_t *ctx, hwd_control_state_t *ctl)
#define SUBDBG(format, args...)
void PAPIERROR(char *format,...)
appio component This file contains the source code for a component that enables PAPI to access applic...
char name[PAPI_MAX_STR_LEN]
static const struct appio_counters _appio_counter_info[APPIO_MAX_COUNTERS]
static __thread long long _appio_register_current[APPIO_MAX_COUNTERS]
static int _appio_shutdown_thread(hwd_context_t *ctx)
long long PAPI_get_real_usec(void)
static int _appio_read(hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags)
static int _appio_init_component(int cidx)
static int _appio_ntv_code_to_name(unsigned int EventCode, char *name, int len)
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)
volatile int buf[CACHE_FLUSH_BUFFER_SIZE_INTS]
int counter_bits[APPIO_MAX_COUNTERS]
papi_vector_t _appio_vector
#define papi_calloc(a, b)