appio_test_select.c File Reference

Include dependency graph for appio_test_select.c:

Go to the source code of this file.

Defines

#define NUM_EVENTS   1

Functions

int main (int argc, char **argv)

Define Documentation

#define NUM_EVENTS   1

Definition at line 21 of file appio_test_select.c.


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 23 of file appio_test_select.c.

00023                                 {
00024   int Events[NUM_EVENTS]; 
00025   const char* names[NUM_EVENTS] = {"SELECT_USEC"};
00026   long long values[NUM_EVENTS];
00027 
00028   /* Set TESTS_QUIET variable */
00029   tests_quiet( argc, argv );
00030 
00031   int version = PAPI_library_init (PAPI_VER_CURRENT);
00032   if (version != PAPI_VER_CURRENT) {
00033     fprintf(stderr, "PAPI_library_init version mismatch\n");
00034     exit(1);
00035   }
00036 
00037   if (!TESTS_QUIET) printf("This program will read from stdin and echo it to stdout\n");
00038   int retval;
00039   int e;
00040   for (e=0; e<NUM_EVENTS; e++) {
00041     retval = PAPI_event_name_to_code((char*)names[e], &Events[e]);
00042     if (retval != PAPI_OK) {
00043       fprintf(stderr, "Error getting code for %s\n", names[e]);
00044       exit(2);
00045     } 
00046   }
00047 
00048   /* Start counting events */
00049   if (PAPI_start_counters(Events, NUM_EVENTS) != PAPI_OK) {
00050     fprintf(stderr, "Error in PAPI_start_counters\n");
00051     exit(1);
00052   }
00053 
00054   int bytes = 0;
00055   char buf[1024];
00056 
00057  
00058 //if (PAPI_read_counters(values, NUM_EVENTS) != PAPI_OK)
00059 //   handle_error(1);
00060 //printf("After reading the counters: %lld\n",values[0]);
00061 
00062   int fdready;
00063   fd_set readfds;
00064   FD_SET(0,&readfds);
00065  
00066   while (select(1,&readfds,NULL,NULL,NULL)) {
00067     bytes = read(0, buf, 1024);
00068     if (bytes > 0) write(1, buf, bytes);
00069     if (bytes == 0) break;
00070   }
00071 
00072 
00073   /* Stop counting events */
00074   if (PAPI_stop_counters(values, NUM_EVENTS) != PAPI_OK) {
00075     fprintf(stderr, "Error in PAPI_stop_counters\n");
00076   }
00077  
00078   if (!TESTS_QUIET) { 
00079     printf("----\n");
00080     for (e=0; e<NUM_EVENTS; e++)  
00081       printf("%s: %lld\n", names[e], values[e]);
00082   }
00083   test_pass( __FILE__, NULL, 0 );
00084   return 0;
00085 }

Here is the call graph for this function:


Generated on 26 Jan 2016 for PAPI by  doxygen 1.6.1