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.

00013 {
00014     int retval, num_tests = 6, tmp;
00015     long long **values;
00016     int EventSet = PAPI_NULL;
00017     const PAPI_hw_info_t *hw_info;
00018 
00019     tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */
00020 
00021     retval = PAPI_library_init( PAPI_VER_CURRENT );
00022     if ( retval != PAPI_VER_CURRENT )
00023         test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
00024 
00025     hw_info = PAPI_get_hardware_info(  );
00026     if ( hw_info == NULL )
00027         test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
00028 
00029     if ( hw_info->vendor == PAPI_VENDOR_INTEL ) {
00030         /* Check for Pentium4 */
00031         if ( hw_info->cpuid_family != 15 ) {
00032         test_skip( __FILE__, __LINE__,
00033             "This test is intended only for Pentium 4.", 1 );
00034         }
00035     } else {
00036         test_skip( __FILE__, __LINE__, 
00037             "This test is intended only for Pentium 4.", 1 );
00038     }
00039 
00040     retval = PAPI_create_eventset( &EventSet );
00041     if ( retval != PAPI_OK )
00042         test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
00043 
00044     values = allocate_test_space( num_tests, 2 );
00045 
00046 /* First test: just PAPI_LD_INS */
00047     retval = PAPI_add_event( EventSet, PAPI_LD_INS );
00048     if ( retval != PAPI_OK )
00049         test_fail( __FILE__, __LINE__, "PAPI_add_event: PAPI_LD_INS", retval );
00050 
00051     retval = PAPI_start( EventSet );
00052     if ( retval != PAPI_OK )
00053         test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00054 
00055     do_flops( NUM_FLOPS / 10 );
00056 
00057     retval = PAPI_stop( EventSet, values[0] );
00058     if ( retval != PAPI_OK )
00059         test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00060 
00061     retval = PAPI_remove_event( EventSet, PAPI_LD_INS );
00062     if ( retval != PAPI_OK )
00063         test_fail( __FILE__, __LINE__, "PAPI_remove_event: PAPI_LD_INS",
00064                    retval );
00065 
00066 /* Second test: just PAPI_SR_INS */
00067     retval = PAPI_add_event( EventSet, PAPI_SR_INS );
00068     if ( retval != PAPI_OK )
00069         test_fail( __FILE__, __LINE__, "PAPI_add_event: PAPI_SR_INS", retval );
00070 
00071     retval = PAPI_start( EventSet );
00072     if ( retval != PAPI_OK )
00073         test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00074 
00075     do_flops( NUM_FLOPS / 10 );
00076 
00077     retval = PAPI_stop( EventSet, values[1] );
00078     if ( retval != PAPI_OK )
00079         test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00080 
00081     retval = PAPI_remove_event( EventSet, PAPI_SR_INS );
00082     if ( retval != PAPI_OK )
00083         test_fail( __FILE__, __LINE__, "PAPI_remove_event: PAPI_SR_INS",
00084                    retval );
00085 
00086 /* Third test: just PAPI_LST_INS */
00087     retval = PAPI_add_event( EventSet, PAPI_LST_INS );
00088     if ( retval != PAPI_OK )
00089         test_fail( __FILE__, __LINE__, "PAPI_add_event: PAPI_LST_INS", retval );
00090 
00091     retval = PAPI_start( EventSet );
00092     if ( retval != PAPI_OK )
00093         test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00094 
00095     do_flops( NUM_FLOPS / 10 );
00096 
00097     retval = PAPI_stop( EventSet, values[2] );
00098     if ( retval != PAPI_OK )
00099         test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00100 
00101 /* Fourth test: PAPI_LST_INS and PAPI_LD_INS */
00102     retval = PAPI_add_event( EventSet, PAPI_LD_INS );
00103     if ( retval != PAPI_OK )
00104         test_fail( __FILE__, __LINE__, "PAPI_add_event: PAPI_LD_INS", retval );
00105 
00106     retval = PAPI_start( EventSet );
00107     if ( retval != PAPI_OK )
00108         test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00109 
00110     do_flops( NUM_FLOPS / 10 );
00111 
00112     retval = PAPI_stop( EventSet, values[3] );
00113     if ( retval != PAPI_OK )
00114         test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00115 
00116     retval = PAPI_remove_event( EventSet, PAPI_LD_INS );
00117     if ( retval != PAPI_OK )
00118         test_fail( __FILE__, __LINE__, "PAPI_remove_event: PAPI_LD_INS",
00119                    retval );
00120 
00121 /* Fifth test: PAPI_LST_INS and PAPI_SR_INS */
00122     retval = PAPI_add_event( EventSet, PAPI_SR_INS );
00123     if ( retval != PAPI_OK )
00124         test_fail( __FILE__, __LINE__, "PAPI_add_event: PAPI_SR_INS", retval );
00125 
00126     retval = PAPI_start( EventSet );
00127     if ( retval != PAPI_OK )
00128         test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00129 
00130     do_flops( NUM_FLOPS / 10 );
00131 
00132     retval = PAPI_stop( EventSet, values[4] );
00133     if ( retval != PAPI_OK )
00134         test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00135 
00136     retval = PAPI_remove_event( EventSet, PAPI_SR_INS );
00137     if ( retval != PAPI_OK )
00138         test_fail( __FILE__, __LINE__, "PAPI_remove_event: PAPI_SR_INS",
00139                    retval );
00140 
00141     retval = PAPI_remove_event( EventSet, PAPI_LST_INS );
00142     if ( retval != PAPI_OK )
00143         test_fail( __FILE__, __LINE__, "PAPI_remove_event: PAPI_LST_INS",
00144                    retval );
00145 
00146 /* Sixth test: PAPI_LD_INS and PAPI_SR_INS */
00147     retval = PAPI_add_event( EventSet, PAPI_LD_INS );
00148     if ( retval != PAPI_OK )
00149         test_fail( __FILE__, __LINE__, "PAPI_add_event: PAPI_LD_INS", retval );
00150 
00151     retval = PAPI_add_event( EventSet, PAPI_SR_INS );
00152     if ( retval != PAPI_OK )
00153         test_fail( __FILE__, __LINE__, "PAPI_add_event: PAPI_SR_INS", retval );
00154 
00155     retval = PAPI_start( EventSet );
00156     if ( retval != PAPI_OK )
00157         test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00158 
00159     do_flops( NUM_FLOPS / 10 );
00160 
00161     retval = PAPI_stop( EventSet, values[5] );
00162     if ( retval != PAPI_OK )
00163         test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00164 
00165     retval = PAPI_remove_event( EventSet, PAPI_LD_INS );
00166     if ( retval != PAPI_OK )
00167         test_fail( __FILE__, __LINE__, "PAPI_remove_event: PAPI_LD_INS",
00168                    retval );
00169 
00170     retval = PAPI_remove_event( EventSet, PAPI_SR_INS );
00171     if ( retval != PAPI_OK )
00172         test_fail( __FILE__, __LINE__, "PAPI_remove_event: PAPI_SR_INS",
00173                    retval );
00174 
00175 
00176 
00177     if ( !TESTS_QUIET ) {
00178         printf( "Pentium 4 Load / Store tests.\n" );
00179         printf
00180             ( "These PAPI events are counted by setting a tag at the front of the pipeline,\n" );
00181         printf
00182             ( "and counting tags at the back of the pipeline. All the tags are the same 'color'\n" );
00183         printf
00184             ( "and can't be distinguished from each other. Therefore, PAPI_LD_INS and PAPI_SR_INS\n" );
00185         printf
00186             ( "cannot be counted with the other two events, or the answer will always == PAPI_LST_INS.\n" );
00187         printf
00188             ( "-------------------------------------------------------------------------------------------\n" );
00189         tmp = PAPI_get_opt( PAPI_DEFDOM, NULL );
00190         printf( "Default domain is: %d (%s)\n", tmp,
00191                 stringify_all_domains( tmp ) );
00192         tmp = PAPI_get_opt( PAPI_DEFGRN, NULL );
00193         printf( "Default granularity is: %d (%s)\n", tmp,
00194                 stringify_granularity( tmp ) );
00195         printf( "Using %d iterations of c += a*b\n", NUM_FLOPS / 10 );
00196         printf
00197             ( "-------------------------------------------------------------------------------------------\n" );
00198 
00199         printf
00200             ( "Test:                1            2            3            4            5            6\n" );
00201         printf( "%s %12lld %12s %12s %12lld %12s %12lld\n", "PAPI_LD_INS: ",
00202                 ( values[0] )[0], "------", "------", ( values[3] )[1],
00203                 "------", ( values[5] )[0] );
00204         printf( "%s %12s %12lld %12s %12s %12lld %12lld\n", "PAPI_SR_INS: ",
00205                 "------", ( values[1] )[0], "------", "------",
00206                 ( values[4] )[1], ( values[5] )[1] );
00207         printf( "%s %12s %12s %12lld %12lld %12lld %12s\n", "PAPI_LST_INS:",
00208                 "------", "------", ( values[2] )[0], ( values[3] )[0],
00209                 ( values[4] )[0], "------" );
00210         printf
00211             ( "-------------------------------------------------------------------------------------------\n" );
00212 
00213         printf( "Test 1: PAPI_LD_INS only.\n" );
00214         printf( "Test 2: PAPI_SR_INS only.\n" );
00215         printf( "Test 3: PAPI_LST_INS only.\n" );
00216         printf( "Test 4: PAPI_LD_INS and PAPI_LST_INS.\n" );
00217         printf( "Test 5: PAPI_SR_INS and PAPI_LST_INS.\n" );
00218         printf( "Test 6: PAPI_LD_INS and PAPI_SR_INS.\n" );
00219         printf
00220             ( "Verification: Values within each column should be the same.\n" );
00221         printf( "              R3C3 ~= (R1C1 + R2C2) ~= all other entries.\n" );
00222     }
00223 
00224     test_pass( __FILE__, values, num_tests );
00225     exit( 1 );
00226 }

Here is the call graph for this function:


Variable Documentation

Definition at line 11 of file test_utils.c.


Generated on 26 Jan 2016 for PAPI by  doxygen 1.6.1