PAPI  5.6.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
profile.c File Reference
Include dependency graph for profile.c:

Go to the source code of this file.

Macros

#define PROFILE_ALL
 

Functions

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

Macro Definition Documentation

#define PROFILE_ALL

Definition at line 38 of file profile.c.

Function Documentation

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

Definition at line 41 of file profile.c.

43 {
44  int i, retval;
45  unsigned long blength;
46  int num_buckets;
47 
48  const char *profstr[5] = { "PAPI_PROFIL_POSIX",
49  "PAPI_PROFIL_RANDOM",
50  "PAPI_PROFIL_WEIGHTED",
51  "PAPI_PROFIL_COMPRESS",
52  "PAPI_PROFIL_<all>"
53  };
54 
55  int profflags[5] = { PAPI_PROFIL_POSIX,
61  };
62 
64  blength = prof_size( plength, scale, bucket, &num_buckets );
65  prof_alloc( 5, blength );
66 
67  for ( i = 0; i < 5; i++ ) {
68  if ( !TESTS_QUIET ) {
69  printf( "Test type : \t%s\n", profstr[i] );
70  }
71 
72 #ifndef SWPROFILE
73  if ( ( retval =
74  PAPI_profil( profbuf[i], ( unsigned int ) blength, start, scale,
75  EventSet, PAPI_event, thresh,
76  profflags[i] | bucket ) ) != PAPI_OK ) {
77  if (retval==PAPI_ENOSUPP) {
78  char warning[BUFSIZ];
79 
80  sprintf(warning,"PAPI_profil %s not supported",
81  profstr[i]);
82  test_warn( __FILE__, __LINE__, warning, 1 );
83  }
84  else {
85  test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
86  }
87  }
88 #else
89  if ( ( retval =
90  PAPI_profil( profbuf[i], ( unsigned int ) blength, start, scale,
91  EventSet, PAPI_event, thresh,
92  profflags[i] | bucket | PAPI_PROFIL_FORCE_SW ) ) !=
93  PAPI_OK ) {
94  test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
95  }
96 #endif
97 
98  if ( retval != PAPI_OK )
99  break;
100 
101  if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
102  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
103 
104  do_flops( getenv( "NUM_FLOPS" ) ? atoi( getenv( "NUM_FLOPS" ) ) :
105  NUM_FLOPS );
106 
107  if ( ( retval = PAPI_stop( EventSet, values[1] ) ) != PAPI_OK )
108  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
109 
110  if ( !TESTS_QUIET ) {
111  printf( TAB1, event_name, ( values[1] )[0] );
112  printf( TAB1, "PAPI_TOT_CYC", ( values[1] )[1] );
113  }
114  retval = PAPI_profil( profbuf[i], ( unsigned int ) blength, start, scale,
115  EventSet, PAPI_event, 0,
116  profflags[i] );
117  if (retval != PAPI_OK ) {
118  test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
119  }
120  }
121 
122  if ( retval == PAPI_OK ) {
123  if (!TESTS_QUIET) prof_head( blength, bucket, num_buckets,
124  "address\t\t\tflat\trandom\tweight\tcomprs\tall\n" );
125  if (!TESTS_QUIET) prof_out( start, 5, bucket, num_buckets, scale );
126  retval = prof_check( 5, bucket, num_buckets );
127  }
128 
129  for ( i = 0; i < 5; i++ ) {
130  free( profbuf[i] );
131  }
132 
133  return retval;
134 }
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 atoi()
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
int PAPI_event[2]
Definition: data_range.c:30
char * getenv()
start
Definition: iozone.c:22736
#define PAPI_ENOSUPP
Definition: papi.h:271
#define TAB1
Definition: papi_test.h:88
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
#define NUM_FLOPS
Definition: sdsc-mpx.c:24
void test_warn(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:522
unsigned long prof_size(unsigned long plength, unsigned scale, int bucket, int *num_buckets)
Definition: prof_utils.c:310
int PAPI_profil(void *buf, unsigned bufsiz, caddr_t offset, unsigned scale, int EventSet, int EventCode, int threshold, int flags)
Definition: papi.c:5438
#define PAPI_PROFIL_COMPRESS
Definition: papi.h:399
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
free(dummyfile[xx])
#define PAPI_PROFIL_RANDOM
Definition: papi.h:397
void * profbuf[5]
Definition: prof_utils.c:33
void do_flops(int n)
Definition: multiplex.c:23
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
#define PAPI_PROFIL_WEIGHTED
Definition: papi.h:398
printf("\tTry: -i 0 -i 1 \n\n")
int TESTS_QUIET
Definition: test_utils.c:18
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
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
#define PAPI_PROFIL_FORCE_SW
Definition: papi.h:403
int PAPI_start(int EventSet)
Definition: papi.c:2096
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
void prof_alloc(int num, unsigned long blength)
Definition: prof_utils.c:140

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 138 of file profile.c.

139 {
140  int num_tests = 6;
141  long length;
142  int mask;
143  int retval;
144  int mythreshold = THRESHOLD;
145  const PAPI_exe_info_t *prginfo;
146  caddr_t start, end;
147  int quiet;
148 
149  /* Set TESTS_QUIET variable */
150  quiet = tests_quiet( argc, argv );
151 
153  if (retval != PAPI_VER_CURRENT ) {
154  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
155  }
156 
157  if ( ( prginfo = PAPI_get_executable_info( ) ) == NULL ) {
158  test_fail( __FILE__, __LINE__, "PAPI_get_executable_info", 1 );
159  }
160 
161  retval = PAPI_query_event(PAPI_TOT_CYC);
162  if (retval!=PAPI_OK) {
163  if (!quiet) printf("No events found\n");
164  test_skip(__FILE__, __LINE__,"No events found",1);
165  }
166 
167  mask = prof_events( num_tests );
168 
169 #ifdef PROFILE_ALL
170 /* use these lines to profile entire code address space */
171  start = prginfo->address_info.text_start;
172  end = prginfo->address_info.text_end;
173 #else
174 /* use these lines to profile only do_flops address space */
175  start = ( caddr_t ) do_flops;
176  end = ( caddr_t ) fdo_flops;
177 /* Itanium and ppc64 processors return function descriptors instead of function addresses.
178  You must dereference the descriptor to get the address.
179 */
180 #if defined(ITANIUM1) || defined(ITANIUM2) || defined(__powerpc64__)
181  start = ( caddr_t ) ( ( ( struct fdesc * ) start )->ip );
182  end = ( caddr_t ) ( ( ( struct fdesc * ) end )->ip );
183 #endif
184 #endif
185 
186 #if defined(linux)
187  {
188  char *tmp = getenv( "THRESHOLD" );
189  if ( tmp )
190  mythreshold = atoi( tmp );
191  }
192 #endif
193 
194  length = end - start;
195  if ( length < 0 ) {
196  test_fail( __FILE__, __LINE__, "Profile length < 0!", ( int ) length );
197  }
198 
199  if (!quiet) {
200  prof_print_address( "Test case profile: "
201  "POSIX compatible profiling with hardware counters.\n",
202  prginfo );
203  prof_print_prof_info( start, end, mythreshold, event_name );
204  }
205 
206  retval = do_profile( start, ( unsigned long ) length, FULL_SCALE,
207  mythreshold, PAPI_PROFIL_BUCKET_16 );
208  if ( retval == PAPI_OK ) {
209  retval = do_profile( start, ( unsigned long ) length,
210  FULL_SCALE, mythreshold,
212  }
213  if ( retval == PAPI_OK ) {
214  retval = do_profile( start, ( unsigned long ) length,
215  FULL_SCALE, mythreshold,
217  }
218 
219  remove_test_events( &EventSet, mask );
220 
221  test_pass( __FILE__ );
222 
223  return 0;
224 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
int atoi()
unsigned long long length
Definition: iozone.c:17106
char * getenv()
void test_pass(const char *filename)
Definition: test_utils.c:432
struct in_addr * ip
Definition: iozone.c:20416
caddr_t text_end
Definition: papi.h:698
start
Definition: iozone.c:22736
#define PAPI_PROFIL_BUCKET_16
Definition: papi.h:400
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
static int do_profile(caddr_t start, unsigned long plength, unsigned scale, int thresh, int bucket)
Definition: profile.c:41
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:559
char ** argv
Definition: iozone.c:1610
int PAPI_library_init(int version)
Definition: papi.c:500
#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
#define PAPI_PROFIL_BUCKET_64
Definition: papi.h:402
caddr_t text_start
Definition: papi.h:697
PAPI_address_map_t address_info
Definition: papi.h:709
#define PAPI_PROFIL_BUCKET_32
Definition: papi.h:401
int num_tests
Definition: zero_fork.c:53
void do_flops(int n)
Definition: multiplex.c:23
int PAPI_query_event(int EventCode)
Definition: papi.c:684
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
int prof_events(int num_tests)
Definition: prof_utils.c:42
static long long mythreshold
#define THRESHOLD
Definition: earprofile.c:37
ssize_t retval
Definition: libasync.c:338
long long tmp
Definition: iozone.c:12031
void fdo_flops(int *n)
Definition: do_loops.c:90
#define PAPI_VER_CURRENT
Definition: papi.h:225
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:201

Here is the call graph for this function: