PAPI  5.3.2.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 ()
 
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 27 of file byte_profile.c.

#define PROFILE_ALL

Definition at line 21 of file byte_profile.c.

#define T   (10)

Definition at line 28 of file byte_profile.c.

Function Documentation

static void cleara ( double  a[N])
static

Definition at line 34 of file byte_profile.c.

35 {
36  int i;
37 
38  for ( i = 0; i < N; i++ ) {
39  a[i] = 0;
40  }
41 }
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:37
int i
Definition: fileop.c:140
#define N
Definition: byte_profile.c:27

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

69  {
70 
71  int i, retval;
72  unsigned long blength;
73  int num_buckets,j=0;
74 
75  int num_bufs = num_events;
76  int event = num_events;
77 
79  char header[BUFSIZ];
80 
81  strncpy(header,"address\t\t",BUFSIZ);
82 
83  //= "address\t\t\tcyc\tins\tfp_ins\n";
84 
85  for(i=0;i<MAX_TEST_EVENTS;i++) {
86  if (mask & test_events[i].mask) {
87  events[j]=test_events[i].event;
88 
89  if (events[j]==PAPI_TOT_CYC) {
90  strncat(header,"\tcyc",BUFSIZ-1);
91  }
92  if (events[j]==PAPI_TOT_INS) {
93  strncat(header,"\tins",BUFSIZ-1);
94  }
95  if (events[j]==PAPI_FP_INS) {
96  strncat(header,"\tfp_ins",BUFSIZ-1);
97  }
98  if (events[j]==PAPI_FP_OPS) {
99  strncat(header,"\tfp_ops",BUFSIZ-1);
100  }
101  if (events[j]==PAPI_L2_TCM) {
102  strncat(header,"\tl2_tcm",BUFSIZ-1);
103  }
104 
105  j++;
106 
107  }
108  }
109 
110  strncat(header,"\n",BUFSIZ-1);
111 
112 
113 
114  blength = prof_size( plength, scale, bucket, &num_buckets );
115  prof_alloc( num_bufs, blength );
116 
117  if ( !TESTS_QUIET )
118  printf( "Overall event counts:\n" );
119 
120  for ( i = 0; i < num_events; i++ ) {
121  if ( ( retval =
122  PAPI_profil( profbuf[i], ( unsigned int ) blength, start, scale,
123  EventSet, events[i], thresh,
124  PAPI_PROFIL_POSIX | bucket ) ) != PAPI_OK ) {
125  if (retval == PAPI_EINVAL) {
126  test_warn( __FILE__, __LINE__, "Trying to profile with derived event", 1);
127  num_events=i;
128  break;
129  }
130  else {
131  printf("Failed with event %d %#x\n",i,events[i]);
132  test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
133  }
134  }
135  }
136 
137  if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
138  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
139 
140  my_main( );
141 
142  if ( ( retval = PAPI_stop( EventSet, values[0] ) ) != PAPI_OK )
143  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
144 
145  if ( !TESTS_QUIET ) {
146  printf( TAB1, "PAPI_TOT_CYC:", ( values[0] )[--event] );
147  if ( strcmp( hw_info->model_string, "POWER6" ) != 0 ) {
148  printf( TAB1, "PAPI_TOT_INS:", ( values[0] )[--event] );
149  }
150 #if defined(__powerpc__)
151  printf( TAB1, "PAPI_FP_INS", ( values[0] )[--event] );
152 #else
153  if ( strcmp( hw_info->model_string, "Intel Pentium III" ) != 0 ) {
154  printf( TAB1, "PAPI_FP_OPS:", ( values[0] )[--event] );
155  printf( TAB1, "PAPI_L2_TCM:", ( values[0] )[--event] );
156  }
157 #endif
158  }
159 
160  for ( i = 0; i < num_events; i++ ) {
161  if ( ( retval =
162  PAPI_profil( profbuf[i], ( unsigned int ) blength, start, scale,
163  EventSet, events[i], 0,
164  PAPI_PROFIL_POSIX ) ) != PAPI_OK )
165  test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
166  }
167 
168  prof_head( blength, bucket, num_buckets, header );
169  prof_out( start, num_events, bucket, num_buckets, scale );
170  retval = prof_check( num_bufs, bucket, num_buckets );
171  for ( i = 0; i < num_bufs; i++ ) {
172  free( profbuf[i] );
173  }
174  return retval;
175 }
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2232
#define PAPI_L2_TCM
Definition: fpapi.h:142
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_TOT_INS
Definition: fpapi.h:185
static int num_events
#define TAB1
Definition: papi_test.h:112
device[deviceId] domain[domainId] event
Definition: linux-cuda.c:306
#define MAX_TEST_EVENTS
Definition: papi_test.h:51
return PAPI_OK
Definition: linux-nvml.c:458
#define PAPI_FP_OPS
Definition: fpapi.h:237
#define PAPI_PROFIL_POSIX
Definition: fpapi.h:75
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define printf
Definition: papi_test.h:125
int TESTS_QUIET
Definition: test_utils.c:11
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:5316
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
#define PAPI_TOT_CYC
Definition: fpapi.h:194
free(dummyfile[xx])
static void my_main()
Definition: byte_profile.c:50
void * profbuf[5]
Definition: prof_utils.c:28
char events[MAX_EVENTS][BUFSIZ]
#define PAPI_FP_INS
Definition: fpapi.h:187
int EventSet
struct test_events_t test_events[]
Definition: test_utils.c:191
int prof_check(int n, int bucket, int num_buckets)
Definition: prof_utils.c:283
unsigned int event
Definition: papi_test.h:55
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:785
int PAPI_start(int EventSet)
Definition: papi.c:2026
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:23
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 180 of file byte_profile.c.

181 {
182  long length;
183  int mask;
184  int retval;
185  const PAPI_exe_info_t *prginfo;
186  caddr_t start, end;
187 
188  prof_init( argc, argv, &prginfo );
189 
191  if ( hw_info == NULL )
192  test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
193 
195 
196 #if defined(__powerpc__)
197  if ( strcmp( hw_info->model_string, "POWER6" ) == 0 )
198  mask = MASK_TOT_CYC | MASK_FP_INS;
199  else
201 #endif
202 
203 #if defined(ITANIUM2)
205 #endif
206  EventSet = add_test_events( &num_events, &mask, 0 );
208 
209 /* profile the cleara and my_main address space */
210  start = ( caddr_t ) cleara;
211  end = ( caddr_t ) my_dummy;
212 
213 /* Itanium and PowerPC64 processors return function descriptors instead
214  * of function addresses. You must dereference the descriptor to get the address.
215 */
216 #if defined(ITANIUM1) || defined(ITANIUM2) || defined(__powerpc64__)
217  start = ( caddr_t ) ( ( ( struct fdesc * ) start )->ip );
218  end = ( caddr_t ) ( ( ( struct fdesc * ) end )->ip );
219 #endif
220 
221  /* call dummy so it doesn't get optimized away */
222  retval = my_dummy( 1 );
223 
224  length = end - start;
225  if ( length < 0 )
226  test_fail( __FILE__, __LINE__, "Profile length < 0!", ( int ) length );
227 
229  ( "Test case byte_profile: Multi-event profiling at byte resolution.\n",
230  prginfo );
231  prof_print_prof_info( start, end, THRESHOLD, event_name );
232 
233  retval =
234  do_profile( start, ( unsigned ) length,
235  FULL_SCALE * 2, THRESHOLD,
236  PAPI_PROFIL_BUCKET_32, mask );
237 
238  remove_test_events( &EventSet, mask );
239 
240  if ( retval )
241  test_pass( __FILE__, values, 1 );
242  else
243  test_fail( __FILE__, __LINE__, "No information in buffers", 1 );
244  return 1;
245 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
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
struct in_addr * ip
Definition: iozone.c:20416
start
Definition: iozone.c:22736
static int num_events
get the executable&#39;s info
Definition: papi.h:702
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
char ** argv
Definition: iozone.c:1610
#define MASK_FP_INS
Definition: papi_test.h:47
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
static void cleara(double a[N])
Definition: byte_profile.c:34
#define FULL_SCALE
Definition: prof_utils.h:23
static int my_dummy(int i)
Definition: byte_profile.c:44
#define MASK_TOT_CYC
Definition: papi_test.h:49
#define MASK_FP_OPS
Definition: papi_test.h:33
int EventSet
#define MASK_TOT_INS
Definition: papi_test.h:48
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
#define MASK_L2_TCM
Definition: papi_test.h:43
#define MASK_L1_DCM
Definition: papi_test.h:44
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:785
static int do_profile(caddr_t start, unsigned long plength, unsigned scale, int thresh, int bucket, unsigned int mask)
Definition: byte_profile.c:68
#define PAPI_PROFIL_BUCKET_32
Definition: fpapi.h:80
#define THRESHOLD
Definition: earprofile.c:31
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
Definition: papi.c:6059
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
static const PAPI_hw_info_t * hw_info
Definition: byte_profile.c:23
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:277
int add_test_events(int *number, int *mask, int allow_derived)
Definition: test_utils.c:213

Here is the call graph for this function:

static int my_dummy ( int  i)
static

Definition at line 44 of file byte_profile.c.

45 {
46  return ( i + 1 );
47 }
int i
Definition: fileop.c:140

Here is the caller graph for this function:

static void my_main ( )
static

Definition at line 50 of file byte_profile.c.

51 {
52  int i, j;
53 
54  for ( j = 0; j < T; j++ ) {
55  for ( i = 0; i < N; i++ ) {
56  bb[i] = 0;
57  }
58  cleara( aa );
59  memset( aa, 0, sizeof ( aa ) );
60  for ( i = 0; i < N; i++ ) {
61  s += aa[i] * bb[i];
62  s2 += aa[i] * aa[i] + bb[i] * bb[i];
63  }
64  }
65 }
memset(eventId, 0, size)
#define T
Definition: byte_profile.c:28
double aa[N]
Definition: byte_profile.c:30
int i
Definition: fileop.c:140
static void cleara(double a[N])
Definition: byte_profile.c:34
s
Definition: iozone.c:20289
double bb[N]
Definition: byte_profile.c:30
double s2
Definition: byte_profile.c:31
#define N
Definition: byte_profile.c:27
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 30 of file byte_profile.c.

double bb[N]

Definition at line 30 of file byte_profile.c.

const PAPI_hw_info_t* hw_info
static

Definition at line 23 of file byte_profile.c.

int num_events = 0
static

Definition at line 25 of file byte_profile.c.

double s = 0

Definition at line 31 of file byte_profile.c.

double s2 = 0

Definition at line 31 of file byte_profile.c.