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

Go to the source code of this file.

Functions

int prof_events (int num_tests)
 
void prof_print_address (const char *title, const PAPI_exe_info_t *prginfo)
 
void prof_print_prof_info (caddr_t start, caddr_t end, int threshold, char *event_name)
 
void do_no_profile (int quiet)
 
void prof_alloc (int num, unsigned long blength)
 
int prof_buckets (int bucket)
 
void prof_head (unsigned long blength, int bucket, int num_buckets, const char *header)
 
void prof_out (caddr_t start, int n, int bucket, int num_buckets, unsigned int scale)
 
int prof_check (int n, int bucket, int num_buckets)
 
unsigned long prof_size (unsigned long plength, unsigned scale, int bucket, int *num_buckets)
 

Variables

long long ** values
 
char event_name [PAPI_MAX_STR_LEN]
 
int PAPI_event
 
int EventSet = PAPI_NULL
 
voidprofbuf [5]
 

Function Documentation

void do_no_profile ( int  quiet)

Definition at line 113 of file prof_utils.c.

114 {
115  int retval;
116 
117  if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
118  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
119 
120  do_flops( getenv( "NUM_ITERS" ) ? atoi( getenv( "NUM_ITERS" ) ) :
121  NUM_ITERS );
122 
123  if ( ( retval = PAPI_stop( EventSet, values[0] ) ) != PAPI_OK )
124  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
125 
126  if (!quiet) {
127  printf( "Test type : \t%s\n", "No profiling" );
128  printf( TAB1, event_name, ( values[0] )[0] );
129  printf( TAB1, "PAPI_TOT_CYC", ( values[0] )[1] );
130  }
131 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
int atoi()
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
char * getenv()
#define NUM_ITERS
Definition: multiplex.c:19
#define TAB1
Definition: papi_test.h:88
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
int quiet
Definition: rapl_overflow.c:18
void do_flops(int n)
Definition: multiplex.c:23
printf("\tTry: -i 0 -i 1 \n\n")
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
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

Here is the call graph for this function:

Here is the caller graph for this function:

void prof_alloc ( int  num,
unsigned long  blength 
)

Definition at line 140 of file prof_utils.c.

141 {
142  int i;
143 
144  for ( i = 0; i < num; i++ ) {
145  profbuf[i] = malloc( blength );
146  if ( profbuf[i] == NULL ) {
147  test_fail( __FILE__, __LINE__, "malloc", PAPI_ESYS );
148  }
149  memset( profbuf[i], 0x00, blength );
150  }
151 }
int i
Definition: fileop.c:140
void int num
Definition: iozone.c:22151
#define PAPI_ESYS
Definition: papi.h:255
void * profbuf[5]
Definition: prof_utils.c:33
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468

Here is the call graph for this function:

Here is the caller graph for this function:

int prof_buckets ( int  bucket)

Definition at line 160 of file prof_utils.c.

161 {
162  int bucket_size;
163  switch ( bucket ) {
165  bucket_size = sizeof ( short );
166  break;
168  bucket_size = sizeof ( int );
169  break;
171  bucket_size = sizeof ( unsigned long long );
172  break;
173  default:
174  bucket_size = 0;
175  break;
176  }
177  return ( bucket_size );
178 }
#define PAPI_PROFIL_BUCKET_16
Definition: papi.h:400
#define PAPI_PROFIL_BUCKET_64
Definition: papi.h:402
long long
Definition: iozone.c:19827
#define PAPI_PROFIL_BUCKET_32
Definition: papi.h:401
int
Definition: iozone.c:18528

Here is the caller graph for this function:

int prof_check ( int  n,
int  bucket,
int  num_buckets 
)

Definition at line 272 of file prof_utils.c.

273 {
274  int i, j;
275  int retval = 0;
276  unsigned short **buf16 = ( unsigned short ** ) profbuf;
277  unsigned int **buf32 = ( unsigned int ** ) profbuf;
278  unsigned long long **buf64 = ( unsigned long long ** ) profbuf;
279 
280  switch ( bucket ) {
282  for ( i = 0; i < num_buckets; i++ )
283  for ( j = 0; j < n; j++ )
284  retval = retval || buf16[j][i];
285  break;
287  for ( i = 0; i < num_buckets; i++ )
288  for ( j = 0; j < n; j++ )
289  retval = retval || buf32[j][i];
290  break;
292  for ( i = 0; i < num_buckets; i++ )
293  for ( j = 0; j < n; j++ )
294  retval = retval || buf64[j][i];
295  break;
296  }
297  return ( retval );
298 }
#define PAPI_PROFIL_BUCKET_16
Definition: papi.h:400
int i
Definition: fileop.c:140
#define PAPI_PROFIL_BUCKET_64
Definition: papi.h:402
void * profbuf[5]
Definition: prof_utils.c:33
#define PAPI_PROFIL_BUCKET_32
Definition: papi.h:401
long j
Definition: iozone.c:19135
ssize_t retval
Definition: libasync.c:338

Here is the caller graph for this function:

int prof_events ( int  num_tests)

Definition at line 42 of file prof_utils.c.

43 {
44  int retval;
45  int num_events, mask;
46 
47  /* add PAPI_TOT_CYC and one of the events in PAPI_FP_INS, PAPI_FP_OPS or
48  PAPI_TOT_INS, depends on the availability of the event on the
49  platform */
50  EventSet = add_two_nonderived_events( &num_events, &PAPI_event, &mask );
51 
52  if (num_events==0) {
53  return 0;
54  }
55 
56  values = allocate_test_space( num_tests, num_events );
57 
59  if (retval != PAPI_OK ) {
60  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
61  }
62 
63  return mask;
64 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
int PAPI_event[2]
Definition: data_range.c:30
static int num_events
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:915
int num_tests
Definition: zero_fork.c:53
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
int add_two_nonderived_events(int *num_events, int *papi_event, int *mask)
Definition: test_utils.c:646
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
long long ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:46

Here is the call graph for this function:

Here is the caller graph for this function:

void prof_head ( unsigned long  blength,
int  bucket,
int  num_buckets,
const char *  header 
)

Definition at line 183 of file prof_utils.c.

184 {
185  int bucket_size = prof_buckets( bucket );
186  printf
187  ( "\n------------------------------------------------------------\n" );
188  printf( "PAPI_profil() hash table, Bucket size: %d bits.\n",
189  bucket_size * 8 );
190  printf( "Number of buckets: %d.\nLength of buffer: %ld bytes.\n",
191  num_buckets, blength );
192  printf( "------------------------------------------------------------\n" );
193  printf( "%s\n", header );
194 }
int prof_buckets(int bucket)
Definition: prof_utils.c:160
printf("\tTry: -i 0 -i 1 \n\n")

Here is the call graph for this function:

Here is the caller graph for this function:

void prof_out ( caddr_t  start,
int  n,
int  bucket,
int  num_buckets,
unsigned int  scale 
)

Definition at line 202 of file prof_utils.c.

204 {
205  int i, j;
206  unsigned short buf_16;
207  unsigned int buf_32;
208  unsigned long long buf_64;
209  unsigned short **buf16 = ( unsigned short ** ) profbuf;
210  unsigned int **buf32 = ( unsigned int ** ) profbuf;
211  unsigned long long **buf64 = ( unsigned long long ** ) profbuf;
212 
213  if ( !TESTS_QUIET ) {
214  /* printf("%#lx\n",(unsigned long) start + (unsigned long) (2 * i)); */
215  /* printf("start: %p; i: %#x; scale: %#x; i*scale: %#x; i*scale >>15: %#x\n", start, i, scale, i*scale, (i*scale)>>15); */
216  switch ( bucket ) {
218  for ( i = 0; i < num_buckets; i++ ) {
219  for ( j = 0, buf_16 = 0; j < n; j++ )
220  buf_16 |= ( buf16[j] )[i];
221  if ( buf_16 ) {
222 /* On 32bit builds with gcc 4.3 gcc complained about casting caddr_t => long long
223  * Thus the unsigned long to long long cast */
224  printf( "%#-16llx",
225  (long long) (unsigned long)start +
226  ( ( ( long long ) i * scale ) >> 15 ) );
227  for ( j = 0, buf_16 = 0; j < n; j++ )
228  printf( "\t%d", ( buf16[j] )[i] );
229  printf( "\n" );
230  }
231  }
232  break;
234  for ( i = 0; i < num_buckets; i++ ) {
235  for ( j = 0, buf_32 = 0; j < n; j++ )
236  buf_32 |= ( buf32[j] )[i];
237  if ( buf_32 ) {
238  printf( "%#-16llx",
239  (long long) (unsigned long)start +
240  ( ( ( long long ) i * scale ) >> 15 ) );
241  for ( j = 0, buf_32 = 0; j < n; j++ )
242  printf( "\t%d", ( buf32[j] )[i] );
243  printf( "\n" );
244  }
245  }
246  break;
248  for ( i = 0; i < num_buckets; i++ ) {
249  for ( j = 0, buf_64 = 0; j < n; j++ )
250  buf_64 |= ( buf64[j] )[i];
251  if ( buf_64 ) {
252  printf( "%#-16llx",
253  (long long) (unsigned long)start +
254  ( ( ( long long ) i * scale ) >> 15 ) );
255  for ( j = 0, buf_64 = 0; j < n; j++ )
256  printf( "\t%lld", ( buf64[j] )[i] );
257  printf( "\n" );
258  }
259  }
260  break;
261  }
262  printf
263  ( "------------------------------------------------------------\n\n" );
264  }
265 }
start
Definition: iozone.c:22736
#define PAPI_PROFIL_BUCKET_16
Definition: papi.h:400
int i
Definition: fileop.c:140
#define PAPI_PROFIL_BUCKET_64
Definition: papi.h:402
void * profbuf[5]
Definition: prof_utils.c:33
#define PAPI_PROFIL_BUCKET_32
Definition: papi.h:401
printf("\tTry: -i 0 -i 1 \n\n")
int TESTS_QUIET
Definition: test_utils.c:18
long j
Definition: iozone.c:19135

Here is the call graph for this function:

Here is the caller graph for this function:

void prof_print_address ( const char *  title,
const PAPI_exe_info_t prginfo 
)

Definition at line 69 of file prof_utils.c.

70 {
71  printf( "%s\n", title );
72  printf
73  ( "----------------------------------------------------------------\n" );
74  printf( "Text start: %p, Text end: %p, Text length: %#x\n",
75  prginfo->address_info.text_start, prginfo->address_info.text_end,
76  ( unsigned int ) ( prginfo->address_info.text_end -
77  prginfo->address_info.text_start ) );
78  printf( "Data start: %p, Data end: %p\n", prginfo->address_info.data_start,
79  prginfo->address_info.data_end );
80  printf( "BSS start : %p, BSS end : %p\n", prginfo->address_info.bss_start,
81  prginfo->address_info.bss_end );
82 
83  printf
84  ( "----------------------------------------------------------------\n" );
85 }
caddr_t text_end
Definition: papi.h:698
caddr_t bss_start
Definition: papi.h:701
caddr_t text_start
Definition: papi.h:697
PAPI_address_map_t address_info
Definition: papi.h:709
caddr_t data_start
Definition: papi.h:699
printf("\tTry: -i 0 -i 1 \n\n")
caddr_t bss_end
Definition: papi.h:702
caddr_t data_end
Definition: papi.h:700

Here is the call graph for this function:

Here is the caller graph for this function:

void prof_print_prof_info ( caddr_t  start,
caddr_t  end,
int  threshold,
char *  event_name 
)

Definition at line 93 of file prof_utils.c.

95 {
96  printf( "Profiling event : %s\n", event_name );
97  printf( "Profile Threshold: %d\n", threshold );
98  printf( "Profile Iters : %d\n",
99  ( getenv( "NUM_ITERS" ) ? atoi( getenv( "NUM_ITERS" ) ) :
100  NUM_ITERS ) );
101  printf( "Profile Range : %p to %p\n", start, end );
102  printf
103  ( "----------------------------------------------------------------\n" );
104  printf( "\n" );
105 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
int atoi()
char * getenv()
#define NUM_ITERS
Definition: multiplex.c:19
start
Definition: iozone.c:22736
static int threshold
printf("\tTry: -i 0 -i 1 \n\n")

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned long prof_size ( unsigned long  plength,
unsigned  scale,
int  bucket,
int num_buckets 
)

Definition at line 310 of file prof_utils.c.

311 {
312  unsigned long blength;
313  long long llength = ( ( long long ) plength * scale );
314  int bucket_size = prof_buckets( bucket );
315  *num_buckets = ( int ) ( llength / 65536 / 2 );
316  blength = ( unsigned long ) ( *num_buckets * bucket_size );
317  return ( blength );
318 }
long long
Definition: iozone.c:19827
int prof_buckets(int bucket)
Definition: prof_utils.c:160
int
Definition: iozone.c:18528

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

char event_name[PAPI_MAX_STR_LEN]

Definition at line 30 of file prof_utils.c.

int EventSet = PAPI_NULL

Definition at line 32 of file prof_utils.c.

int PAPI_event

Definition at line 31 of file prof_utils.c.

void* profbuf[5]

Definition at line 33 of file prof_utils.c.

long long** values

Definition at line 29 of file prof_utils.c.