PAPI 7.1.0.0
Loading...
Searching...
No Matches
components/template/tests/simple.c File Reference
Include dependency graph for components/template/tests/simple.c:

Go to the source code of this file.

Macros

#define NUM_EVENTS   (4)
 

Functions

int main (int argc, char *argv[])
 

Variables

int quiet
 

Macro Definition Documentation

◆ NUM_EVENTS

#define NUM_EVENTS   (4)

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 7 of file components/template/tests/simple.c.

8{
9 int papi_errno;
10
11 quiet = tests_quiet(argc, argv);
12
14 if (papi_errno != PAPI_VER_CURRENT) {
15 test_fail(__FILE__, __LINE__, "PAPI_library_init", papi_errno);
16 }
17
18#define NUM_EVENTS (4)
19 const char *events[NUM_EVENTS] = {
20 "templ:::TEMPLATE_ZERO:device=0",
21 "templ:::TEMPLATE_CONSTANT:device=1",
22 "templ:::TEMPLATE_FUNCTION:device=2:function=exp",
23 "templ:::TEMPLATE_FUNCTION:device=3:function=sum",
24 };
25
26 int eventset = PAPI_NULL;
27 papi_errno = PAPI_create_eventset(&eventset);
28 if (papi_errno != PAPI_OK) {
29 test_fail(__FILE__, __LINE__, "PAPI_create_eventset", papi_errno);
30 }
31
32 for (int i = 0; i < NUM_EVENTS; ++i) {
33 papi_errno = PAPI_add_named_event(eventset, events[i]);
34 if (papi_errno != PAPI_OK) {
35 test_fail(__FILE__, __LINE__, "PAPI_add_named_event", papi_errno);
36 }
37 }
38
39 long long counters[NUM_EVENTS] = { 0 };
40 papi_errno = PAPI_start(eventset);
41 if (papi_errno != PAPI_OK) {
42 test_fail(__FILE__, __LINE__, "PAPI_start", papi_errno);
43 }
44
45 papi_errno = PAPI_read(eventset, counters);
46 if (papi_errno != PAPI_OK) {
47 test_fail(__FILE__, __LINE__, "PAPI_read", papi_errno);
48 }
49
50 for (int i = 0; i < NUM_EVENTS && !quiet; ++i) {
51 fprintf(stdout, "%s: %lli\n", events[i], counters[i]);
52 }
53
54 papi_errno = PAPI_read(eventset, counters);
55 if (papi_errno != PAPI_OK) {
56 test_fail(__FILE__, __LINE__, "PAPI_read", papi_errno);
57 }
58
59 for (int i = 0; i < NUM_EVENTS && !quiet; ++i) {
60 fprintf(stdout, "%s: %lli\n", events[i], counters[i]);
61 }
62
63 papi_errno = PAPI_read(eventset, counters);
64 if (papi_errno != PAPI_OK) {
65 test_fail(__FILE__, __LINE__, "PAPI_read", papi_errno);
66 }
67
68 for (int i = 0; i < NUM_EVENTS && !quiet; ++i) {
69 fprintf(stdout, "%s: %lli\n", events[i], counters[i]);
70 }
71
72 papi_errno = PAPI_stop(eventset, counters);
73 if (papi_errno != PAPI_OK) {
74 test_fail(__FILE__, __LINE__, "PAPI_read", papi_errno);
75 }
76
77 for (int i = 0; i < NUM_EVENTS && !quiet; ++i) {
78 fprintf(stdout, "%s: %lli\n", events[i], counters[i]);
79 }
80
81 papi_errno = PAPI_cleanup_eventset(eventset);
82 if (papi_errno != PAPI_OK) {
83 test_fail(__FILE__, __LINE__, "PAPI_cleanup_eventset", papi_errno);
84 }
85
86 papi_errno = PAPI_destroy_eventset(&eventset);
87 if (papi_errno != PAPI_OK) {
88 test_fail(__FILE__, __LINE__, "PAPI_destroy_eventset", papi_errno);
89 }
90
92 test_pass(__FILE__);
93 return 0;
94}
int i
add PAPI preset or native hardware event by name to an EventSet
Empty and destroy an EventSet.
Create a new empty PAPI EventSet.
Empty and destroy an EventSet.
initialize the PAPI library.
Read hardware counters from an event set.
Finish using PAPI and free all related resources.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
#define NUM_EVENTS
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
char events[MAX_EVENTS][BUFSIZ]
FILE * stdout
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
Here is the call graph for this function:

Variable Documentation

◆ quiet

int quiet

Definition at line 5 of file components/template/tests/simple.c.