PAPI  5.3.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 18 of file ctests/sprofile.c.

#define DO_READS   (unsigned long)(do_reads)

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

Function Documentation

int main ( int  argc,
char **  argv 
)

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

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