PAPI  5.6.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
appio_test_select.c File Reference
Include dependency graph for appio_test_select.c:

Go to the source code of this file.

Macros

#define NUM_EVENTS   1
 

Functions

int main (int argc, char **argv)
 

Macro Definition Documentation

#define NUM_EVENTS   1

Definition at line 22 of file appio_test_select.c.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 24 of file appio_test_select.c.

24  {
25  int Events[NUM_EVENTS];
26  const char* names[NUM_EVENTS] = {"SELECT_USEC"};
27  long long values[NUM_EVENTS];
28 
29  /* Set TESTS_QUIET variable */
30  tests_quiet( argc, argv );
31 
33  if (version != PAPI_VER_CURRENT) {
34  fprintf(stderr, "PAPI_library_init version mismatch\n");
35  exit(1);
36  }
37 
38  if (!TESTS_QUIET) printf("This program will read from stdin and echo it to stdout\n");
39  int retval;
40  int e;
41  for (e=0; e<NUM_EVENTS; e++) {
42  retval = PAPI_event_name_to_code((char*)names[e], &Events[e]);
43  if (retval != PAPI_OK) {
44  fprintf(stderr, "Error getting code for %s\n", names[e]);
45  exit(2);
46  }
47  }
48 
49  /* Start counting events */
50  if (PAPI_start_counters(Events, NUM_EVENTS) != PAPI_OK) {
51  fprintf(stderr, "Error in PAPI_start_counters\n");
52  exit(1);
53  }
54 
55  int bytes = 0;
56  char buf[1024];
57 
58 
59 //if (PAPI_read_counters(values, NUM_EVENTS) != PAPI_OK)
60 // handle_error(1);
61 //printf("After reading the counters: %lld\n",values[0]);
62 
63  int fdready;
64  fd_set readfds;
65  FD_SET(0,&readfds);
66 
67  while (select(1,&readfds,NULL,NULL,NULL)) {
68  bytes = read(0, buf, 1024);
69  if (bytes > 0) write(1, buf, bytes);
70  if (bytes == 0) break;
71  }
72 
73 
74  /* Stop counting events */
75  if (PAPI_stop_counters(values, NUM_EVENTS) != PAPI_OK) {
76  fprintf(stderr, "Error in PAPI_stop_counters\n");
77  }
78 
79  if (!TESTS_QUIET) {
80  printf("----\n");
81  for (e=0; e<NUM_EVENTS; e++)
82  printf("%s: %lld\n", names[e], values[e]);
83  }
84  test_pass( __FILE__ );
85  return 0;
86 }
ssize_t read(int fd, void *buf, size_t count)
Definition: appio.c:225
void test_pass(const char *filename)
Definition: test_utils.c:432
static int Events[NUM_EVENTS]
Definition: init_fini.c:8
return PAPI_OK
Definition: linux-nvml.c:497
int PAPI_event_name_to_code(const char *in, int *out)
Definition: papi.c:1004
int int argc
Definition: iozone.c:1609
#define NUM_EVENTS
char ** argv
Definition: iozone.c:1610
int PAPI_library_init(int version)
Definition: papi.c:500
char buf[200]
Definition: iozone.c:19609
ssize_t write(int fd, const void *buf, size_t count)
Definition: appio.c:298
int PAPI_stop_counters(long long *values, int array_len)
Definition: papi_hl.c:803
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
Definition: appio.c:199
char version[]
Definition: fileop.c:134
printf("\tTry: -i 0 -i 1 \n\n")
int TESTS_QUIET
Definition: test_utils.c:18
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
int PAPI_start_counters(int *events, int array_len)
Definition: papi_hl.c:593
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:225
const char * names[NUM_EVENTS]
void exit()

Here is the call graph for this function: