PAPI  5.3.2.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)
 

Variables

int TESTS_QUIET
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 12 of file p4_lst_ins.c.

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

Here is the call graph for this function:

Variable Documentation

int TESTS_QUIET

Definition at line 11 of file test_utils.c.