|
PAPI
5.0.1.0
|
00001 /* This test checks that mixing PAPI_flips and the other high 00002 * level calls does the right thing. 00003 * Kevin 00004 */ 00005 00006 #include "papi_test.h" 00007 extern int TESTS_QUIET; /*Declared in test_utils.c */ 00008 00009 int 00010 main( int argc, char **argv ) 00011 { 00012 int retval; 00013 int Events, fip = 0; 00014 long long values, flpins; 00015 float real_time, proc_time, mflops; 00016 00017 tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */ 00018 retval = PAPI_library_init( PAPI_VER_CURRENT ); 00019 if ( retval != PAPI_VER_CURRENT ) 00020 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval ); 00021 00022 if ( PAPI_query_event( PAPI_FP_INS ) == PAPI_OK ) { 00023 fip = 1; 00024 Events = PAPI_FP_INS; 00025 } else if ( PAPI_query_event( PAPI_FP_OPS ) == PAPI_OK ) { 00026 fip = 2; 00027 Events = PAPI_FP_OPS; 00028 } else { 00029 if ( !TESTS_QUIET ) 00030 printf 00031 ( "PAPI_FP_INS and PAPI_FP_OPS are not defined for this platform.\n" ); 00032 } 00033 00034 if ( fip > 0 ) { 00035 if ( fip == 1 ) { 00036 if ( ( retval = 00037 PAPI_flips( &real_time, &proc_time, &flpins, 00038 &mflops ) ) != PAPI_OK ) 00039 test_fail( __FILE__, __LINE__, "PAPI_flips", retval ); 00040 } else { 00041 if ( ( retval = 00042 PAPI_flops( &real_time, &proc_time, &flpins, 00043 &mflops ) ) != PAPI_OK ) 00044 test_fail( __FILE__, __LINE__, "PAPI_flops", retval ); 00045 } 00046 if ( ( retval = PAPI_start_counters( &Events, 1 ) ) == PAPI_OK ) 00047 test_fail( __FILE__, __LINE__, "PAPI_start_counters", retval ); 00048 if ( fip == 1 ) { 00049 if ( ( retval = 00050 PAPI_flips( &real_time, &proc_time, &flpins, 00051 &mflops ) ) != PAPI_OK ) 00052 test_fail( __FILE__, __LINE__, "PAPI_flips", retval ); 00053 } else { 00054 if ( ( retval = 00055 PAPI_flops( &real_time, &proc_time, &flpins, 00056 &mflops ) ) != PAPI_OK ) 00057 test_fail( __FILE__, __LINE__, "PAPI_flops", retval ); 00058 } 00059 if ( ( retval = PAPI_read_counters( &values, 1 ) ) == PAPI_OK ) 00060 test_fail( __FILE__, __LINE__, "PAPI_read_counters", retval ); 00061 if ( ( retval = PAPI_stop_counters( &values, 1 ) ) != PAPI_OK ) 00062 test_fail( __FILE__, __LINE__, "PAPI_stop_counters", retval ); 00063 if ( fip == 1 ) { 00064 if ( ( retval = 00065 PAPI_flips( &real_time, &proc_time, &flpins, 00066 &mflops ) ) != PAPI_OK ) 00067 test_fail( __FILE__, __LINE__, "PAPI_flips", retval ); 00068 } else { 00069 if ( ( retval = 00070 PAPI_flops( &real_time, &proc_time, &flpins, 00071 &mflops ) ) != PAPI_OK ) 00072 test_fail( __FILE__, __LINE__, "PAPI_flops", retval ); 00073 } 00074 if ( ( retval = PAPI_read_counters( &values, 1 ) ) == PAPI_OK ) 00075 test_fail( __FILE__, __LINE__, "PAPI_read_counters", retval ); 00076 if ( ( retval = PAPI_stop_counters( &values, 1 ) ) != PAPI_OK ) 00077 test_fail( __FILE__, __LINE__, "PAPI_stop_counters", retval ); 00078 if ( ( retval = PAPI_start_counters( &Events, 1 ) ) != PAPI_OK ) 00079 test_fail( __FILE__, __LINE__, "PAPI_start_counters", retval ); 00080 if ( ( retval = PAPI_read_counters( &values, 1 ) ) != PAPI_OK ) 00081 test_fail( __FILE__, __LINE__, "PAPI_read_counters", retval ); 00082 if ( fip == 1 ) { 00083 if ( ( retval = 00084 PAPI_flips( &real_time, &proc_time, &flpins, 00085 &mflops ) ) == PAPI_OK ) 00086 test_fail( __FILE__, __LINE__, "PAPI_flips", retval ); 00087 } else { 00088 if ( ( retval = 00089 PAPI_flops( &real_time, &proc_time, &flpins, 00090 &mflops ) ) == PAPI_OK ) 00091 test_fail( __FILE__, __LINE__, "PAPI_flops", retval ); 00092 } 00093 if ( ( retval = PAPI_stop_counters( &values, 1 ) ) != PAPI_OK ) 00094 test_fail( __FILE__, __LINE__, "PAPI_stop_counters", retval ); 00095 } 00096 test_pass( __FILE__, NULL, 0 ); 00097 exit( 0 ); /* just to make the compiler happy... */ 00098 }