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

Go to the source code of this file.

Macros

#define FLOPS   1000000
 
#define THRESHOLD   100000
 
#define ERROR_RETURN(retval)   { fprintf(stderr, "Error %d %s:line %d: \n", retval,__FILE__,__LINE__); exit(retval); }
 

Functions

int code_to_monitor ()
 
int main ()
 

Macro Definition Documentation

◆ ERROR_RETURN

#define ERROR_RETURN (   retval)    { fprintf(stderr, "Error %d %s:line %d: \n", retval,__FILE__,__LINE__); exit(retval); }

Definition at line 12 of file PAPI_profil.c.

◆ FLOPS

#define FLOPS   1000000

Definition at line 10 of file PAPI_profil.c.

◆ THRESHOLD

#define THRESHOLD   100000

Definition at line 11 of file PAPI_profil.c.

Function Documentation

◆ code_to_monitor()

int code_to_monitor ( )

Definition at line 14 of file PAPI_profil.c.

15{
16 int i;
17 double tmp=1.1;
18
19 for(i=0; i < FLOPS; i++)
20 {
21 tmp=i+tmp;
22 tmp++;
23 }
24 i = (int) tmp;
25 return i;
26}
double tmp
int i
#define FLOPS
Definition: PAPI_profil.c:10
int
Definition: sde_internal.h:89
Here is the caller graph for this function:

◆ main()

int main ( )

Definition at line 28 of file PAPI_profil.c.

29{
30
31 unsigned long length;
32 vptr_t start, end;
33 PAPI_sprofil_t * prof;
34 int EventSet = PAPI_NULL;
35 /*must be initialized to PAPI_NULL before calling PAPI_create_event*/
36 int PAPI_event,i,tmp = 0;
38 /*These are going to be used as buffers */
39 unsigned short *profbuf;
40 long long values[2];
41 const PAPI_exe_info_t *prginfo = NULL;
42
43
44 int retval;
45
46
47 /****************************************************************************
48 * This part initializes the library and compares the version number of the *
49 * header file, to the version of the library, if these don't match then it *
50 * is likely that PAPI won't work correctly.If there is an error, retval *
51 * keeps track of the version number. *
52 ****************************************************************************/
53
55 {
56 printf("Library initialization error! \n");
57 exit(1);
58 }
59
60
61 if ((prginfo = PAPI_get_executable_info()) == NULL)
62 {
63 fprintf(stderr, "Error in get executable information \n");
64 exit(1);
65 }
66
67 start = prginfo->address_info.text_start;
68 end = prginfo->address_info.text_end;
69 length = (end - start);
70
71 /* for PAPI_PROFIL_BUCKET_16 and scale = 65536,
72 profile buffer length == program address length.
73 Larger bucket sizes would increase the buffer length.
74 Smaller scale factors would decrease it.
75 Handle with care...
76 */
77 profbuf = (unsigned short *)malloc(length);
78 if (profbuf == NULL)
79 {
80 fprintf(stderr, "Not enough memory \n");
81 exit(1);
82 }
83 memset(profbuf,0x00,length);
84
85 /* Creating the eventset */
88
90 /* Add Total Instructions Executed to our EventSet */
93
94 /* Add Total Cycles Executed to our EventSet */
97
98 /* enable the collection of profiling information */
102
103 /* let's rock and roll */
106
108
111
112 /* disable the collection of profiling information by setting threshold
113 to 0
114 */
118
119 printf("-----------------------------------------------------------\n");
120 printf("Text start: %p, Text end: %p, \n",
121 prginfo->address_info.text_start,prginfo->address_info.text_end);
122 printf("Data start: %p, Data end: %p\n",
123 prginfo->address_info.data_start,prginfo->address_info.data_end);
124 printf("BSS start : %p, BSS end: %p\n",
125 prginfo->address_info.bss_start,prginfo->address_info.bss_end);
126
127 printf("------------------------------------------\n");
128
129 printf("Test type : \tPAPI_PROFIL_POSIX\n");
130 printf("------------------------------------------\n\n\n");
131 printf("PAPI_profil() hash table.\n");
132 printf("address\t\tflat \n");
133 for (i = 0; i < (int) length/2; i++)
134 {
135 if (profbuf[i])
136 printf("%#lx\t%d \n",
137 (unsigned long) start + (unsigned long) (2 * i), profbuf[i]);
138 }
139
140 printf("-----------------------------------------\n");
141
142 retval = 0;
143 for (i = 0; i < (int) length/2; i++)
144 retval = retval || (profbuf[i]);
145 if (retval)
146 printf("Test succeeds! \n");
147 else
148 printf( "No information in buffers\n");
149 /* clean up */
151
152 exit(0);
153}
#define THRESHOLD
Definition: PAPI_profil.c:11
#define ERROR_RETURN(retval)
Definition: PAPI_profil.c:12
int code_to_monitor()
Definition: PAPI_profil.c:14
add PAPI preset or native hardware event to an event set
Create a new empty PAPI EventSet.
Get the executable's address space info.
initialize the PAPI library.
Generate a histogram of hardware counter overflows vs. PC addresses.
Finish using PAPI and free all related resources.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
int PAPI_event[2]
Definition: data_range.c:30
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_PROFIL_POSIX
Definition: f90papi.h:44
#define PAPI_PROFIL_BUCKET_16
Definition: f90papi.h:144
#define PAPI_TOT_CYC
Definition: f90papi.h:308
#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
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
static struct timeval start
void * vptr_t
Definition: papi.h:576
FILE * stderr
void * profbuf[5]
Definition: prof_utils.c:33
unsigned int length
vptr_t text_start
Definition: papi.h:686
vptr_t text_end
Definition: papi.h:687
vptr_t bss_start
Definition: papi.h:690
vptr_t data_end
Definition: papi.h:689
vptr_t data_start
Definition: papi.h:688
vptr_t bss_end
Definition: papi.h:691
get the executable's info
Definition: papi.h:696
PAPI_address_map_t address_info
Definition: papi.h:698
int retval
Definition: zero_fork.c:53
Here is the call graph for this function: