Go to the source code of this file.
|
const char * | names [NUM_EVENTS] = {"READ_CALLS", "READ_BYTES","READ_USEC","WRITE_CALLS","WRITE_BYTES","WRITE_USEC"} |
|
static const char * | files [NUM_INFILES] = {"/etc/passwd", "/etc/group", "/etc/protocols", "/etc/nsswitch.conf"} |
|
◆ NUM_EVENTS
◆ NUM_INFILES
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 93 of file appio_test_pthreads.c.
93 {
98
99
101
104 fprintf(
stderr,
"PAPI_library_init version mismatch\n");
105 exit(1);
106 }
107
108
109 pthread_attr_init(&attr);
111 fprintf(
stderr,
"PAPI_thread_init returned an error\n");
112 exit(1);
113 }
114#ifdef PTHREAD_CREATE_UNDETACHED
115 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_UNDETACHED);
116#endif
117#ifdef PTHREAD_SCOPE_SYSTEM
118 retval = pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
120 fprintf(
stderr,
"This system does not support kernel scheduled pthreads.\n");
121 exit(1);
122 }
123#endif
124
128
130 for (
i=0;
i<(numthrds-1);
i++) {
132 if (
rc != 0) perror(
"Error creating thread using pthread_create()");
133 }
135 pthread_attr_destroy(&attr);
136
137 for (
i=0;
i<(numthrds-1);
i++)
138 pthread_join(callThd[
i], NULL);
139
141 return 0;
142}
static const char * files[NUM_INFILES]
void * ThreadIO(void *arg)
initialize the PAPI library.
Initialize thread support in the PAPI library.
unsigned long int pthread_t
int tests_quiet(int argc, char **argv)
void PAPI_NORETURN test_pass(const char *filename)
◆ ThreadIO()
void * ThreadIO |
( |
void * |
arg | ) |
|
Definition at line 30 of file appio_test_pthreads.c.
30 {
31 unsigned long tid = (
unsigned long)pthread_self();
32 if (!
TESTS_QUIET) printf(
"\nThread %#lx: will read %s and write it to /dev/null\n", tid,(
const char*) arg);
36 int e;
37 int event_code;
38
39
41 fprintf(
stderr,
"Error creating event set\n");
42 exit(2);
43 }
44
48 fprintf(
stderr,
"Error getting code for %s\n",
names[e]);
49 exit(2);
50 }
53 fprintf(
stderr,
"Error adding %s to event set\n",
names[e]);
54 exit(2);
55 }
56 }
57
58
60 fprintf(
stderr,
"Error in PAPI_start\n");
61 exit(1);
62 }
63
64
65
66
67
68 int fdin =
open((
const char*)arg, O_RDONLY);
69 if (fdin < 0) perror("Could not open file for reading: \n");
70
71 int bytes = 0;
73
74 int fdout =
open(
"/dev/null", O_WRONLY);
75 if (fdout < 0) perror("Could not open /dev/null for writing: \n");
76 while ((bytes =
read(fdin,
buf, 1024)) > 0) {
78 }
80
81
83 fprintf(
stderr,
"Error in PAPI_stop\n");
84 }
85
88 printf(
"Thread %#lx: %s: %lld\n", tid,
names[e],
values[e]);
89 }
90 return(NULL);
91}
int open(const char *pathname, int flags, mode_t mode)
ssize_t write(int fd, const void *buf, size_t count)
ssize_t read(int fd, void *buf, size_t count)
const char * names[NUM_EVENTS]
add PAPI preset or native hardware event to an event set
Create a new empty PAPI EventSet.
Convert a name to a numeric hardware event code.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
volatile int buf[CACHE_FLUSH_BUFFER_SIZE_INTS]
static long long values[NUM_EVENTS]
◆ files
const char* files[NUM_INFILES] = {"/etc/passwd", "/etc/group", "/etc/protocols", "/etc/nsswitch.conf"} |
|
static |
◆ names
const char* names[NUM_EVENTS] = {"READ_CALLS", "READ_BYTES","READ_USEC","WRITE_CALLS","WRITE_BYTES","WRITE_USEC"} |