1PAPI_set_granularity(3) PAPI PAPI_set_granularity(3)
2
3
4
6 PAPI_set_granularity - set the default counting granularity for
7 eventsets bound to the cpu component
8 PAPI_set_cmp_granularity - set the default counting granularity for
9 eventsets bound to the specified component
10
11
13 C Interface
14 #include <papi.h>
15 int PAPI_set_granularity(int granularity);
16 int PAPI_set_cmp_granularity(int granularity",int cidx );
17 Fortran Interface
18 #include fpapi.h
19 PAPIF_set_granularity(C_INT granularity, C_INT check)
20
21
23 PAPI_set_granularity sets the default counting granularity for all new
24 event sets created by PAPI_create_eventset(3). This call implicitly
25 sets the granularity for the cpu component (component 0) and is
26 included to preserve backward compatibility.
27
28 PAPI_set_cmp_granularity sets the default counting granularity for all
29 new event sets,
30 and requires an explicit component argument.
31 Event sets that are already in existence are not affected. To change
32 the granularity of an existing event set, please see the
33 PAPI_set_opt(3) man page. The reader should note that the granularity
34 of an event set affects only the mode in which the counter continues to
35 run.
36
37
39 cidx -- An integer identifier for a component. By convention, component
40 0 is always the cpu component.
41
42 granularity -- one of the following constants as defined in the papi.h
43 header file:
44
45
46 ┌─────────────────┬──────────────────────────────────────┐
47 │PAPI_GRN_THR │ Count each individual thread │
48 ├─────────────────┼──────────────────────────────────────┤
49 │PAPI_GRN_PROC │ Count each individual process │
50 ├─────────────────┼──────────────────────────────────────┤
51 │PAPI_GRN_PROCG │ Count each individual process group │
52 ├─────────────────┼──────────────────────────────────────┤
53 │PAPI_GRN_SYS │ Count the current CPU │
54 ├─────────────────┼──────────────────────────────────────┤
55 │PAPI_GRN_SYS_CPU │ Count all CPU's individually │
56 ├─────────────────┼──────────────────────────────────────┤
57 │PAPI_GRN_MIN │ The finest available granularity │
58 ├─────────────────┼──────────────────────────────────────┤
59 │PAPI_GRN_MAX │ The coarsest available granularity │
60 └─────────────────┴──────────────────────────────────────┘
61
63 On success, this function returns PAPI_OK.
64 On error, a non-zero error code is returned.
65
66
68 PAPI_EINVAL
69 One or more of the arguments is invalid.
70
71 PAPI_ENOEVST
72 The event set specified does not exist.
73
74 PAPI_ENOCMP
75 The argument cidx is not a valid component.
76
77 PAPI_EISRUN
78 The event set is currently counting events.
79
80
82 int retval;
83
84 /* Initialize the library */
85
86 retval = PAPI_library_init(PAPI_VER_CURRENT);
87
88 if (retval > 0 && retval != PAPI_VER_CURRENT) {
89 fprintf(stderr,"PAPI library version mismatch!0);
90 exit(1); }
91
92 if (retval < 0)
93 handle_error(retval);
94
95 /* Set the default granularity for the cpu component */
96
97 if ((retval = PAPI_set_cmp_granularity(PAPI_GRN_PROC,0)) != PAPI_OK)
98 handle_error(retval);
99
100 if ((retval = PAPI_create_eventset(&EventSet)) != PAPI_OK)
101 handle_error(retval);
102
103
105 This function has no known bugs.
106
107
109 PAPI_set_domain(3), PAPI_set_opt(3), PAPI_get_opt(3)
110
111
112
113PAPI Programmer's Reference April, 2007 PAPI_set_granularity(3)