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

Go to the source code of this file.

Macros

#define NUM_EVENTS   7
 

Functions

int main (int argc, char **argv)
 

Macro Definition 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.

22  {
23  int Events[NUM_EVENTS];
24  const char* names[NUM_EVENTS] = {"READ_CALLS", "READ_BYTES", "READ_BLOCK_SIZE", "READ_USEC", "SEEK_CALLS", "SEEK_USEC", "SEEK_ABS_STRIDE_SIZE"};
25  long long values[NUM_EVENTS];
26 
27  char *infile = "/etc/group";
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  int fdin;
39  if (!TESTS_QUIET) printf("This program will do a strided read %s and write it to stdout\n", infile);
40  int retval;
41  int e;
42  for (e=0; e<NUM_EVENTS; e++) {
43  retval = PAPI_event_name_to_code((char*)names[e], &Events[e]);
44  if (retval != PAPI_OK) {
45  fprintf(stderr, "Error getting code for %s\n", names[e]);
46  exit(2);
47  }
48  }
49 
50  /* Start counting events */
51  if (PAPI_start_counters(Events, NUM_EVENTS) != PAPI_OK) {
52  fprintf(stderr, "Error in PAPI_start_counters\n");
53  exit(1);
54  }
55 
56  fdin=open(infile, O_RDONLY);
57  if (fdin < 0) perror("Could not open file for reading: \n");
58  int bytes = 0;
59  char buf[1024];
60 
61 
62 //if (PAPI_read_counters(values, NUM_EVENTS) != PAPI_OK)
63 // handle_error(1);
64 //printf("After reading the counters: %lld\n",values[0]);
65 
66  while ((bytes = read(fdin, buf, 32)) > 0) {
67  write(1, buf, bytes);
68  lseek(fdin, 16, SEEK_CUR);
69  }
70 
71  /* Closing the descriptors before doing the PAPI_stop
72  means, OPEN_FDS will be reported as zero, which is
73  right, since at the time of PAPI_stop, the descriptors
74  we opened have been closed */
75  close (fdin);
76 
77  /* Stop counting events */
78  if (PAPI_stop_counters(values, NUM_EVENTS) != PAPI_OK) {
79  fprintf(stderr, "Error in PAPI_stop_counters\n");
80  }
81 
82  if (!TESTS_QUIET) {
83  printf("----\n");
84  for (e=0; e<NUM_EVENTS; e++)
85  printf("%s: %lld\n", names[e], values[e]);
86  }
87  test_pass( __FILE__, NULL, 0 );
88  return 0;
89 }
ssize_t read(int fd, void *buf, size_t count)
Definition: appio.c:225
int close(int fd)
Definition: appio.c:175
static int Events[NUM_EVENTS]
Definition: init_fini.c:8
off_t lseek(int fd, off_t offset, int whence)
Definition: appio.c:210
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
int TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
int open(const char *pathname, int flags, mode_t mode)
Definition: appio.c:184
int PAPI_library_init(int version)
Definition: papi.c:495
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
#define NUM_EVENTS
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
char version[]
Definition: fileop.c:134
int PAPI_event_name_to_code(char *in, int *out)
Definition: papi.c:1008
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
const char * names[NUM_EVENTS]
void exit()

Here is the call graph for this function: