PAPI  5.0.1.0
nineth.c
Go to the documentation of this file.
00001 /* This file performs the following test: start, stop and timer functionality for derived events
00002 
00003    NOTE: This test becomes useless when rate events like PAPI_FLOPS are removed.
00004 
00005    - It tests the derived metric FLOPS using the following two counters.
00006      They are counted in the default counting domain and default
00007      granularity, depending on the platform. Usually this is 
00008      the user domain (PAPI_DOM_USER) and thread context (PAPI_GRN_THR).
00009      + PAPI_FP_INS
00010      + PAPI_TOT_CYC
00011    - Get us.
00012    - Start counters
00013    - Do flops
00014    - Stop and read counters
00015    - Get us.
00016 */
00017 
00018 #include "papi_test.h"
00019 
00020 extern int TESTS_QUIET;                /* Declared in test_utils.c */
00021 
00022 int
00023 main( int argc, char **argv )
00024 {
00025     int retval, num_tests = 2, tmp;
00026     int EventSet1 = PAPI_NULL;
00027     int EventSet2 = PAPI_NULL;
00028     int mask1 = 0x80001;               /* FP_OPS and TOT_CYC */
00029     int mask2 = 0x8;                   /* FLOPS */
00030     int num_events1;
00031     int num_events2;
00032     long long **values;
00033     int clockrate;
00034     double test_flops;
00035 
00036 
00037     tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */
00038 
00039     retval = PAPI_library_init( PAPI_VER_CURRENT );
00040     if ( retval != PAPI_VER_CURRENT )
00041         test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
00042 
00043     /* gotta count flops to run this test */
00044     if ( ( retval = PAPI_query_event( PAPI_FP_OPS ) ) != PAPI_OK )
00045         test_skip( __FILE__, __LINE__, "PAPI_query_event", retval );
00046 
00047     EventSet1 = add_test_events( &num_events1, &mask1 );
00048 /*   EventSet2 = add_test_events(&num_events2, &mask2); */
00049 
00050     if ( num_events1 == 0 || num_events2 == 0 )
00051         test_skip( __FILE__, __LINE__, "add_test_events", PAPI_ENOEVNT );
00052 
00053     /* num_events1 is greater than num_events2 so don't worry. */
00054 
00055     values = allocate_test_space( num_tests, num_events1 );
00056 
00057     clockrate = PAPI_get_opt( PAPI_CLOCKRATE, NULL );
00058     if ( clockrate < 1 )
00059         test_fail( __FILE__, __LINE__, "PAPI_get_opt", retval );
00060 
00061     retval = PAPI_start( EventSet1 );
00062     if ( retval != PAPI_OK )
00063         test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00064 
00065     do_flops( NUM_FLOPS );
00066 
00067     retval = PAPI_stop( EventSet1, values[0] );
00068     if ( retval != PAPI_OK )
00069         test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00070 /*
00071    retval = PAPI_start(EventSet2);
00072    if (retval != PAPI_OK)
00073       test_fail(__FILE__, __LINE__, "PAPI_start", retval);
00074 
00075    do_flops(NUM_FLOPS);
00076 
00077    retval = PAPI_stop(EventSet2, values[1]);
00078    if (retval != PAPI_OK)
00079       test_fail(__FILE__, __LINE__, "PAPI_stop", retval);
00080 */
00081     remove_test_events( &EventSet1, mask1 );
00082 /*   remove_test_events(&EventSet2, mask2); */
00083 
00084     test_flops =
00085         ( double ) ( values[0] )[0] *
00086         ( double ) clockrate *( double ) 1000000.0;
00087     test_flops = test_flops / ( double ) ( values[0] )[1];
00088 
00089     if ( !TESTS_QUIET ) {
00090         printf( "Test case 9: start, stop for derived event PAPI_FLOPS.\n" );
00091         printf( "------------------------------------------------------\n" );
00092         tmp = PAPI_get_opt( PAPI_DEFDOM, NULL );
00093         printf( "Default domain is: %d (%s)\n", tmp,
00094                 stringify_all_domains( tmp ) );
00095         tmp = PAPI_get_opt( PAPI_DEFGRN, NULL );
00096         printf( "Default granularity is: %d (%s)\n", tmp,
00097                 stringify_granularity( tmp ) );
00098         printf( "Using %d iterations of c += a*b\n", NUM_FLOPS );
00099         printf
00100             ( "-------------------------------------------------------------------------\n" );
00101 
00102         printf( "Test type   : %12s%12s\n", "1", "2" );
00103         printf( TAB2, "PAPI_FP_OPS : ", ( values[0] )[0], ( long long ) 0 );
00104         printf( TAB2, "PAPI_TOT_CYC: ", ( values[0] )[1], ( long long ) 0 );
00105         printf( TAB2, "PAPI_FLOPS  : ", ( long long ) 0, ( values[1] )[0] );
00106         printf
00107             ( "-------------------------------------------------------------------------\n" );
00108 
00109         printf( "Verification:\n" );
00110         printf( "Last number in row 3 approximately equals %f\n", test_flops );
00111         printf( "This test is no longer valid: PAPI_FLOPS is deprecated.\n" );
00112     }
00113 /*   {
00114       double min, max;
00115       min = values[1][0] * .9;
00116       max = values[1][0] * 1.1;
00117       if (test_flops > max || test_flops < min)
00118          test_fail(__FILE__, __LINE__, "PAPI_FLOPS", 1);
00119    }
00120 */
00121     test_pass( __FILE__, values, num_tests );
00122     exit( 1 );
00123 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines