PAPI  5.0.1.0
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.

                                {
  int Events[NUM_EVENTS]; 
  const char* names[NUM_EVENTS] = {"SELECT_USEC"};
  long long values[NUM_EVENTS];

  /* Set TESTS_QUIET variable */
  tests_quiet( argc, argv );

  int version = PAPI_library_init (PAPI_VER_CURRENT);
  if (version != PAPI_VER_CURRENT) {
    fprintf(stderr, "PAPI_library_init version mismatch\n");
    exit(1);
  }

  if (!TESTS_QUIET) printf("This program will read from stdin and echo it to stdout\n");
  int retval;
  int e;
  for (e=0; e<NUM_EVENTS; e++) {
    retval = PAPI_event_name_to_code((char*)names[e], &Events[e]);
    if (retval != PAPI_OK) {
      fprintf(stderr, "Error getting code for %s\n", names[e]);
      exit(2);
    } 
  }

  /* Start counting events */
  if (PAPI_start_counters(Events, NUM_EVENTS) != PAPI_OK) {
    fprintf(stderr, "Error in PAPI_start_counters\n");
    exit(1);
  }

  int bytes = 0;
  char buf[1024];

 
//if (PAPI_read_counters(values, NUM_EVENTS) != PAPI_OK)
//   handle_error(1);
//printf("After reading the counters: %lld\n",values[0]);

  int fdready;
  fd_set readfds;
  FD_SET(0,&readfds);
 
  while (select(1,&readfds,NULL,NULL,NULL)) {
    bytes = read(0, buf, 1024);
    if (bytes > 0) write(1, buf, bytes);
    if (bytes == 0) break;
  }


  /* Stop counting events */
  if (PAPI_stop_counters(values, NUM_EVENTS) != PAPI_OK) {
    fprintf(stderr, "Error in PAPI_stop_counters\n");
  }
 
  if (!TESTS_QUIET) { 
    printf("----\n");
    for (e=0; e<NUM_EVENTS; e++)  
      printf("%s: %lld\n", names[e], values[e]);
  }
  test_pass( __FILE__, NULL, 0 );
  return 0;
}

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines