1PAPI_read(3) PAPI PAPI_read(3)
2
3
4
6 PAPI_read - read hardware counters from an event set
7
8 PAPI_accum - accumulate and reset counters in an event set
9
10
12 C Interface
13 #include <papi.h>
14 int PAPI_read(int EventSet, long_long *values);
15 int PAPI_accum(int EventSet, long_long *values);
16 Fortran Interface
17 #include fpapi.h
18 PAPIF_read(C_INT EventSet, C_LONG_LONG(*) values, C_INT check)
19 PAPIF_accum(C_INT EventSet, C_LONG_LONG(*) values, C_INT check)
20
21
23 These calls assume an initialized PAPI library and a properly added
24 event set.
25
26 PAPI_read() copies the counters of the indicated event set into the
27 array values. The counters continue counting after the read.
28
29 PAPI_accum() adds the counters of the indicated event set into the
30 array values. The counters are zeroed and continue counting after the
31 operation.
32
33 Note the differences between PAPI_read() and PAPI_accum(), specifically
34 that PAPI_accum() resets the values array to zero.
35
36
37
39 EventSet -- an integer handle for a PAPI Event Set as created by
40 PAPI_create_eventset(3)
41
42 *values -- an array to hold the counter values of the counting events
43
44
46 On success, these functions return PAPI_OK.
47 On error, a non-zero error code is returned.
48
49
51 PAPI_EINVAL
52 One or more of the arguments is invalid.
53
54 PAPI_ESYS
55 A system or C library call failed inside PAPI, see the errno
56 variable.
57
58 PAPI_ENOEVST
59 The event set specified does not exist.
60
61
63 do_100events();
64 if (PAPI_read(EventSet, values) != PAPI_OK)
65 handle_error(1);
66 /* values[0] now equals 100 */
67 do_100events();
68 if (PAPI_accum(EventSet, values) != PAPI_OK)
69 handle_error(1);
70 /* values[0] now equals 200 */
71 values[0] = -100;
72 do_100events();
73 if (PAPI_accum(EventSet, values) != PAPI_OK)
74 handle_error(1);
75 /* values[0] now equals 0 */
76
77
79 These functions have no known bugs.
80
81
83 PAPI_set_opt(3), PAPI_reset(3), PAPI_start(3), PAPI(3), PAPIF(3)
84
85
86
87PAPI Programmer's Reference September, 2004 PAPI_read(3)