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

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 16 of file p4_lst_ins.c.

17 {
18  int retval, num_tests = 6, tmp;
19  long long **values;
20  int EventSet = PAPI_NULL;
21  const PAPI_hw_info_t *hw_info;
22 
23  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
24 
26  if ( retval != PAPI_VER_CURRENT )
27  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
28 
29  hw_info = PAPI_get_hardware_info( );
30  if ( hw_info == NULL )
31  test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
32 
33  if ( hw_info->vendor == PAPI_VENDOR_INTEL ) {
34  /* Check for Pentium4 */
35  if ( hw_info->cpuid_family != 15 ) {
36  test_skip( __FILE__, __LINE__,
37  "This test is intended only for Pentium 4.", 1 );
38  }
39  } else {
40  test_skip( __FILE__, __LINE__,
41  "This test is intended only for Pentium 4.", 1 );
42  }
43 
44  retval = PAPI_create_eventset( &EventSet );
45  if ( retval != PAPI_OK )
46  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
47 
48  values = allocate_test_space( num_tests, 2 );
49 
50 /* First test: just PAPI_LD_INS */
51  retval = PAPI_add_event( EventSet, PAPI_LD_INS );
52  if ( retval != PAPI_OK )
53  test_fail( __FILE__, __LINE__, "PAPI_add_event: PAPI_LD_INS", retval );
54 
55  retval = PAPI_start( EventSet );
56  if ( retval != PAPI_OK )
57  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
58 
59  do_flops( NUM_FLOPS / 10 );
60 
61  retval = PAPI_stop( EventSet, values[0] );
62  if ( retval != PAPI_OK )
63  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
64 
65  retval = PAPI_remove_event( EventSet, PAPI_LD_INS );
66  if ( retval != PAPI_OK )
67  test_fail( __FILE__, __LINE__, "PAPI_remove_event: PAPI_LD_INS",
68  retval );
69 
70 /* Second test: just PAPI_SR_INS */
71  retval = PAPI_add_event( EventSet, PAPI_SR_INS );
72  if ( retval != PAPI_OK )
73  test_fail( __FILE__, __LINE__, "PAPI_add_event: PAPI_SR_INS", retval );
74 
75  retval = PAPI_start( EventSet );
76  if ( retval != PAPI_OK )
77  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
78 
79  do_flops( NUM_FLOPS / 10 );
80 
81  retval = PAPI_stop( EventSet, values[1] );
82  if ( retval != PAPI_OK )
83  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
84 
85  retval = PAPI_remove_event( EventSet, PAPI_SR_INS );
86  if ( retval != PAPI_OK )
87  test_fail( __FILE__, __LINE__, "PAPI_remove_event: PAPI_SR_INS",
88  retval );
89 
90 /* Third test: just PAPI_LST_INS */
91  retval = PAPI_add_event( EventSet, PAPI_LST_INS );
92  if ( retval != PAPI_OK )
93  test_fail( __FILE__, __LINE__, "PAPI_add_event: PAPI_LST_INS", retval );
94 
95  retval = PAPI_start( EventSet );
96  if ( retval != PAPI_OK )
97  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
98 
99  do_flops( NUM_FLOPS / 10 );
100 
101  retval = PAPI_stop( EventSet, values[2] );
102  if ( retval != PAPI_OK )
103  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
104 
105 /* Fourth test: PAPI_LST_INS and PAPI_LD_INS */
106  retval = PAPI_add_event( EventSet, PAPI_LD_INS );
107  if ( retval != PAPI_OK )
108  test_fail( __FILE__, __LINE__, "PAPI_add_event: PAPI_LD_INS", retval );
109 
110  retval = PAPI_start( EventSet );
111  if ( retval != PAPI_OK )
112  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
113 
114  do_flops( NUM_FLOPS / 10 );
115 
116  retval = PAPI_stop( EventSet, values[3] );
117  if ( retval != PAPI_OK )
118  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
119 
120  retval = PAPI_remove_event( EventSet, PAPI_LD_INS );
121  if ( retval != PAPI_OK )
122  test_fail( __FILE__, __LINE__, "PAPI_remove_event: PAPI_LD_INS",
123  retval );
124 
125 /* Fifth test: PAPI_LST_INS and PAPI_SR_INS */
126  retval = PAPI_add_event( EventSet, PAPI_SR_INS );
127  if ( retval != PAPI_OK )
128  test_fail( __FILE__, __LINE__, "PAPI_add_event: PAPI_SR_INS", retval );
129 
130  retval = PAPI_start( EventSet );
131  if ( retval != PAPI_OK )
132  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
133 
134  do_flops( NUM_FLOPS / 10 );
135 
136  retval = PAPI_stop( EventSet, values[4] );
137  if ( retval != PAPI_OK )
138  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
139 
140  retval = PAPI_remove_event( EventSet, PAPI_SR_INS );
141  if ( retval != PAPI_OK )
142  test_fail( __FILE__, __LINE__, "PAPI_remove_event: PAPI_SR_INS",
143  retval );
144 
145  retval = PAPI_remove_event( EventSet, PAPI_LST_INS );
146  if ( retval != PAPI_OK )
147  test_fail( __FILE__, __LINE__, "PAPI_remove_event: PAPI_LST_INS",
148  retval );
149 
150 /* Sixth test: PAPI_LD_INS and PAPI_SR_INS */
151  retval = PAPI_add_event( EventSet, PAPI_LD_INS );
152  if ( retval != PAPI_OK )
153  test_fail( __FILE__, __LINE__, "PAPI_add_event: PAPI_LD_INS", retval );
154 
155  retval = PAPI_add_event( EventSet, PAPI_SR_INS );
156  if ( retval != PAPI_OK )
157  test_fail( __FILE__, __LINE__, "PAPI_add_event: PAPI_SR_INS", retval );
158 
159  retval = PAPI_start( EventSet );
160  if ( retval != PAPI_OK )
161  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
162 
163  do_flops( NUM_FLOPS / 10 );
164 
165  retval = PAPI_stop( EventSet, values[5] );
166  if ( retval != PAPI_OK )
167  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
168 
169  retval = PAPI_remove_event( EventSet, PAPI_LD_INS );
170  if ( retval != PAPI_OK )
171  test_fail( __FILE__, __LINE__, "PAPI_remove_event: PAPI_LD_INS",
172  retval );
173 
174  retval = PAPI_remove_event( EventSet, PAPI_SR_INS );
175  if ( retval != PAPI_OK )
176  test_fail( __FILE__, __LINE__, "PAPI_remove_event: PAPI_SR_INS",
177  retval );
178 
179 
180 
181  if ( !TESTS_QUIET ) {
182  printf( "Pentium 4 Load / Store tests.\n" );
183  printf
184  ( "These PAPI events are counted by setting a tag at the front of the pipeline,\n" );
185  printf
186  ( "and counting tags at the back of the pipeline. All the tags are the same 'color'\n" );
187  printf
188  ( "and can't be distinguished from each other. Therefore, PAPI_LD_INS and PAPI_SR_INS\n" );
189  printf
190  ( "cannot be counted with the other two events, or the answer will always == PAPI_LST_INS.\n" );
191  printf
192  ( "-------------------------------------------------------------------------------------------\n" );
193  tmp = PAPI_get_opt( PAPI_DEFDOM, NULL );
194  printf( "Default domain is: %d (%s)\n", tmp,
196  tmp = PAPI_get_opt( PAPI_DEFGRN, NULL );
197  printf( "Default granularity is: %d (%s)\n", tmp,
199  printf( "Using %d iterations of c += a*b\n", NUM_FLOPS / 10 );
200  printf
201  ( "-------------------------------------------------------------------------------------------\n" );
202 
203  printf
204  ( "Test: 1 2 3 4 5 6\n" );
205  printf( "%s %12lld %12s %12s %12lld %12s %12lld\n", "PAPI_LD_INS: ",
206  ( values[0] )[0], "------", "------", ( values[3] )[1],
207  "------", ( values[5] )[0] );
208  printf( "%s %12s %12lld %12s %12s %12lld %12lld\n", "PAPI_SR_INS: ",
209  "------", ( values[1] )[0], "------", "------",
210  ( values[4] )[1], ( values[5] )[1] );
211  printf( "%s %12s %12s %12lld %12lld %12lld %12s\n", "PAPI_LST_INS:",
212  "------", "------", ( values[2] )[0], ( values[3] )[0],
213  ( values[4] )[0], "------" );
214  printf
215  ( "-------------------------------------------------------------------------------------------\n" );
216 
217  printf( "Test 1: PAPI_LD_INS only.\n" );
218  printf( "Test 2: PAPI_SR_INS only.\n" );
219  printf( "Test 3: PAPI_LST_INS only.\n" );
220  printf( "Test 4: PAPI_LD_INS and PAPI_LST_INS.\n" );
221  printf( "Test 5: PAPI_SR_INS and PAPI_LST_INS.\n" );
222  printf( "Test 6: PAPI_LD_INS and PAPI_SR_INS.\n" );
223  printf
224  ( "Verification: Values within each column should be the same.\n" );
225  printf( " R3C3 ~= (R1C1 + R2C2) ~= all other entries.\n" );
226  }
227 
228  test_pass( __FILE__ );
229 
230  return 0;
231 
232 }
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
void test_pass(const char *filename)
Definition: test_utils.c:432
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
Hardware info structure.
Definition: papi.h:780
#define PAPI_LST_INS
int PAPI_remove_event(int EventSet, int EventCode)
Definition: papi.c:1758
char * stringify_granularity(int granularity)
Definition: test_utils.c:353
#define PAPI_NULL
Definition: papi.h:292
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
#define NUM_FLOPS
Definition: sdsc-mpx.c:24
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
int PAPI_library_init(int version)
Definition: papi.c:500
char * stringify_all_domains(int domains)
Definition: test_utils.c:293
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4143
#define PAPI_LD_INS
#define PAPI_DEFGRN
Definition: papi.h:434
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
int cpuid_family
Definition: papi.h:792
int num_tests
Definition: zero_fork.c:53
#define PAPI_VENDOR_INTEL
Definition: papi.h:348
void do_flops(int n)
Definition: multiplex.c:23
int vendor
Definition: papi.h:787
printf("\tTry: -i 0 -i 1 \n\n")
int TESTS_QUIET
Definition: test_utils.c:18
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
#define PAPI_DEFDOM
Definition: papi.h:432
int PAPI_start(int EventSet)
Definition: papi.c:2096
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
#define PAPI_SR_INS
ssize_t retval
Definition: libasync.c:338
long long tmp
Definition: iozone.c:12031
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

Here is the call graph for this function: