PAPI 7.1.0.0
Loading...
Searching...
No Matches
appio_test_blocking.c File Reference
Include dependency graph for appio_test_blocking.c:

Go to the source code of this file.

Macros

#define NUM_EVENTS   12
 

Functions

int main (int argc, char **argv)
 

Macro Definition Documentation

◆ NUM_EVENTS

#define NUM_EVENTS   12

Definition at line 22 of file appio_test_blocking.c.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 24 of file appio_test_blocking.c.

24 {
25 int EventSet = PAPI_NULL;
26 const char* names[NUM_EVENTS] = {"OPEN_CALLS", "OPEN_FDS", "READ_CALLS", "READ_BYTES", "READ_USEC", "READ_ERR", "READ_INTERRUPTED", "READ_WOULD_BLOCK", "WRITE_CALLS","WRITE_BYTES","WRITE_USEC", "WRITE_WOULD_BLOCK"};
27 long long values[NUM_EVENTS];
28
29 /* Set TESTS_QUIET variable */
30 tests_quiet( argc, argv );
31
34 fprintf(stderr, "PAPI_library_init version mismatch\n");
35 exit(1);
36 }
37
38 /* Create the Event Set */
40 fprintf(stderr, "Error creating event set\n");
41 exit(2);
42 }
43
44 if (!TESTS_QUIET) fprintf(stderr, "This program will read from stdin and echo it to stdout\n");
45 int retval;
46 int e;
47 int event_code;
48 for (e=0; e<NUM_EVENTS; e++) {
49 retval = PAPI_event_name_to_code((char*)names[e], &event_code);
50 if (retval != PAPI_OK) {
51 fprintf(stderr, "Error getting code for %s\n", names[e]);
52 exit(2);
53 }
54 retval = PAPI_add_event(EventSet, event_code);
55 if (retval != PAPI_OK) {
56 fprintf(stderr, "Error adding %s to event set\n", names[e]);
57 exit(2);
58 }
59 }
60
61 /* Start counting events */
62 if (PAPI_start(EventSet) != PAPI_OK) {
63 fprintf(stderr, "Error in PAPI_start\n");
64 exit(1);
65 }
66
67 int bytes = 0;
68 char buf[1024];
69
70
71//if (PAPI_read(EventSet, values) != PAPI_OK)
72// handle_error(1);
73//printf("After reading the counters: %lld\n",values[0]);
74
75 while ((bytes = read(0, buf, 1024)) > 0) {
76 write(1, buf, bytes);
77 }
78
79
80 /* Stop counting events */
82 fprintf(stderr, "Error in PAPI_stop\n");
83 }
84
85 if (!TESTS_QUIET) {
86 printf("----\n");
87 for (e=0; e<NUM_EVENTS; e++)
88 printf("%s: %lld\n", names[e], values[e]);
89 }
90 test_pass( __FILE__ );
91 return 0;
92}
ssize_t write(int fd, const void *buf, size_t count)
Definition: appio.c:302
ssize_t read(int fd, void *buf, size_t count)
Definition: appio.c:229
#define NUM_EVENTS
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.
initialize the PAPI library.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
volatile int buf[CACHE_FLUSH_BUFFER_SIZE_INTS]
Definition: do_loops.c:12
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
static int EventSet
Definition: init_fini.c:8
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
uint8_t version
int TESTS_QUIET
Definition: test_utils.c:18
FILE * stderr
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
int retval
Definition: zero_fork.c:53
Here is the call graph for this function: