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

Go to the source code of this file.

Macros

#define PROFILE_ALL
 
#define N   (1 << 23)
 
#define T   (10)
 

Functions

static void cleara (double a[N])
 
static int my_dummy (int i)
 
static void my_main (void)
 
static int do_profile (vptr_t start, unsigned long plength, unsigned scale, int thresh, int bucket, unsigned int mask)
 
int main (int argc, char **argv)
 

Variables

static const PAPI_hw_info_thw_info
 
static int num_events = 0
 
double aa [N]
 
double bb [N]
 
double s = 0
 
double s2 = 0
 

Macro Definition Documentation

◆ N

#define N   (1 << 23)

Definition at line 32 of file byte_profile.c.

◆ PROFILE_ALL

#define PROFILE_ALL

Definition at line 26 of file byte_profile.c.

◆ T

#define T   (10)

Definition at line 33 of file byte_profile.c.

Function Documentation

◆ cleara()

static void cleara ( double  a[N])
static

Definition at line 39 of file byte_profile.c.

40{
41 int i;
42
43 for ( i = 0; i < N; i++ ) {
44 a[i] = 0;
45 }
46}
int i
#define N
Definition: byte_profile.c:32
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:38
Here is the caller graph for this function:

◆ do_profile()

static int do_profile ( vptr_t  start,
unsigned long  plength,
unsigned  scale,
int  thresh,
int  bucket,
unsigned int  mask 
)
static

Definition at line 73 of file byte_profile.c.

74 {
75
76 int i, retval;
77 unsigned long blength;
78 int num_buckets,j=0;
79
80 int num_bufs = num_events;
81 int event = num_events;
82
84 char header[BUFSIZ];
85
86 strncpy(header,"address\t\t",BUFSIZ);
87
88 //= "address\t\t\tcyc\tins\tfp_ins\n";
89
90 for(i=0;i<MAX_TEST_EVENTS;i++) {
91 if (mask & test_events[i].mask) {
93
94 if (events[j]==PAPI_TOT_CYC) {
95 strncat(header,"\tcyc",BUFSIZ-1);
96 }
97 if (events[j]==PAPI_TOT_INS) {
98 strncat(header,"\tins",BUFSIZ-1);
99 }
100 if (events[j]==PAPI_FP_INS) {
101 strncat(header,"\tfp_ins",BUFSIZ-1);
102 }
103 if (events[j]==PAPI_FP_OPS) {
104 strncat(header,"\tfp_ops",BUFSIZ-1);
105 }
106 if (events[j]==PAPI_L2_TCM) {
107 strncat(header,"\tl2_tcm",BUFSIZ-1);
108 }
109
110 j++;
111
112 }
113 }
114
115 strncat(header,"\n",BUFSIZ-1);
116
117
118
119 blength = prof_size( plength, scale, bucket, &num_buckets );
120 prof_alloc( num_bufs, blength );
121
122 if ( !TESTS_QUIET ) printf( "Overall event counts:\n" );
123
124 for ( i = 0; i < num_events; i++ ) {
125 if ( ( retval =
126 PAPI_profil( profbuf[i], ( unsigned int ) blength, start, scale,
127 EventSet, events[i], thresh,
128 PAPI_PROFIL_POSIX | bucket ) ) != PAPI_OK ) {
129 if (retval == PAPI_EINVAL) {
130 test_warn( __FILE__, __LINE__, "Trying to profile with derived event", 1);
132 break;
133 }
134 else {
135 printf("Failed with event %d %#x\n",i,events[i]);
136 test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
137 }
138 }
139 }
140
141 if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
142 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
143
144 my_main( );
145
146 if ( ( retval = PAPI_stop( EventSet, values[0] ) ) != PAPI_OK )
147 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
148
149 if ( !TESTS_QUIET ) {
150 printf( TAB1, "PAPI_TOT_CYC:", ( values[0] )[--event] );
151 if ( strcmp( hw_info->model_string, "POWER6" ) != 0 ) {
152 printf( TAB1, "PAPI_TOT_INS:", ( values[0] )[--event] );
153 }
154#if defined(__powerpc__)
155 printf( TAB1, "PAPI_FP_INS", ( values[0] )[--event] );
156#else
157 if ( strcmp( hw_info->model_string, "Intel Pentium III" ) != 0 ) {
158 printf( TAB1, "PAPI_FP_OPS:", ( values[0] )[--event] );
159 printf( TAB1, "PAPI_L2_TCM:", ( values[0] )[--event] );
160 }
161#endif
162 }
163
164 for ( i = 0; i < num_events; i++ ) {
165 if ( ( retval =
166 PAPI_profil( profbuf[i], ( unsigned int ) blength, start, scale,
167 EventSet, events[i], 0,
169 test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
170 }
171
172 if (!TESTS_QUIET) {
173 prof_head( blength, bucket, num_buckets, header );
174 prof_out( start, num_events, bucket, num_buckets, scale );
175 }
176 retval = prof_check( num_bufs, bucket, num_buckets );
177 for ( i = 0; i < num_bufs; i++ ) {
178 free( profbuf[i] );
179 }
180 return retval;
181}
static const PAPI_hw_info_t * hw_info
Definition: byte_profile.c:28
static int num_events
Definition: byte_profile.c:30
static void my_main(void)
Definition: byte_profile.c:55
Generate a histogram of hardware counter overflows vs. PC addresses.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_PROFIL_POSIX
Definition: f90papi.h:44
#define PAPI_TOT_CYC
Definition: f90papi.h:308
#define PAPI_L2_TCM
Definition: f90papi.h:320
#define PAPI_EINVAL
Definition: f90papi.h:115
#define PAPI_FP_INS
Definition: f90papi.h:366
#define PAPI_FP_OPS
Definition: f90papi.h:319
#define PAPI_TOT_INS
Definition: f90papi.h:317
char events[MAX_EVENTS][BUFSIZ]
static int EventSet
Definition: init_fini.c:8
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
static struct timeval start
int TESTS_QUIET
Definition: test_utils.c:18
struct test_events_t test_events[]
Definition: test_utils.c:130
#define TAB1
Definition: papi_test.h:98
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
#define MAX_TEST_EVENTS
Definition: papi_test.h:42
void test_warn(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:547
int prof_check(int n, int bucket, int num_buckets)
Definition: prof_utils.c:272
void prof_head(unsigned long blength, int bucket, int num_buckets, const char *header)
Definition: prof_utils.c:183
unsigned long prof_size(unsigned long plength, unsigned scale, int bucket, int *num_buckets)
Definition: prof_utils.c:310
void prof_alloc(int num, unsigned long blength)
Definition: prof_utils.c:140
void prof_out(vptr_t start, int n, int bucket, int num_buckets, unsigned int scale)
Definition: prof_utils.c:202
void * profbuf[5]
Definition: prof_utils.c:33
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:784
unsigned int event
Definition: papi_test.h:46
int retval
Definition: zero_fork.c:53
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 186 of file byte_profile.c.

187{
188 long length;
189 int mask;
190 int retval;
191 const PAPI_exe_info_t *prginfo;
192 vptr_t start, end;
193 int quiet;
194
195 /* Set TESTS_QUIET variable */
196 quiet=tests_quiet( argc, argv );
197
199 if (retval != PAPI_VER_CURRENT) {
200 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
201 }
202
203 if ( ( prginfo = PAPI_get_executable_info( ) ) == NULL ) {
204 test_fail( __FILE__, __LINE__, "PAPI_get_executable_info", 1 );
205 }
206
208 if ( hw_info == NULL ) {
209 test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
210 }
211
213
214#if defined(__powerpc__)
215 if ( strcmp( hw_info->model_string, "POWER6" ) == 0 )
216 mask = MASK_TOT_CYC | MASK_FP_INS;
217 else
219#endif
220
221#if defined(ITANIUM2)
223#endif
224 EventSet = add_test_events( &num_events, &mask, 0 );
225 if (num_events==0) {
226 if (!quiet) printf("Trouble adding events\n");
227 test_skip(__FILE__,__LINE__,"add_test_events",2);
228 }
230
231/* profile the cleara and my_main address space */
232 start = ( vptr_t ) cleara;
233 end = ( vptr_t ) my_dummy;
234
235/* Itanium and PowerPC64 processors return function descriptors instead
236 * of function addresses. You must dereference the descriptor to get the address.
237*/
238#if defined(ITANIUM1) || defined(ITANIUM2) \
239 || (defined(__powerpc64__) && (_CALL_ELF != 2))
240 start = ( vptr_t ) ( ( ( struct fdesc * ) start )->ip );
241 end = ( vptr_t ) ( ( ( struct fdesc * ) end )->ip );
242 /* PPC64 Big Endian is ELF version 1 which uses function descriptors.
243 * PPC64 Little Endian is ELF version 2 which does not use
244 * function descriptors
245 */
246#endif
247
248 /* call dummy so it doesn't get optimized away */
249 retval = my_dummy( 1 );
250
251 length = end - start;
252 if ( length < 0 )
253 test_fail( __FILE__, __LINE__, "Profile length < 0!", ( int ) length );
254
255 if (!quiet) {
256 prof_print_address( "Test case byte_profile: "
257 "Multi-event profiling at byte resolution.\n",
258 prginfo );
260 }
261
262 retval = do_profile( start, ( unsigned ) length,
264 PAPI_PROFIL_BUCKET_32, mask );
265
267
268 if (retval == 0) {
269 test_fail( __FILE__, __LINE__, "No information in buffers", 1 );
270 }
271
272 test_pass( __FILE__ );
273
274 return 0;
275}
static void cleara(double a[N])
Definition: byte_profile.c:39
static int my_dummy(int i)
Definition: byte_profile.c:49
static int do_profile(vptr_t start, unsigned long plength, unsigned scale, int thresh, int bucket, unsigned int mask)
Definition: byte_profile.c:73
Get the executable's address space info.
get information about the system hardware
initialize the PAPI library.
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
#define THRESHOLD
Definition: earprofile.c:37
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_PROFIL_BUCKET_32
Definition: f90papi.h:248
void * vptr_t
Definition: papi.h:576
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
int add_test_events(int *number, int *mask, int allow_derived)
Definition: test_utils.c:152
#define MASK_FP_OPS
Definition: papi_test.h:24
#define MASK_L2_TCM
Definition: papi_test.h:34
#define MASK_L1_DCM
Definition: papi_test.h:35
long long ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:46
#define MASK_FP_INS
Definition: papi_test.h:38
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
#define MASK_TOT_CYC
Definition: papi_test.h:40
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:584
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:201
#define MASK_TOT_INS
Definition: papi_test.h:39
void prof_print_prof_info(vptr_t start, vptr_t end, int threshold, char *event_name)
Definition: prof_utils.c:93
void prof_print_address(const char *title, const PAPI_exe_info_t *prginfo)
Definition: prof_utils.c:69
#define FULL_SCALE
Definition: prof_utils.h:20
unsigned int length
int quiet
Definition: rapl_overflow.c:19
get the executable's info
Definition: papi.h:696
Here is the call graph for this function:

◆ my_dummy()

static int my_dummy ( int  i)
static

Definition at line 49 of file byte_profile.c.

50{
51 return ( i + 1 );
52}
Here is the caller graph for this function:

◆ my_main()

static void my_main ( void  )
static

Definition at line 55 of file byte_profile.c.

56{
57 int i, j;
58
59 for ( j = 0; j < T; j++ ) {
60 for ( i = 0; i < N; i++ ) {
61 bb[i] = 0;
62 }
63 cleara( aa );
64 memset( aa, 0, sizeof ( aa ) );
65 for ( i = 0; i < N; i++ ) {
66 s += aa[i] * bb[i];
67 s2 += aa[i] * aa[i] + bb[i] * bb[i];
68 }
69 }
70}
#define T
Definition: byte_profile.c:33
double bb[N]
Definition: byte_profile.c:35
double s2
Definition: byte_profile.c:36
double aa[N]
Definition: byte_profile.c:35
double s
Definition: byte_profile.c:36
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ aa

double aa[N]

Definition at line 35 of file byte_profile.c.

◆ bb

double bb[N]

Definition at line 35 of file byte_profile.c.

◆ hw_info

const PAPI_hw_info_t* hw_info
static

Definition at line 28 of file byte_profile.c.

◆ num_events

int num_events = 0
static

Definition at line 30 of file byte_profile.c.

◆ s

double s = 0

Definition at line 36 of file byte_profile.c.

◆ s2

double s2 = 0

Definition at line 36 of file byte_profile.c.