tenth.c File Reference

Include dependency graph for tenth.c:

Go to the source code of this file.

Defines

#define ITERS   100
#define CACHE_LEVEL   "PAPI_L1_TCM"
#define EVT1   PAPI_L1_TCM
#define EVT2   PAPI_L1_ICM
#define EVT3   PAPI_L1_DCM
#define EVT1_STR   "PAPI_L1_TCM"
#define EVT2_STR   "PAPI_L1_ICM"
#define EVT3_STR   "PAPI_L1_DCM"
#define MASK1   MASK_L1_TCM
#define MASK2   MASK_L1_ICM
#define MASK3   MASK_L1_DCM

Functions

int main (int argc, char **argv)

Variables

int TESTS_QUIET

Define Documentation

#define CACHE_LEVEL   "PAPI_L1_TCM"

Definition at line 46 of file tenth.c.

#define EVT1   PAPI_L1_TCM

Definition at line 47 of file tenth.c.

#define EVT1_STR   "PAPI_L1_TCM"

Definition at line 50 of file tenth.c.

#define EVT2   PAPI_L1_ICM

Definition at line 48 of file tenth.c.

#define EVT2_STR   "PAPI_L1_ICM"

Definition at line 51 of file tenth.c.

#define EVT3   PAPI_L1_DCM

Definition at line 49 of file tenth.c.

#define EVT3_STR   "PAPI_L1_DCM"

Definition at line 52 of file tenth.c.

#define ITERS   100

Definition at line 6 of file tenth.c.

#define MASK1   MASK_L1_TCM

Definition at line 53 of file tenth.c.

#define MASK2   MASK_L1_ICM

Definition at line 54 of file tenth.c.

#define MASK3   MASK_L1_DCM

Definition at line 55 of file tenth.c.


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 64 of file tenth.c.

00065 {
00066     int retval, num_tests = 30, tmp;
00067     int EventSet1 = PAPI_NULL;
00068     int EventSet2 = PAPI_NULL;
00069     int EventSet3 = PAPI_NULL;
00070     int mask1 = MASK1;
00071     int mask2 = MASK2;
00072     int mask3 = MASK3;
00073     int num_events1;
00074     int num_events2;
00075     int num_events3;
00076     long long **values;
00077     int i, j;
00078     long long min[3];
00079     long long max[3];
00080     long long sum[3];
00081 
00082     tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */
00083 
00084     retval = PAPI_library_init( PAPI_VER_CURRENT );
00085     if ( retval != PAPI_VER_CURRENT )
00086         test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
00087 
00088     /* Make sure that required resources are available */
00089     /* Skip (don't fail!) if they are not */
00090     retval = PAPI_query_event( EVT1 );
00091     if ( retval != PAPI_OK )
00092         test_skip( __FILE__, __LINE__, EVT1_STR, retval );
00093 
00094     retval = PAPI_query_event( EVT2 );
00095     if ( retval != PAPI_OK )
00096         test_skip( __FILE__, __LINE__, EVT2_STR, retval );
00097 
00098     retval = PAPI_query_event( EVT3 );
00099     if ( retval != PAPI_OK )
00100         test_skip( __FILE__, __LINE__, EVT3_STR, retval );
00101 
00102 
00103     EventSet1 = add_test_events( &num_events1, &mask1, 1 );
00104     EventSet2 = add_test_events( &num_events2, &mask2, 1 );
00105     EventSet3 = add_test_events( &num_events3, &mask3, 1 );
00106 
00107     values = allocate_test_space( num_tests, 1 );
00108 
00109     /* Warm me up */
00110     do_l1misses( ITERS );
00111     do_misses( 1, 1024 * 1024 * 4 );
00112 
00113     for ( i = 0; i < 10; i++ ) {
00114         retval = PAPI_start( EventSet1 );
00115         if ( retval != PAPI_OK )
00116             test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00117 
00118         do_l1misses( ITERS );
00119         do_misses( 1, 1024 * 1024 * 4 );
00120 
00121         retval = PAPI_stop( EventSet1, values[( i * 3 ) + 0] );
00122         if ( retval != PAPI_OK )
00123             test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00124 
00125         retval = PAPI_start( EventSet2 );
00126         if ( retval != PAPI_OK )
00127             test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00128 
00129         do_l1misses( ITERS );
00130         do_misses( 1, 1024 * 1024 * 4 );
00131 
00132         retval = PAPI_stop( EventSet2, values[( i * 3 ) + 1] );
00133         if ( retval != PAPI_OK )
00134             test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00135 
00136         retval = PAPI_start( EventSet3 );
00137         if ( retval != PAPI_OK )
00138             test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00139 
00140         do_l1misses( ITERS );
00141         do_misses( 1, 1024 * 1024 * 4 );
00142 
00143         retval = PAPI_stop( EventSet3, values[( i * 3 ) + 2] );
00144         if ( retval != PAPI_OK )
00145             test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00146     }
00147 
00148     remove_test_events( &EventSet1, mask1 );
00149     remove_test_events( &EventSet2, mask2 );
00150     remove_test_events( &EventSet3, mask3 );
00151 
00152     for ( j = 0; j < 3; j++ ) {
00153         min[j] = 65535;
00154         max[j] = sum[j] = 0;
00155     }
00156     for ( i = 0; i < 10; i++ ) {
00157         for ( j = 0; j < 3; j++ ) {
00158             if ( min[j] > values[( i * 3 ) + j][0] )
00159                 min[j] = values[( i * 3 ) + j][0];
00160             if ( max[j] < values[( i * 3 ) + j][0] )
00161                 max[j] = values[( i * 3 ) + j][0];
00162             sum[j] += values[( i * 3 ) + j][0];
00163         }
00164     }
00165 
00166     if ( !TESTS_QUIET ) {
00167         printf( "Test case 10: start, stop for derived event %s.\n",
00168                 CACHE_LEVEL );
00169         printf( "--------------------------------------------------------\n" );
00170         tmp = PAPI_get_opt( PAPI_DEFDOM, NULL );
00171         printf( "Default domain is: %d (%s)\n", tmp,
00172                 stringify_all_domains( tmp ) );
00173         tmp = PAPI_get_opt( PAPI_DEFGRN, NULL );
00174         printf( "Default granularity is: %d (%s)\n", tmp,
00175                 stringify_granularity( tmp ) );
00176         printf( "Using %d iterations of c += a*b\n", ITERS );
00177         printf( "Repeated 10 times\n" );
00178         printf
00179             ( "-------------------------------------------------------------------------\n" );
00180 /* 
00181       for (i=0;i<10;i++) {
00182          printf("Test type   : %12s%13s%13s\n", "1", "2", "3");
00183          printf(TAB3, EVT1_STR, values[(i*3)+0][0], (long long)0, (long long)0);
00184          printf(TAB3, EVT2_STR, (long long)0, values[(i*3)+1][0], (long long)0);
00185          printf(TAB3, EVT3_STR, (long long)0, (long long)0, values[(i*3)+2][0]);
00186          printf
00187             ("-------------------------------------------------------------------------\n");
00188       }
00189 */
00190         printf( "Test type   : %12s%13s%13s\n", "min", "max", "sum" );
00191         printf( TAB3, EVT1_STR, min[0], max[0], sum[0] );
00192         printf( TAB3, EVT2_STR, min[1], max[1], sum[1] );
00193         printf( TAB3, EVT3_STR, min[2], max[2], sum[2] );
00194         printf
00195             ( "-------------------------------------------------------------------------\n" );
00196         printf( "Verification:\n" );
00197 #if defined(sun) && defined(sparc)
00198         printf( TAB1, "Sum 1 approximately equals sum 2 - sum 3 or",
00199                 ( sum[1] - sum[2] ) );
00200 #else
00201         printf( TAB1, "Sum 1 approximately equals sum 2 + sum 3 or",
00202                 ( sum[1] + sum[2] ) );
00203 #endif
00204     }
00205 
00206     {
00207         long long tmin, tmax;
00208 
00209 #if defined(sun) && defined(sparc)
00210         tmax = ( long long ) ( sum[1] - sum[2] );
00211 #else
00212         tmax = ( long long ) ( sum[1] + sum[2] );
00213 #endif
00214 
00215         printf( "percent error: %f\n",
00216                         (( float )  abs( ( int ) ( tmax - sum[0] ) ) / (float)  sum[0] ) * 100.0 );
00217         tmin = ( long long ) ( ( double ) tmax * 0.8 );
00218         tmax = ( long long ) ( ( double ) tmax * 1.2 );
00219         if ( sum[0] > tmax || sum[0] < tmin )
00220             test_fail( __FILE__, __LINE__, CACHE_LEVEL, 1 );
00221     }
00222     test_pass( __FILE__, values, num_tests );
00223     exit( 1 );
00224 }

Here is the call graph for this function:


Variable Documentation

Definition at line 11 of file test_utils.c.


Generated on 8 Sep 2016 for PAPI by  doxygen 1.6.1