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

Go to the source code of this file.

Macros

#define THRESHOLD   1000
 

Functions

static void ear_no_profile (void)
 
static int do_profile (vptr_t start, unsigned long plength, unsigned scale, int thresh, int bucket)
 
int main (int argc, char **argv)
 

Macro Definition Documentation

◆ THRESHOLD

#define THRESHOLD   1000

Definition at line 37 of file earprofile.c.

Function Documentation

◆ do_profile()

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

Definition at line 58 of file earprofile.c.

60{
61 int i, retval;
62 unsigned long blength;
63 int num_buckets;
64 const char *profstr[2] = { "PAPI_PROFIL_POSIX", "PAPI_PROFIL_INST_EAR" };
65 int profflags[2] =
67 int num_profs;
68
69 do_stuff( );
70
71 num_profs = sizeof ( profflags ) / sizeof ( int );
73 blength = prof_size( plength, scale, bucket, &num_buckets );
74 prof_alloc( num_profs, blength );
75
76 for ( i = 0; i < num_profs; i++ ) {
77 if ( !TESTS_QUIET )
78 printf( "Test type : \t%s\n", profstr[i] );
79
80 if ( ( retval = PAPI_profil( profbuf[i], blength, start, scale,
81 EventSet, PAPI_event, thresh,
82 profflags[i] | bucket ) ) != PAPI_OK ) {
83 test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
84 }
85 if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
86 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
87
88 do_stuff( );
89
90 if ( ( retval = PAPI_stop( EventSet, values[1] ) ) != PAPI_OK )
91 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
92
93 if ( !TESTS_QUIET ) {
94 printf( TAB1, event_name, ( values[1] )[0] );
95 printf( TAB1, "PAPI_TOT_CYC:", ( values[1] )[1] );
96 }
97 if ( ( retval = PAPI_profil( profbuf[i], blength, start, scale,
99 profflags[i] ) ) != PAPI_OK )
100 test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
101 }
102
103 prof_head( blength, bucket, num_buckets,
104 "address\t\t\tPOSIX\tINST_DEAR\n" );
105 prof_out( start, num_profs, bucket, num_buckets, scale );
106
107 retval = prof_check( num_profs, bucket, num_buckets );
108
109 for ( i = 0; i < num_profs; i++ ) {
110 free( profbuf[i] );
111 }
112
113 return retval;
114}
int i
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.
int PAPI_event[2]
Definition: data_range.c:30
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
void do_stuff(void)
Definition: do_loops.c:256
static void ear_no_profile(void)
Definition: earprofile.c:40
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_PROFIL_POSIX
Definition: f90papi.h:44
#define PAPI_PROFIL_INST_EAR
Definition: f90papi.h:206
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
#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
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
int retval
Definition: zero_fork.c:53
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ear_no_profile()

static void ear_no_profile ( void  )
static

Definition at line 40 of file earprofile.c.

41{
42 int retval;
43
44 if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
45 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
46
47 do_l1misses( 10000 );
48
49 if ( ( retval = PAPI_stop( EventSet, values[0] ) ) != PAPI_OK )
50 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
51
52 printf( "Test type : \tNo profiling\n" );
53 printf( TAB1, event_name, ( values[0] )[0] );
54 printf( TAB1, "PAPI_TOT_CYC:", ( values[0] )[1] );
55}
void do_l1misses(int n)
Definition: do_loops.c:220
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 118 of file earprofile.c.

119{
120 int num_events, num_tests = 6;
121 long length;
122 int retval, retval2;
123 const PAPI_hw_info_t *hw_info;
124 const PAPI_exe_info_t *prginfo;
125 vptr_t start, end;
126 int quiet;
127
128 /* Set TESTS_QUIET variable */
129 quiet = tests_quiet( argc, argv );
130
132 if (retval != PAPI_VER_CURRENT ) {
133 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
134 }
135
136 if ( ( prginfo = PAPI_get_executable_info( ) ) == NULL ) {
137 test_fail( __FILE__, __LINE__, "PAPI_get_executable_info", 1 );
138 }
139
140 if ( ( hw_info = PAPI_get_hardware_info( ) ) == NULL ) {
141 test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 0 );
142 }
143
144 if ( ( strncasecmp( hw_info->model_string, "Itanium",
145 strlen( "Itanium" ) ) != 0 ) &&
146 ( strncasecmp( hw_info->model_string, "32",
147 strlen( "32" ) ) != 0 ) ) {
148 if (!quiet) printf("Itanium only for now.\n");
149 test_skip( __FILE__, __LINE__, "Test unsupported", PAPI_ENOIMPL );
150 }
151
152// if ( quiet ) {
153// test_skip( __FILE__, __LINE__,
154// "Test deprecated in quiet mode for PAPI 3.6", 0 );
155// }
156
157 sprintf( event_name, "DATA_EAR_CACHE_LAT4" );
158 if ( ( retval =
160 test_fail( __FILE__, __LINE__, "PAPI_event_name_to_code", retval );
161
162 if ( ( retval = PAPI_create_eventset( &EventSet ) ) != PAPI_OK )
163 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
164
166 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
167
169 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
170
171 num_events = 2;
173
174 /* use these lines to profile entire code address space */
175 start = prginfo->address_info.text_start;
176 end = prginfo->address_info.text_end;
177 length = end - start;
178 if ( length < 0 )
179 test_fail( __FILE__, __LINE__, "Profile length < 0!", length );
180
182 ( "Test earprofile: POSIX compatible event address register profiling.\n",
183 prginfo );
185 retval =
188
190 if ( retval2 == PAPI_OK )
192 if ( retval2 != PAPI_OK )
193 test_fail( __FILE__, __LINE__, "Can't remove events", retval2 );
194
195 if ( retval )
196 test_pass( __FILE__ );
197 else
198 test_fail( __FILE__, __LINE__, "No information in buffers", 1 );
199
200 return 1;
201
202}
static const PAPI_hw_info_t * hw_info
Definition: byte_profile.c:28
add PAPI preset or native hardware event to an event set
Create a new empty PAPI EventSet.
Convert a name to a numeric hardware event code.
Get the executable's address space info.
get information about the system hardware
initialize the PAPI library.
removes a hardware event from a PAPI event set.
#define THRESHOLD
Definition: earprofile.c:37
static int do_profile(vptr_t start, unsigned long plength, unsigned scale, int thresh, int bucket)
Definition: earprofile.c:58
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_PROFIL_BUCKET_16
Definition: f90papi.h:144
#define PAPI_TOT_CYC
Definition: f90papi.h:308
#define PAPI_ENOIMPL
Definition: f90papi.h:219
static int num_events
void * vptr_t
Definition: papi.h:576
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
long long ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:46
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:584
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
vptr_t text_start
Definition: papi.h:686
vptr_t text_end
Definition: papi.h:687
get the executable's info
Definition: papi.h:696
PAPI_address_map_t address_info
Definition: papi.h:698
Hardware info structure.
Definition: papi.h:774
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:784
int num_tests
Definition: zero_fork.c:53
Here is the call graph for this function: