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

Go to the source code of this file.

Macros

#define NUM   16384
 

Functions

static void init_array (void)
 
static int do_malloc_work (long loop)
 
static int do_static_work (long loop)
 
static void measure_load_store (caddr_t start, caddr_t end)
 
static void measure_event (int index, PAPI_option_t *option)
 
int main (int argc, char **argv)
 

Variables

intparray1
 
intparray2
 
intparray3
 
int array1 [NUM]
 
int array2 [NUM]
 
int array3 [NUM]
 
char event_name [2][PAPI_MAX_STR_LEN]
 
int PAPI_event [2]
 
int EventSet = PAPI_NULL
 

Macro Definition Documentation

#define NUM   16384

Definition at line 13 of file data_range.c.

Function Documentation

static int do_malloc_work ( long  loop)
static

Definition at line 236 of file data_range.c.

237 {
238  int i;
239  int sum = 0;
240 
241  for ( i = 0; i < loop; i++ ) {
242  parray1[i] = i;
243  sum += parray1[i];
244  }
245 
246  for ( i = 0; i < loop; i++ ) {
247  parray2[i] = i;
248  sum += parray2[i];
249  }
250 
251  for ( i = 0; i < loop; i++ ) {
252  parray3[i] = i;
253  sum += parray3[i];
254  }
255 
256  return sum;
257 }
int * parray3
Definition: data_range.c:21
double loop(long n)
Definition: kufrin.c:19
int * parray1
Definition: data_range.c:21
int i
Definition: fileop.c:140
int * parray2
Definition: data_range.c:21

Here is the call graph for this function:

Here is the caller graph for this function:

static int do_static_work ( long  loop)
static

Definition at line 212 of file data_range.c.

213 {
214  int i;
215  int sum = 0;
216 
217  for ( i = 0; i < loop; i++ ) {
218  array1[i] = i;
219  sum += array1[i];
220  }
221 
222  for ( i = 0; i < loop; i++ ) {
223  array2[i] = i;
224  sum += array2[i];
225  }
226 
227  for ( i = 0; i < loop; i++ ) {
228  array3[i] = i;
229  sum += array3[i];
230  }
231 
232  return sum;
233 }
double loop(long n)
Definition: kufrin.c:19
int i
Definition: fileop.c:140
int array3[NUM]
Definition: data_range.c:22
int array2[NUM]
Definition: data_range.c:22
int array1[NUM]
Definition: data_range.c:22

Here is the call graph for this function:

Here is the caller graph for this function:

static void init_array ( void  )
static

Definition at line 192 of file data_range.c.

193 {
194  parray1 = ( int * ) malloc( NUM * sizeof ( int ) );
195  if ( parray1 == NULL )
196  test_fail( __FILE__, __LINE__, "No memory available!\n", 0 );
197  memset( parray1, 0x0, NUM * sizeof ( int ) );
198 
199  parray2 = ( int * ) malloc( NUM * sizeof ( int ) );
200  if ( parray2 == NULL )
201  test_fail( __FILE__, __LINE__, "No memory available!\n", 0 );
202  memset( parray2, 0x0, NUM * sizeof ( int ) );
203 
204  parray3 = ( int * ) malloc( NUM * sizeof ( int ) );
205  if ( parray3 == NULL )
206  test_fail( __FILE__, __LINE__, "No memory available!\n", 0 );
207  memset( parray3, 0x0, NUM * sizeof ( int ) );
208 
209 }
memset(eventId, 0, size)
int * parray3
Definition: data_range.c:21
int * parray1
Definition: data_range.c:21
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
#define NUM
Definition: data_range.c:13
int * parray2
Definition: data_range.c:21

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 28 of file data_range.c.

29 {
30  int retval;
31  const PAPI_exe_info_t *prginfo = NULL;
32  const PAPI_hw_info_t *hw_info;
33 
34  /* Set TESTS_QUIET variable */
35  tests_quiet( argc, argv );
36 
37 #if !defined(ITANIUM2) && !defined(ITANIUM3)
38  test_skip( __FILE__, __LINE__, "Currently only works on itanium2", 0 );
39  exit( 1 );
40 #endif
41 
42  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
43 
44  init_array( );
45  printf( "Malloc'd array pointers: %p %p %p\n", &parray1, &parray2,
46  &parray3 );
47  printf( "Malloc'd array addresses: %p %p %p\n", parray1, parray2,
48  parray3 );
49  printf( "Static array addresses: %p %p %p\n", &array1, &array2,
50  &array3 );
51 
52  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
53 
54  if ( ( retval =
56  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
57 
58  hw_info = PAPI_get_hardware_info( );
59  if ( hw_info == NULL )
60  test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
61 
62  prginfo = PAPI_get_executable_info( );
63  if ( prginfo == NULL )
64  test_fail( __FILE__, __LINE__, "PAPI_get_executable_info", 1 );
65 
66 #if defined(linux) && defined(__ia64__)
67  sprintf( event_name[0], "loads_retired" );
68  sprintf( event_name[1], "stores_retired" );
71 #else
72  test_skip( __FILE__, __LINE__, "only works for Itanium", PAPI_ENOSUPP );
73 #endif
74 
75  if ( ( retval = PAPI_create_eventset( &EventSet ) ) != PAPI_OK )
76  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
77 
78  retval = PAPI_cleanup_eventset( EventSet );
79  if ( retval != PAPI_OK )
80  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
81 
83  if ( retval != PAPI_OK )
84  test_fail( __FILE__, __LINE__, "PAPI_assign_eventset_component",
85  retval );
86 
87 /***************************************************************************************/
88  printf
89  ( "\n\nMeasure loads and stores on the pointers to the allocated arrays\n" );
90  printf( "Expected loads: %d; Expected stores: 0\n", NUM * 2 );
91  printf
92  ( "These loads result from accessing the pointers to compute array addresses.\n" );
93  printf
94  ( "They will likely disappear with higher levels of optimization.\n" );
95 
96  measure_load_store( ( caddr_t ) & parray1, ( caddr_t ) ( &parray1 + 1 ) );
97  measure_load_store( ( caddr_t ) & parray2, ( caddr_t ) ( &parray2 + 1 ) );
98  measure_load_store( ( caddr_t ) & parray3, ( caddr_t ) ( &parray3 + 1 ) );
99 /***************************************************************************************/
100  printf
101  ( "\n\nMeasure loads and stores on the allocated arrays themselves\n" );
102  printf( "Expected loads: %d; Expected stores: %d\n", NUM, NUM );
103 
104  measure_load_store( ( caddr_t ) parray1, ( caddr_t ) ( parray1 + NUM ) );
105  measure_load_store( ( caddr_t ) parray2, ( caddr_t ) ( parray2 + NUM ) );
106  measure_load_store( ( caddr_t ) parray3, ( caddr_t ) ( parray3 + NUM ) );
107 /***************************************************************************************/
108  printf( "\n\nMeasure loads and stores on the static arrays\n" );
109  printf
110  ( "These values will differ from the expected values by the size of the offsets.\n" );
111  printf( "Expected loads: %d; Expected stores: %d\n", NUM, NUM );
112 
113  measure_load_store( ( caddr_t ) array1, ( caddr_t ) ( array1 + NUM ) );
114  measure_load_store( ( caddr_t ) array2, ( caddr_t ) ( array2 + NUM ) );
115  measure_load_store( ( caddr_t ) array3, ( caddr_t ) ( array3 + NUM ) );
116 /***************************************************************************************/
117 
118  retval = PAPI_destroy_eventset( &EventSet );
119  if ( retval != PAPI_OK )
120  test_fail( __FILE__, __LINE__, "PAPI_destroy", retval );
121 
122  free( parray1 );
123  free( parray2 );
124  free( parray3 );
125 
126  test_pass( __FILE__, NULL, 0 );
127 
128  exit( 1 );
129 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
int PAPI_event[2]
Definition: data_range.c:24
int * parray3
Definition: data_range.c:21
Hardware info structure.
Definition: papi.h:775
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
get the executable&#39;s info
Definition: papi.h:702
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
int * parray1
Definition: data_range.c:21
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:495
#define PAPI_ENOSUPP
Definition: fpapi.h:123
const PAPI_exe_info_t * PAPI_get_executable_info(void)
Definition: papi.c:5988
free(dummyfile[xx])
#define NUM
Definition: data_range.c:13
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2805
int PAPI_assign_eventset_component(int EventSet, int cidx)
Definition: papi.c:1467
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1406
int array3[NUM]
Definition: data_range.c:22
static void measure_load_store(caddr_t start, caddr_t end)
Definition: data_range.c:132
int PAPI_event_name_to_code(char *in, int *out)
Definition: papi.c:1008
int EventSet
int array2[NUM]
Definition: data_range.c:22
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1944
static void init_array(void)
Definition: data_range.c:192
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
Definition: papi.c:6059
ssize_t retval
Definition: libasync.c:338
static const PAPI_hw_info_t * hw_info
Definition: byte_profile.c:23
int * parray2
Definition: data_range.c:21
void exit()
int array1[NUM]
Definition: data_range.c:22

Here is the call graph for this function:

static void measure_event ( int  index,
PAPI_option_t option 
)
static

Definition at line 151 of file data_range.c.

152 {
153  int retval;
154  long long value;
155 
156  if ( ( retval = PAPI_add_event( EventSet, PAPI_event[index] ) ) != PAPI_OK )
157  test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
158 
159  if ( index == 0 ) {
160 /* if ((retval = PAPI_get_opt(PAPI_DATA_ADDRESS, option)) != PAPI_OK)
161  test_fail(__FILE__, __LINE__, "PAPI_get_opt(PAPI_DATA_ADDRESS)", retval);
162 */
163  printf
164  ( "Requested Start Address: %p; Start Offset: %#5x; Actual Start Address: %p\n",
165  option->addr.start, option->addr.start_off,
166  option->addr.start - option->addr.start_off );
167  printf
168  ( "Requested End Address: %p; End Offset: %#5x; Actual End Address: %p\n",
169  option->addr.end, option->addr.end_off,
170  option->addr.end + option->addr.end_off );
171  }
172 
173  retval = PAPI_start( EventSet );
174  if ( retval != PAPI_OK ) {
175  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
176  }
177  do_malloc_work( NUM );
178  do_static_work( NUM );
179  retval = PAPI_stop( EventSet, &value );
180  if ( retval != PAPI_OK ) {
181  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
182  }
183 
184  printf( "%s: %lld\n", event_name[index], value );
185 
186  if ( ( retval =
187  PAPI_remove_event( EventSet, PAPI_event[index] ) ) != PAPI_OK )
188  test_fail( __FILE__, __LINE__, "PAPI_remove_event", retval );
189 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2232
int PAPI_event[2]
Definition: data_range.c:24
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1604
static int do_malloc_work(long loop)
Definition: data_range.c:236
int PAPI_remove_event(int EventSet, int EventCode)
Definition: papi.c:1699
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
void double value
Definition: iozone.c:18781
PAPI_addr_range_option_t addr
Definition: papi.h:860
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
#define NUM
Definition: data_range.c:13
int EventSet
int PAPI_start(int EventSet)
Definition: papi.c:2026
ssize_t retval
Definition: libasync.c:338
static int do_static_work(long loop)
Definition: data_range.c:212

Here is the call graph for this function:

Here is the caller graph for this function:

static void measure_load_store ( caddr_t  start,
caddr_t  end 
)
static

Definition at line 132 of file data_range.c.

133 {
134  PAPI_option_t option;
135  int retval;
136 
137  /* set up the optional address structure for starting and ending data addresses */
138  option.addr.eventset = EventSet;
139  option.addr.start = start;
140  option.addr.end = end;
141 
142  if ( ( retval = PAPI_set_opt( PAPI_DATA_ADDRESS, &option ) ) != PAPI_OK )
143  test_fail( __FILE__, __LINE__, "PAPI_set_opt(PAPI_DATA_ADDRESS)",
144  retval );
145 
146  measure_event( 0, &option );
147  measure_event( 1, &option );
148 }
start
Definition: iozone.c:22736
#define PAPI_DATA_ADDRESS
Definition: papi.h:450
return PAPI_OK
Definition: linux-nvml.c:458
A pointer to the following is passed to PAPI_set/get_opt()
Definition: papi.h:843
int PAPI_set_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:3371
PAPI_addr_range_option_t addr
Definition: papi.h:860
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int EventSet
static void measure_event(int index, PAPI_option_t *option)
Definition: data_range.c:151
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

int array1[NUM]

Definition at line 22 of file data_range.c.

int array2[NUM]

Definition at line 22 of file data_range.c.

int array3[NUM]

Definition at line 22 of file data_range.c.

char event_name[2][PAPI_MAX_STR_LEN]

Definition at line 23 of file data_range.c.

int EventSet = PAPI_NULL

Definition at line 25 of file data_range.c.

int PAPI_event[2]

Definition at line 24 of file data_range.c.

int* parray1

Definition at line 21 of file data_range.c.

int * parray2

Definition at line 21 of file data_range.c.

int * parray3

Definition at line 21 of file data_range.c.