PAPI 7.1.0.0
Loading...
Searching...
No Matches
PAPI_perror.c File Reference
Include dependency graph for PAPI_perror.c:

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 16 of file PAPI_perror.c.

17{
18
19 int retval;
20 int EventSet = PAPI_NULL;
21 char error_str[PAPI_MAX_STR_LEN];
22
23 /****************************************************************************
24 * This part initializes the library and compares the version number of the *
25 * header file, to the version of the library, if these don't match then it *
26 * is likely that PAPI won't work correctly.If there is an error, retval *
27 * keeps track of the version number. *
28 ****************************************************************************/
29
31 {
32 exit(1);
33 }
34
36 {
37 fprintf(stderr, "PAPI error %d: %s\n",retval,PAPI_strerror(retval));
38 exit(1);
39 }
40
41 /* Add Total Instructions Executed to our EventSet */
42
44 {
45 PAPI_perror( "PAPI_add_event" );
46 exit(1);
47 }
48
49 /* Start counting */
50
52 {
53 PAPI_perror( "PAPI_start" );
54 exit(1);
55 }
56
57 /* We are trying to start the counter which has already been started,
58 and this will give an error which will be passed to PAPI_perror via
59 retval and the function will then display the error string on the
60 screen.
61 */
62
64 {
65 PAPI_perror( "PAPI_start" );
66 }
67
68 /* The function PAPI_strerror returns the corresponding error string
69 from the error code */
71 {
72 printf("%s\n",PAPI_strerror(retval));
73 }
74
75 /* finish using PAPI and free all related resources
76 (this is optional, you don't have to use it
77 */
78 PAPI_shutdown ();
79
80 exit(0);
81}
add PAPI preset or native hardware event to an event set
Create a new empty PAPI EventSet.
initialize the PAPI library.
Produces a string on standard error, describing the last library error.
Finish using PAPI and free all related resources.
Start counting hardware events in an event set.
Returns a string describing the PAPI error code.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
#define PAPI_TOT_INS
Definition: f90papi.h:317
static int EventSet
Definition: init_fini.c:8
FILE * stderr
int retval
Definition: zero_fork.c:53