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

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 19 of file profile_twoevents.c.

20{
21 int i, num_tests = 6;
22 unsigned long length, blength;
23 int num_buckets, mask;
24 char title[PAPI_2MAX_STR_LEN];
25 int retval;
26 const PAPI_exe_info_t *prginfo;
27 vptr_t start, end;
28 int quiet;
29
30 /* Set TESTS_QUIET variable */
31 quiet=tests_quiet( argc, argv );
32
34 if (retval != PAPI_VER_CURRENT ) {
35 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
36 }
37
38 if ( ( prginfo = PAPI_get_executable_info( ) ) == NULL ) {
39 test_fail( __FILE__, __LINE__, "PAPI_get_executable_info", 1 );
40 }
41
42 mask = prof_events( num_tests );
43 start = prginfo->address_info.text_start;
44 end = prginfo->address_info.text_end;
45
46 /* Must have at least FP instr or Tot ins */
47
48 if ( ( ( mask & MASK_FP_INS ) == 0 ) && ( ( mask & MASK_TOT_INS ) == 0 ) ) {
49 if (!quiet) printf("No events could be added\n");
50 test_skip( __FILE__, __LINE__, "No FP or Total Ins. event", 1 );
51 }
52
53 if ( start > end )
54 test_fail( __FILE__, __LINE__, "Profile length < 0!", 0 );
55 length = ( unsigned long ) ( end - start );
56
57 if (!quiet) {
58 prof_print_address( "Test case profile: POSIX compatible profiling with two events.\n",
59 prginfo );
61 }
62
63 prof_alloc( 2, length );
64
65 blength =
68
69 if ( !quiet ) {
70 printf( "Test type : \tPAPI_PROFIL_POSIX\n" );
71 }
72 if ( ( retval =
73 PAPI_profil( profbuf[0], ( unsigned int ) blength, start, FULL_SCALE,
75 PAPI_PROFIL_POSIX ) ) != PAPI_OK ) {
76 test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
77 }
78 if ( ( retval =
79 PAPI_profil( profbuf[1], ( unsigned int ) blength, start, FULL_SCALE,
82 test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
83
84 do_stuff( );
85
86 if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
87 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
88
89 do_stuff( );
90
91 if ( ( retval = PAPI_stop( EventSet, values[1] ) ) != PAPI_OK )
92 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
93
94 if ( !quiet ) {
95 printf( TAB1, event_name, ( values[1] )[0] );
96 printf( TAB1, "PAPI_TOT_CYC:", ( values[1] )[1] );
97 }
98 if ( ( retval =
99 PAPI_profil( profbuf[0], ( unsigned int ) blength, start, FULL_SCALE,
102 test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
103
104 if ( ( retval =
105 PAPI_profil( profbuf[1], ( unsigned int ) blength, start, FULL_SCALE,
108 test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
109
110 sprintf( title, " \t\t %s\tPAPI_TOT_CYC\naddress\t\t\tcounts\tcounts\n",
111 event_name );
112
113 if (!quiet) {
114 prof_head( blength, PAPI_PROFIL_BUCKET_16, num_buckets, title );
115 prof_out( start, 2, PAPI_PROFIL_BUCKET_16, num_buckets, FULL_SCALE );
116 }
117
119
120 retval = prof_check( 2, PAPI_PROFIL_BUCKET_16, num_buckets );
121
122 for ( i = 0; i < 2; i++ ) {
123 free( profbuf[i] );
124 }
125
126 if ( retval == 0 ) {
127 test_fail( __FILE__, __LINE__, "No information in buffers", 1 );
128 }
129
130 test_pass( __FILE__ );
131
132 return 0;
133}
int i
Get the executable's address space info.
initialize the PAPI library.
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
#define THRESHOLD
Definition: earprofile.c:37
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#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_2MAX_STR_LEN
Definition: f90papi.h:180
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
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
#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 MASK_FP_INS
Definition: papi_test.h:38
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
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:201
#define MASK_TOT_INS
Definition: papi_test.h:39
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
void prof_print_prof_info(vptr_t start, vptr_t end, int threshold, char *event_name)
Definition: prof_utils.c:93
unsigned long prof_size(unsigned long plength, unsigned scale, int bucket, int *num_buckets)
Definition: prof_utils.c:310
int prof_events(int num_tests)
Definition: prof_utils.c:42
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 prof_print_address(const char *title, const PAPI_exe_info_t *prginfo)
Definition: prof_utils.c:69
void * profbuf[5]
Definition: prof_utils.c:33
void do_no_profile(int quiet)
Definition: prof_utils.c:113
#define FULL_SCALE
Definition: prof_utils.h:20
unsigned int length
int quiet
Definition: rapl_overflow.c:19
long long int long long
Definition: sde_internal.h:85
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
int num_tests
Definition: zero_fork.c:53
int retval
Definition: zero_fork.c:53
Here is the call graph for this function: