/* * Test case for appio * Author: Tushar Mohan * tusharmohan@gmail.com * * Description: This test case reads from standard linux /etc files in * four separate threads and copies the output to /dev/null * READ and WRITE statistics for each of the threads is * summarized at the end. */ #include #include #include #include #include #include #include #include #include #include "papi.h" #include "papi_test.h" #define NUM_EVENTS 6 const char* names[NUM_EVENTS] = {"READ_CALLS", "READ_BYTES","READ_USEC","WRITE_CALLS","WRITE_BYTES","WRITE_USEC"}; #define NUM_INFILES 4 static const char* files[NUM_INFILES] = {"/etc/passwd", "/etc/group", "/etc/protocols", "/etc/nsswitch.conf"}; void *ThreadIO(void *arg) { unsigned long tid = (unsigned long)pthread_self(); if (!TESTS_QUIET) printf("\nThread %#lx: will read %s and write it to /dev/null\n", tid,(const char*) arg); int Events[NUM_EVENTS]; long long values[NUM_EVENTS]; int retval; int e; for (e=0; e 0) { write(fdout, buf, bytes); } close(fdout); /* Stop counting events */ if (PAPI_stop_counters(values, NUM_EVENTS) != PAPI_OK) { fprintf(stderr, "Error in PAPI_stop_counters\n"); } if (!TESTS_QUIET) { for (e=0; e