appio_test_seek.c File Reference

Include dependency graph for appio_test_seek.c:

Go to the source code of this file.

Defines

#define NUM_EVENTS   7

Functions

int main (int argc, char **argv)

Define Documentation

#define NUM_EVENTS   7

Definition at line 20 of file appio_test_seek.c.


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 22 of file appio_test_seek.c.

00022                                 {
00023   int Events[NUM_EVENTS]; 
00024   const char* names[NUM_EVENTS] = {"READ_CALLS", "READ_BYTES", "READ_BLOCK_SIZE", "READ_USEC", "SEEK_CALLS", "SEEK_USEC", "SEEK_ABS_STRIDE_SIZE"};
00025   long long values[NUM_EVENTS];
00026 
00027   char *infile = "/etc/group";
00028 
00029   /* Set TESTS_QUIET variable */
00030   tests_quiet( argc, argv );
00031 
00032   int version = PAPI_library_init (PAPI_VER_CURRENT);
00033   if (version != PAPI_VER_CURRENT) {
00034     fprintf(stderr, "PAPI_library_init version mismatch\n");
00035     exit(1);
00036   }
00037 
00038   int fdin;
00039   if (!TESTS_QUIET) printf("This program will do a strided read %s and write it to stdout\n", infile);
00040   int retval;
00041   int e;
00042   for (e=0; e<NUM_EVENTS; e++) {
00043     retval = PAPI_event_name_to_code((char*)names[e], &Events[e]);
00044     if (retval != PAPI_OK) {
00045       fprintf(stderr, "Error getting code for %s\n", names[e]);
00046       exit(2);
00047     } 
00048   }
00049 
00050   /* Start counting events */
00051   if (PAPI_start_counters(Events, NUM_EVENTS) != PAPI_OK) {
00052     fprintf(stderr, "Error in PAPI_start_counters\n");
00053     exit(1);
00054   }
00055 
00056   fdin=open(infile, O_RDONLY);
00057   if (fdin < 0) perror("Could not open file for reading: \n");
00058   int bytes = 0;
00059   char buf[1024];
00060 
00061  
00062 //if (PAPI_read_counters(values, NUM_EVENTS) != PAPI_OK)
00063 //   handle_error(1);
00064 //printf("After reading the counters: %lld\n",values[0]);
00065 
00066   while ((bytes = read(fdin, buf, 32)) > 0) {
00067     write(1, buf, bytes);
00068     lseek(fdin, 16, SEEK_CUR);
00069   }
00070 
00071   /* Closing the descriptors before doing the PAPI_stop
00072      means, OPEN_FDS will be reported as zero, which is
00073      right, since at the time of PAPI_stop, the descriptors
00074      we opened have been closed */
00075   close (fdin);
00076 
00077   /* Stop counting events */
00078   if (PAPI_stop_counters(values, NUM_EVENTS) != PAPI_OK) {
00079     fprintf(stderr, "Error in PAPI_stop_counters\n");
00080   }
00081  
00082   if (!TESTS_QUIET) { 
00083     printf("----\n");
00084     for (e=0; e<NUM_EVENTS; e++)  
00085       printf("%s: %lld\n", names[e], values[e]);
00086   }
00087   test_pass( __FILE__, NULL, 0 );
00088   return 0;
00089 }

Here is the call graph for this function:


Generated on 26 Jan 2016 for PAPI by  doxygen 1.6.1