PAPI  5.4.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 33 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 103 of file profile.c.

105 {
106  int i, retval;
107  unsigned long blength;
108  int num_buckets;
109 
110  char *profstr[5] = { "PAPI_PROFIL_POSIX",
111  "PAPI_PROFIL_RANDOM",
112  "PAPI_PROFIL_WEIGHTED",
113  "PAPI_PROFIL_COMPRESS",
114  "PAPI_PROFIL_<all>"
115  };
116 
117  int profflags[5] = { PAPI_PROFIL_POSIX,
123  };
124 
125  do_no_profile( );
126  blength = prof_size( plength, scale, bucket, &num_buckets );
127  prof_alloc( 5, blength );
128 
129  for ( i = 0; i < 5; i++ ) {
130  if ( !TESTS_QUIET )
131  printf( "Test type : \t%s\n", profstr[i] );
132 
133 #ifndef SWPROFILE
134  if ( ( retval =
135  PAPI_profil( profbuf[i], ( unsigned int ) blength, start, scale,
136  EventSet, PAPI_event, thresh,
137  profflags[i] | bucket ) ) != PAPI_OK ) {
138  if (retval==PAPI_ENOSUPP) {
139  char warning[BUFSIZ];
140 
141  sprintf(warning,"PAPI_profil %s not supported",
142  profstr[i]);
143  test_warn( __FILE__, __LINE__, warning, 1 );
144  }
145  else {
146  test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
147  }
148  }
149 #else
150  if ( ( retval =
151  PAPI_profil( profbuf[i], ( unsigned int ) blength, start, scale,
152  EventSet, PAPI_event, thresh,
153  profflags[i] | bucket | PAPI_PROFIL_FORCE_SW ) ) !=
154  PAPI_OK ) {
155  test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
156  }
157 #endif
158 
159  if ( retval != PAPI_OK )
160  break;
161 
162  if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
163  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
164 
165  do_flops( getenv( "NUM_FLOPS" ) ? atoi( getenv( "NUM_FLOPS" ) ) :
166  NUM_FLOPS );
167 
168  if ( ( retval = PAPI_stop( EventSet, values[1] ) ) != PAPI_OK )
169  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
170 
171  if ( !TESTS_QUIET ) {
172  printf( TAB1, event_name, ( values[1] )[0] );
173  printf( TAB1, "PAPI_TOT_CYC", ( values[1] )[1] );
174  }
175  if ( ( retval =
176  PAPI_profil( profbuf[i], ( unsigned int ) blength, start, scale,
177  EventSet, PAPI_event, 0,
178  profflags[i] ) ) != PAPI_OK )
179  test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
180  }
181 
182  if ( retval == PAPI_OK ) {
183  prof_head( blength, bucket, num_buckets,
184  "address\t\t\tflat\trandom\tweight\tcomprs\tall\n" );
185  prof_out( start, 5, bucket, num_buckets, scale );
186  retval = prof_check( 5, bucket, num_buckets );
187  }
188 
189  for ( i = 0; i < 5; i++ ) {
190  free( profbuf[i] );
191  }
192 
193  return ( retval );
194 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
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:2258
#define NUM_FLOPS
int PAPI_event[2]
Definition: data_range.c:24
char * getenv()
void prof_head(unsigned long blength, int bucket, int num_buckets, char *header)
Definition: prof_utils.c:194
start
Definition: iozone.c:22736
#define PAPI_ENOSUPP
Definition: papi.h:269
#define TAB1
Definition: papi_test.h:112
int EventSet
Definition: data_range.c:25
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
int TESTS_QUIET
Definition: test_utils.c:11
void do_no_profile(void)
Definition: prof_utils.c:126
unsigned long prof_size(unsigned long plength, unsigned scale, int bucket, int *num_buckets)
Definition: prof_utils.c:321
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_profil(void *buf, unsigned bufsiz, caddr_t offset, unsigned scale, int EventSet, int EventCode, int threshold, int flags)
Definition: papi.c:5364
#define PAPI_PROFIL_COMPRESS
Definition: papi.h:397
int i
Definition: fileop.c:140
void test_warn(char *file, int line, char *call, int retval)
Definition: test_utils.c:578
void prof_out(caddr_t start, int n, int bucket, int num_buckets, unsigned int scale)
Definition: prof_utils.c:213
free(dummyfile[xx])
#define PAPI_PROFIL_RANDOM
Definition: papi.h:395
void * profbuf[5]
Definition: prof_utils.c:28
void do_flops(int n)
Definition: multiplex.c:23
#define PAPI_PROFIL_POSIX
Definition: papi.h:394
#define PAPI_PROFIL_WEIGHTED
Definition: papi.h:396
int prof_check(int n, int bucket, int num_buckets)
Definition: prof_utils.c:283
#define PAPI_PROFIL_FORCE_SW
Definition: papi.h:401
int PAPI_start(int EventSet)
Definition: papi.c:2053
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:151

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 39 of file profile.c.

40 {
41  int num_tests = 6;
42  long length;
43  int mask;
44  int retval;
45  int mythreshold = THRESHOLD;
46  const PAPI_exe_info_t *prginfo;
47  caddr_t start, end;
48 
49  prof_init( argc, argv, &prginfo );
50  mask = prof_events( num_tests );
51 
52 #ifdef PROFILE_ALL
53 /* use these lines to profile entire code address space */
54  start = prginfo->address_info.text_start;
55  end = prginfo->address_info.text_end;
56 #else
57 /* use these lines to profile only do_flops address space */
58  start = ( caddr_t ) do_flops;
59  end = ( caddr_t ) fdo_flops;
60 /* Itanium and ppc64 processors return function descriptors instead of function addresses.
61  You must dereference the descriptor to get the address.
62 */
63 #if defined(ITANIUM1) || defined(ITANIUM2) || defined(__powerpc64__)
64  start = ( caddr_t ) ( ( ( struct fdesc * ) start )->ip );
65  end = ( caddr_t ) ( ( ( struct fdesc * ) end )->ip );
66 #endif
67 #endif
68 
69 #if defined(linux)
70  {
71  char *tmp = getenv( "THRESHOLD" );
72  if ( tmp )
73  mythreshold = atoi( tmp );
74  }
75 #endif
76 
77  length = end - start;
78  if ( length < 0 )
79  test_fail( __FILE__, __LINE__, "Profile length < 0!", ( int ) length );
80 
82  ( "Test case profile: POSIX compatible profiling with hardware counters.\n",
83  prginfo );
84  prof_print_prof_info( start, end, mythreshold, event_name );
85  retval =
86  do_profile( start, ( unsigned long ) length, FULL_SCALE, mythreshold,
88  if ( retval == PAPI_OK )
89  retval =
90  do_profile( start, ( unsigned long ) length, FULL_SCALE,
91  mythreshold, PAPI_PROFIL_BUCKET_32 );
92  if ( retval == PAPI_OK )
93  retval =
94  do_profile( start, ( unsigned long ) length, FULL_SCALE,
95  mythreshold, PAPI_PROFIL_BUCKET_64 );
96 
97  remove_test_events( &EventSet, mask );
98  test_pass( __FILE__, values, num_tests );
99  exit( 1 );
100 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
int atoi()
unsigned long long length
Definition: iozone.c:17106
void prof_print_address(char *title, const PAPI_exe_info_t *prginfo)
Definition: prof_utils.c:82
char * getenv()
struct in_addr * ip
Definition: iozone.c:20416
caddr_t text_end
Definition: papi.h:695
start
Definition: iozone.c:22736
#define PAPI_PROFIL_BUCKET_16
Definition: papi.h:398
int EventSet
Definition: data_range.c:25
get the executable&#39;s info
Definition: papi.h:704
return PAPI_OK
Definition: linux-nvml.c:458
test_pass(__FILE__, NULL, 0)
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:103
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
#define FULL_SCALE
Definition: prof_utils.h:23
#define PAPI_PROFIL_BUCKET_64
Definition: papi.h:400
caddr_t text_start
Definition: papi.h:694
PAPI_address_map_t address_info
Definition: papi.h:706
#define PAPI_PROFIL_BUCKET_32
Definition: papi.h:399
int num_tests
Definition: zero_fork.c:46
void do_flops(int n)
Definition: multiplex.c:23
void prof_init(int argc, char **argv, const PAPI_exe_info_t **prginfo)
Definition: prof_utils.c:39
void prof_print_prof_info(caddr_t start, caddr_t end, int threshold, char *event_name)
Definition: prof_utils.c:106
int prof_events(int num_tests)
Definition: prof_utils.c:59
long long mythreshold
#define THRESHOLD
Definition: earprofile.c:31
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
long long tmp
Definition: iozone.c:12031
void fdo_flops(int *n)
Definition: do_loops.c:83
void exit()
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:277

Here is the call graph for this function: