PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ctests/sprofile.c File Reference
Include dependency graph for ctests/sprofile.c:

Go to the source code of this file.

Macros

#define DO_READS   (unsigned long)(do_reads)
 
#define DO_FLOPS   (unsigned long)(do_flops)
 

Functions

int main (int argc, char **argv)
 

Macro Definition Documentation

#define DO_FLOPS   (unsigned long)(do_flops)

Definition at line 23 of file ctests/sprofile.c.

#define DO_READS   (unsigned long)(do_reads)

Definition at line 22 of file ctests/sprofile.c.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 32 of file ctests/sprofile.c.

33 {
34  int i, num_events, num_tests = 6, mask = 0x1;
35  int EventSet = PAPI_NULL;
36  unsigned short **buf = ( unsigned short ** ) profbuf;
37  unsigned long length, blength;
38  int num_buckets;
39  PAPI_sprofil_t sprof[3];
40  int retval;
41  const PAPI_exe_info_t *prginfo;
42  caddr_t start, end;
43 
44  prof_init( argc, argv, &prginfo );
45 
46  start = prginfo->address_info.text_start;
47  end = prginfo->address_info.text_end;
48  if ( start > end ) {
49  test_fail( __FILE__, __LINE__, "Profile length < 0!", PAPI_ESYS );
50  }
51  length = ( unsigned long ) ( end - start );
53  ( "Test case sprofile: POSIX compatible profiling over multiple regions.\n",
54  prginfo );
55  blength =
56  prof_size( length, FULL_SCALE, PAPI_PROFIL_BUCKET_16, &num_buckets );
57  prof_alloc( 3, blength );
58 
59  /* First half */
60  sprof[0].pr_base = buf[0];
61  sprof[0].pr_size = ( unsigned int ) blength;
62  sprof[0].pr_off = ( caddr_t ) DO_FLOPS;
63 #if defined(linux) && defined(__ia64__)
64  if ( !TESTS_QUIET )
65  fprintf( stderr, "do_flops is at %p %p\n", &do_flops, sprof[0].pr_off );
66 #endif
67  sprof[0].pr_scale = FULL_SCALE;
68  /* Second half */
69  sprof[1].pr_base = buf[1];
70  sprof[1].pr_size = ( unsigned int ) blength;
71  sprof[1].pr_off = ( caddr_t ) DO_READS;
72 #if defined(linux) && defined(__ia64__)
73  if ( !TESTS_QUIET )
74  fprintf( stderr, "do_reads is at %p %p\n", &do_reads, sprof[1].pr_off );
75 #endif
76  sprof[1].pr_scale = FULL_SCALE;
77  /* Overflow bin */
78  sprof[2].pr_base = buf[2];
79  sprof[2].pr_size = 1;
80  sprof[2].pr_off = 0;
81  sprof[2].pr_scale = 0x2;
82 
83  EventSet = add_test_events( &num_events, &mask, 1 );
84 
85  values = allocate_test_space( num_tests, num_events );
86 
87  if ( ( retval = PAPI_sprofil( sprof, 3, EventSet, PAPI_TOT_CYC, THRESHOLD,
89  != PAPI_OK )
90  test_fail( __FILE__, __LINE__, "PAPI_sprofil", retval );
91 
92  do_stuff( );
93 
94  if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
95  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
96 
97  do_stuff( );
98 
99  if ( ( retval = PAPI_stop( EventSet, values[1] ) ) != PAPI_OK )
100  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
101 
102  /* clear the profile flag before removing the event */
103  if ( ( retval = PAPI_sprofil( sprof, 3, EventSet, PAPI_TOT_CYC, 0,
105  != PAPI_OK )
106  test_fail( __FILE__, __LINE__, "PAPI_sprofil", retval );
107 
108  remove_test_events( &EventSet, mask );
109 
110 
111 
112  if ( !TESTS_QUIET ) {
113  printf( "Test case: PAPI_sprofil()\n" );
114  printf( "---------Buffer 1--------\n" );
115  for ( i = 0; i < ( int ) length / 2; i++ ) {
116  if ( buf[0][i] )
117  printf( "%#lx\t%d\n", DO_FLOPS + 2 * ( unsigned long ) i,
118  buf[0][i] );
119  }
120  printf( "---------Buffer 2--------\n" );
121  for ( i = 0; i < ( int ) length / 2; i++ ) {
122  if ( buf[1][i] )
123  printf( "%#lx\t%d\n", DO_READS + 2 * ( unsigned long ) i,
124  buf[1][i] );
125  }
126  printf( "-------------------------\n" );
127  printf( "%u samples fell outside the regions.\n", *buf[2] );
128  }
129  retval = prof_check( 2, PAPI_PROFIL_BUCKET_16, num_buckets );
130 
131  for ( i = 0; i < 3; i++ ) {
132  free( profbuf[i] );
133  }
134  if ( retval == 0 )
135  test_fail( __FILE__, __LINE__, "No information in buffers", 1 );
136 
137  test_pass( __FILE__, values, num_tests );
138 
139  exit( 1 );
140 }
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2258
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
void do_reads(int n)
Definition: do_loops.c:12
caddr_t text_end
Definition: papi.h:695
start
Definition: iozone.c:22736
#define DO_FLOPS
#define PAPI_NULL
Definition: papi.h:290
#define PAPI_PROFIL_BUCKET_16
Definition: papi.h:398
void do_stuff(void)
Definition: do_loops.c:249
int EventSet
Definition: data_range.c:25
int num_events
caddr_t pr_off
Definition: papi.h:581
get the executable&#39;s info
Definition: papi.h:704
return PAPI_OK
Definition: linux-nvml.c:458
int PAPI_sprofil(PAPI_sprofil_t *prof, int profcnt, int EventSet, int EventCode, int threshold, int flags)
Definition: papi.c:4970
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
unsigned pr_scale
Definition: papi.h:582
int TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
unsigned pr_size
Definition: papi.h:580
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 i
Definition: fileop.c:140
char buf[200]
Definition: iozone.c:19609
#define FULL_SCALE
Definition: prof_utils.h:23
#define PAPI_TOT_CYC
free(dummyfile[xx])
caddr_t text_start
Definition: papi.h:694
PAPI_address_map_t address_info
Definition: papi.h:706
#define PAPI_ESYS
Definition: papi.h:253
void * profbuf[5]
Definition: prof_utils.c:28
long long
Definition: iozone.c:19827
#define DO_READS
int num_tests
Definition: zero_fork.c:46
void do_flops(int n)
Definition: multiplex.c:23
#define PAPI_PROFIL_POSIX
Definition: papi.h:394
void prof_init(int argc, char **argv, const PAPI_exe_info_t **prginfo)
Definition: prof_utils.c:39
int
Definition: iozone.c:18528
int prof_check(int n, int bucket, int num_buckets)
Definition: prof_utils.c:283
void * pr_base
Definition: papi.h:579
int PAPI_start(int EventSet)
Definition: papi.c:2053
#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 ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:107
void exit()
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:277
void prof_alloc(int num, unsigned long blength)
Definition: prof_utils.c:151
int add_test_events(int *number, int *mask, int allow_derived)
Definition: test_utils.c:213

Here is the call graph for this function: