PAPI  5.6.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
profile_twoevents.c
Go to the documentation of this file.
1 /*
2 * File: profile_twoevents.c
3 * Author: Philip Mucci
4 * mucci@cs.utk.edu
5 */
6 
7 /* This file performs the following test: profiling two events */
8 
9 #include <stdio.h>
10 #include <stdlib.h>
11 
12 #include "papi.h"
13 #include "papi_test.h"
14 #include "prof_utils.h"
15 
16 #include "do_loops.h"
17 
18 int
19 main( int argc, char **argv )
20 {
21  int i, num_tests = 6;
22  unsigned long length, blength;
23  int num_buckets, mask;
24  char title[80];
25  int retval;
26  const PAPI_exe_info_t *prginfo;
27  caddr_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 =
66  prof_size( length, FULL_SCALE, PAPI_PROFIL_BUCKET_16, &num_buckets );
67  do_no_profile( quiet );
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,
81  PAPI_PROFIL_POSIX ) ) != PAPI_OK )
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,
100  EventSet, PAPI_event, 0,
101  PAPI_PROFIL_POSIX ) ) != PAPI_OK )
102  test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
103 
104  if ( ( retval =
105  PAPI_profil( profbuf[1], ( unsigned int ) blength, start, FULL_SCALE,
107  PAPI_PROFIL_POSIX ) ) != PAPI_OK )
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 
118  remove_test_events( &EventSet, mask );
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 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
unsigned long long length
Definition: iozone.c:17106
int PAPI_event[2]
Definition: data_range.c:30
void test_pass(const char *filename)
Definition: test_utils.c:432
caddr_t text_end
Definition: papi.h:698
start
Definition: iozone.c:22736
#define PAPI_PROFIL_BUCKET_16
Definition: papi.h:400
void do_stuff(void)
Definition: do_loops.c:256
#define TAB1
Definition: papi_test.h:88
int EventSet
get the executable&#39;s info
Definition: papi.h:707
return PAPI_OK
Definition: linux-nvml.c:497
int int argc
Definition: iozone.c:1609
Return codes and api definitions.
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:559
char ** argv
Definition: iozone.c:1610
unsigned long prof_size(unsigned long plength, unsigned scale, int bucket, int *num_buckets)
Definition: prof_utils.c:310
#define MASK_FP_INS
Definition: papi_test.h:38
int PAPI_library_init(int version)
Definition: papi.c:500
int PAPI_profil(void *buf, unsigned bufsiz, caddr_t offset, unsigned scale, int EventSet, int EventCode, int threshold, int flags)
Definition: papi.c:5438
int i
Definition: fileop.c:140
void prof_out(caddr_t start, int n, int bucket, int num_buckets, unsigned int scale)
Definition: prof_utils.c:202
#define FULL_SCALE
Definition: prof_utils.h:20
int quiet
Definition: rapl_overflow.c:18
#define PAPI_TOT_CYC
const PAPI_exe_info_t * PAPI_get_executable_info(void)
Definition: papi.c:6114
free(dummyfile[xx])
caddr_t text_start
Definition: papi.h:697
PAPI_address_map_t address_info
Definition: papi.h:709
void * profbuf[5]
Definition: prof_utils.c:33
long long
Definition: iozone.c:19827
int num_tests
Definition: zero_fork.c:53
#define MASK_TOT_INS
Definition: papi_test.h:39
void prof_head(unsigned long blength, int bucket, int num_buckets, const char *header)
Definition: prof_utils.c:183
#define PAPI_PROFIL_POSIX
Definition: papi.h:396
printf("\tTry: -i 0 -i 1 \n\n")
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
void prof_print_address(const char *title, const PAPI_exe_info_t *prginfo)
Definition: prof_utils.c:69
void prof_print_prof_info(caddr_t start, caddr_t end, int threshold, char *event_name)
Definition: prof_utils.c:93
void do_no_profile(int quiet)
Definition: prof_utils.c:113
int prof_check(int n, int bucket, int num_buckets)
Definition: prof_utils.c:272
int prof_events(int num_tests)
Definition: prof_utils.c:42
int PAPI_start(int EventSet)
Definition: papi.c:2096
#define THRESHOLD
Definition: earprofile.c:37
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:225
int main(int argc, char **argv)
List all appio events codes and names.
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:201
void prof_alloc(int num, unsigned long blength)
Definition: prof_utils.c:140