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

Go to the source code of this file.

Macros

#define PROFILE_ALL
 
#define N   (1 << 23)
 
#define T   (10)
 

Functions

static void cleara (double a[N])
 
static int my_dummy (int i)
 
static void my_main (void)
 
static int do_profile (caddr_t start, unsigned long plength, unsigned scale, int thresh, int bucket, unsigned int mask)
 
int main (int argc, char **argv)
 

Variables

static const PAPI_hw_info_thw_info
 
static int num_events = 0
 
double aa [N]
 
double bb [N]
 
double s = 0
 
double s2 = 0
 

Macro Definition Documentation

#define N   (1 << 23)

Definition at line 32 of file byte_profile.c.

#define PROFILE_ALL

Definition at line 26 of file byte_profile.c.

#define T   (10)

Definition at line 33 of file byte_profile.c.

Function Documentation

static void cleara ( double  a[N])
static

Definition at line 39 of file byte_profile.c.

40 {
41  int i;
42 
43  for ( i = 0; i < N; i++ ) {
44  a[i] = 0;
45  }
46 }
int i
Definition: fileop.c:140
#define N
Definition: byte_profile.c:32
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:38

Here is the caller graph for this function:

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

Definition at line 73 of file byte_profile.c.

74  {
75 
76  int i, retval;
77  unsigned long blength;
78  int num_buckets,j=0;
79 
80  int num_bufs = num_events;
81  int event = num_events;
82 
84  char header[BUFSIZ];
85 
86  strncpy(header,"address\t\t",BUFSIZ);
87 
88  //= "address\t\t\tcyc\tins\tfp_ins\n";
89 
90  for(i=0;i<MAX_TEST_EVENTS;i++) {
91  if (mask & test_events[i].mask) {
92  events[j]=test_events[i].event;
93 
94  if (events[j]==PAPI_TOT_CYC) {
95  strncat(header,"\tcyc",BUFSIZ-1);
96  }
97  if (events[j]==PAPI_TOT_INS) {
98  strncat(header,"\tins",BUFSIZ-1);
99  }
100  if (events[j]==PAPI_FP_INS) {
101  strncat(header,"\tfp_ins",BUFSIZ-1);
102  }
103  if (events[j]==PAPI_FP_OPS) {
104  strncat(header,"\tfp_ops",BUFSIZ-1);
105  }
106  if (events[j]==PAPI_L2_TCM) {
107  strncat(header,"\tl2_tcm",BUFSIZ-1);
108  }
109 
110  j++;
111 
112  }
113  }
114 
115  strncat(header,"\n",BUFSIZ-1);
116 
117 
118 
119  blength = prof_size( plength, scale, bucket, &num_buckets );
120  prof_alloc( num_bufs, blength );
121 
122  if ( !TESTS_QUIET ) printf( "Overall event counts:\n" );
123 
124  for ( i = 0; i < num_events; i++ ) {
125  if ( ( retval =
126  PAPI_profil( profbuf[i], ( unsigned int ) blength, start, scale,
127  EventSet, events[i], thresh,
128  PAPI_PROFIL_POSIX | bucket ) ) != PAPI_OK ) {
129  if (retval == PAPI_EINVAL) {
130  test_warn( __FILE__, __LINE__, "Trying to profile with derived event", 1);
131  num_events=i;
132  break;
133  }
134  else {
135  printf("Failed with event %d %#x\n",i,events[i]);
136  test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
137  }
138  }
139  }
140 
141  if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
142  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
143 
144  my_main( );
145 
146  if ( ( retval = PAPI_stop( EventSet, values[0] ) ) != PAPI_OK )
147  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
148 
149  if ( !TESTS_QUIET ) {
150  printf( TAB1, "PAPI_TOT_CYC:", ( values[0] )[--event] );
151  if ( strcmp( hw_info->model_string, "POWER6" ) != 0 ) {
152  printf( TAB1, "PAPI_TOT_INS:", ( values[0] )[--event] );
153  }
154 #if defined(__powerpc__)
155  printf( TAB1, "PAPI_FP_INS", ( values[0] )[--event] );
156 #else
157  if ( strcmp( hw_info->model_string, "Intel Pentium III" ) != 0 ) {
158  printf( TAB1, "PAPI_FP_OPS:", ( values[0] )[--event] );
159  printf( TAB1, "PAPI_L2_TCM:", ( values[0] )[--event] );
160  }
161 #endif
162  }
163 
164  for ( i = 0; i < num_events; i++ ) {
165  if ( ( retval =
166  PAPI_profil( profbuf[i], ( unsigned int ) blength, start, scale,
167  EventSet, events[i], 0,
168  PAPI_PROFIL_POSIX ) ) != PAPI_OK )
169  test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
170  }
171 
172  if (!TESTS_QUIET) {
173  prof_head( blength, bucket, num_buckets, header );
174  prof_out( start, num_events, bucket, num_buckets, scale );
175  }
176  retval = prof_check( num_bufs, bucket, num_buckets );
177  for ( i = 0; i < num_bufs; i++ ) {
178  free( profbuf[i] );
179  }
180  return retval;
181 }
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
#define PAPI_L2_TCM
#define PAPI_FP_OPS
start
Definition: iozone.c:22736
#define TAB1
Definition: papi_test.h:88
#define PAPI_TOT_INS
static void my_main(void)
Definition: byte_profile.c:55
#define MAX_TEST_EVENTS
Definition: papi_test.h:42
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
return PAPI_EINVAL
Definition: linux-nvml.c:436
void test_warn(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:522
char events[MAX_EVENTS][BUFSIZ]
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
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
#define PAPI_TOT_CYC
free(dummyfile[xx])
void * profbuf[5]
Definition: prof_utils.c:33
void prof_head(unsigned long blength, int bucket, int num_buckets, const char *header)
Definition: prof_utils.c:183
struct test_events_t test_events[]
Definition: test_utils.c:130
#define PAPI_PROFIL_POSIX
Definition: papi.h:396
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
static int num_events
Definition: byte_profile.c:30
int prof_check(int n, int bucket, int num_buckets)
Definition: prof_utils.c:272
unsigned int event
Definition: papi_test.h:46
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:790
int PAPI_start(int EventSet)
Definition: papi.c:2096
long j
Definition: iozone.c:19135
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
static const PAPI_hw_info_t * hw_info
Definition: byte_profile.c:28
void prof_alloc(int num, unsigned long blength)
Definition: prof_utils.c:140
#define PAPI_FP_INS

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 186 of file byte_profile.c.

187 {
188  long length;
189  int mask;
190  int retval;
191  const PAPI_exe_info_t *prginfo;
192  caddr_t start, end;
193  int quiet;
194 
195  /* Set TESTS_QUIET variable */
196  quiet=tests_quiet( argc, argv );
197 
199  if (retval != PAPI_VER_CURRENT) {
200  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
201  }
202 
203  if ( ( prginfo = PAPI_get_executable_info( ) ) == NULL ) {
204  test_fail( __FILE__, __LINE__, "PAPI_get_executable_info", 1 );
205  }
206 
208  if ( hw_info == NULL ) {
209  test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
210  }
211 
213 
214 #if defined(__powerpc__)
215  if ( strcmp( hw_info->model_string, "POWER6" ) == 0 )
216  mask = MASK_TOT_CYC | MASK_FP_INS;
217  else
219 #endif
220 
221 #if defined(ITANIUM2)
223 #endif
224  EventSet = add_test_events( &num_events, &mask, 0 );
225  if (num_events==0) {
226  if (!quiet) printf("Trouble adding events\n");
227  test_skip(__FILE__,__LINE__,"add_test_events",2);
228  }
230 
231 /* profile the cleara and my_main address space */
232  start = ( caddr_t ) cleara;
233  end = ( caddr_t ) my_dummy;
234 
235 /* Itanium and PowerPC64 processors return function descriptors instead
236  * of function addresses. You must dereference the descriptor to get the address.
237 */
238 #if defined(ITANIUM1) || defined(ITANIUM2) \
239  || (defined(__powerpc64__) && (_CALL_ELF != 2))
240  start = ( caddr_t ) ( ( ( struct fdesc * ) start )->ip );
241  end = ( caddr_t ) ( ( ( struct fdesc * ) end )->ip );
242  /* PPC64 Big Endian is ELF version 1 which uses function descriptors.
243  * PPC64 Little Endian is ELF version 2 which does not use
244  * function descriptors
245  */
246 #endif
247 
248  /* call dummy so it doesn't get optimized away */
249  retval = my_dummy( 1 );
250 
251  length = end - start;
252  if ( length < 0 )
253  test_fail( __FILE__, __LINE__, "Profile length < 0!", ( int ) length );
254 
255  if (!quiet) {
256  prof_print_address( "Test case byte_profile: "
257  "Multi-event profiling at byte resolution.\n",
258  prginfo );
259  prof_print_prof_info( start, end, THRESHOLD, event_name );
260  }
261 
262  retval = do_profile( start, ( unsigned ) length,
263  FULL_SCALE * 2, THRESHOLD,
264  PAPI_PROFIL_BUCKET_32, mask );
265 
266  remove_test_events( &EventSet, mask );
267 
268  if (retval == 0) {
269  test_fail( __FILE__, __LINE__, "No information in buffers", 1 );
270  }
271 
272  test_pass( __FILE__ );
273 
274  return 0;
275 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
unsigned long long length
Definition: iozone.c:17106
void test_pass(const char *filename)
Definition: test_utils.c:432
struct in_addr * ip
Definition: iozone.c:20416
start
Definition: iozone.c:22736
int EventSet
get the executable&#39;s info
Definition: papi.h:707
int int argc
Definition: iozone.c:1609
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:559
char ** argv
Definition: iozone.c:1610
#define MASK_FP_INS
Definition: papi_test.h:38
int PAPI_library_init(int version)
Definition: papi.c:500
static void cleara(double a[N])
Definition: byte_profile.c:39
#define FULL_SCALE
Definition: prof_utils.h:20
int quiet
Definition: rapl_overflow.c:18
const PAPI_exe_info_t * PAPI_get_executable_info(void)
Definition: papi.c:6114
static int my_dummy(int i)
Definition: byte_profile.c:49
#define PAPI_PROFIL_BUCKET_32
Definition: papi.h:401
#define MASK_TOT_CYC
Definition: papi_test.h:40
#define MASK_FP_OPS
Definition: papi_test.h:24
#define MASK_TOT_INS
Definition: papi_test.h:39
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
#define MASK_L2_TCM
Definition: papi_test.h:34
static int num_events
Definition: byte_profile.c:30
#define MASK_L1_DCM
Definition: papi_test.h:35
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:790
static int do_profile(caddr_t start, unsigned long plength, unsigned scale, int thresh, int bucket, unsigned int mask)
Definition: byte_profile.c:73
#define THRESHOLD
Definition: earprofile.c:37
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
Definition: papi.c:6185
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
#define PAPI_VER_CURRENT
Definition: papi.h:225
static const PAPI_hw_info_t * hw_info
Definition: byte_profile.c:28
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:201
int add_test_events(int *number, int *mask, int allow_derived)
Definition: test_utils.c:152

Here is the call graph for this function:

static int my_dummy ( int  i)
static

Definition at line 49 of file byte_profile.c.

50 {
51  return ( i + 1 );
52 }
int i
Definition: fileop.c:140

Here is the caller graph for this function:

static void my_main ( void  )
static

Definition at line 55 of file byte_profile.c.

56 {
57  int i, j;
58 
59  for ( j = 0; j < T; j++ ) {
60  for ( i = 0; i < N; i++ ) {
61  bb[i] = 0;
62  }
63  cleara( aa );
64  memset( aa, 0, sizeof ( aa ) );
65  for ( i = 0; i < N; i++ ) {
66  s += aa[i] * bb[i];
67  s2 += aa[i] * aa[i] + bb[i] * bb[i];
68  }
69  }
70 }
#define T
Definition: byte_profile.c:33
double aa[N]
Definition: byte_profile.c:35
int i
Definition: fileop.c:140
static void cleara(double a[N])
Definition: byte_profile.c:39
s
Definition: iozone.c:20289
double bb[N]
Definition: byte_profile.c:35
double s2
Definition: byte_profile.c:36
#define N
Definition: byte_profile.c:32
long j
Definition: iozone.c:19135

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

double aa[N]

Definition at line 35 of file byte_profile.c.

double bb[N]

Definition at line 35 of file byte_profile.c.

const PAPI_hw_info_t* hw_info
static

Definition at line 28 of file byte_profile.c.

int num_events = 0
static

Definition at line 30 of file byte_profile.c.

double s = 0

Definition at line 36 of file byte_profile.c.

double s2 = 0

Definition at line 36 of file byte_profile.c.