derived.c File Reference

Include dependency graph for derived.c:

Go to the source code of this file.

Defines

#define OLD_TEST_DRIVER
#define CPP_TEST_FAIL(string, retval)   test_fail(__FILE__, __LINE__, string, retval);
#define CPP_TEST_PASS()   { test_pass(__FILE__, NULL, 0); exit(0); }
#define CPP_TEST_SKIP()   { test_skip(__FILE__,__LINE__,NULL,0); exit(0); }
#define EVENTSLEN   2
#define QUIETPRINTF   if (!TESTS_QUIET) printf

Functions

int main (int argc, char **argv)

Variables

unsigned int PAPI_events [EVENTSLEN] = { 0, 0 }
static const int PAPI_events_len = 1
int TESTS_QUIET

Define Documentation

#define CPP_TEST_FAIL ( string,
retval   )     test_fail(__FILE__, __LINE__, string, retval);

Definition at line 8 of file derived.c.

 
#define CPP_TEST_PASS (  )     { test_pass(__FILE__, NULL, 0); exit(0); }

Definition at line 9 of file derived.c.

 
#define CPP_TEST_SKIP (  )     { test_skip(__FILE__,__LINE__,NULL,0); exit(0); }

Definition at line 10 of file derived.c.

#define EVENTSLEN   2

Definition at line 17 of file derived.c.

#define OLD_TEST_DRIVER

Definition at line 5 of file derived.c.

#define QUIETPRINTF   if (!TESTS_QUIET) printf

Definition at line 19 of file derived.c.


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 25 of file derived.c.

00026 {
00027     int retval, tmp;
00028     int EventSet = PAPI_NULL;
00029     int i;
00030     PAPI_event_info_t info;
00031     long long values;
00032     char event_name[PAPI_MAX_STR_LEN], add_event_str[PAPI_MAX_STR_LEN];
00033 
00034 /*#if !defined(i386) || !defined(linux)
00035    CPP_TEST_SKIP();
00036 #endif
00037 */
00038     tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */
00039 
00040     retval = PAPI_library_init( PAPI_VER_CURRENT );
00041     if ( retval != PAPI_VER_CURRENT )
00042         test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
00043 
00044     QUIETPRINTF( "Test case %s: start, stop with a derived counter.\n",
00045                  __FILE__ );
00046     QUIETPRINTF( "------------------------------------------------\n" );
00047     tmp = PAPI_get_opt( PAPI_DEFDOM, NULL );
00048     QUIETPRINTF( "Default domain is: %d (%s)\n", tmp,
00049                  stringify_all_domains( tmp ) );
00050     tmp = PAPI_get_opt( PAPI_DEFGRN, NULL );
00051     QUIETPRINTF( "Default granularity is: %d (%s)\n\n", tmp,
00052                  stringify_granularity( tmp ) );
00053 
00054     i = PAPI_PRESET_MASK;
00055     do {
00056         if ( PAPI_get_event_info( i, &info ) == PAPI_OK ) {
00057             if ( info.count > 1 ) {
00058                 PAPI_events[0] = ( unsigned int ) info.event_code;
00059                 break;
00060             }
00061         }
00062     } while ( PAPI_enum_event( &i, 0 ) == PAPI_OK );
00063 
00064     if ( PAPI_events[0] == 0 )
00065         CPP_TEST_SKIP(  );
00066 
00067     retval = PAPI_create_eventset( &EventSet );
00068     if ( retval != PAPI_OK )
00069         CPP_TEST_FAIL( "PAPI_create_eventset", retval );
00070 
00071     for ( i = 0; i < PAPI_events_len; i++ ) {
00072         PAPI_event_code_to_name( ( int ) PAPI_events[i], event_name );
00073         if ( !TESTS_QUIET )
00074             QUIETPRINTF( "Adding %s\n", event_name );
00075         retval = PAPI_add_event( EventSet, ( int ) PAPI_events[i] );
00076         if ( retval != PAPI_OK )
00077             CPP_TEST_FAIL( "PAPI_add_event", retval );
00078     }
00079 
00080     retval = PAPI_start( EventSet );
00081     if ( retval != PAPI_OK )
00082         test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00083 
00084     QUIETPRINTF( "Running do_stuff().\n" );
00085 
00086     do_stuff(  );
00087 
00088     retval = PAPI_stop( EventSet, &values );
00089     if ( retval != PAPI_OK )
00090         test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00091 
00092     sprintf( add_event_str, "%-12s : \t", event_name );
00093     QUIETPRINTF( TAB1, add_event_str, values );
00094     QUIETPRINTF( "------------------------------------------------\n" );
00095 
00096     retval = PAPI_cleanup_eventset( EventSet ); /* JT */
00097     if ( retval != PAPI_OK )
00098         CPP_TEST_FAIL( "PAPI_cleanup_eventset", retval );
00099 
00100     retval = PAPI_destroy_eventset( &EventSet );
00101     if ( retval != PAPI_OK )
00102         CPP_TEST_FAIL( "PAPI_cleanup_eventset", retval );
00103 
00104 #ifndef OLD_TEST_DRIVER
00105     PAPI_shutdown(  );
00106 #endif
00107 
00108     QUIETPRINTF( "Verification: Does it produce a non-zero value?\n" );
00109 
00110     if ( values != 0 ) {
00111         QUIETPRINTF( "Yes: " );
00112         QUIETPRINTF( LLDFMT, values );
00113         QUIETPRINTF( "\n" );
00114     }
00115 
00116     CPP_TEST_PASS(  );
00117 }

Here is the call graph for this function:


Variable Documentation

unsigned int PAPI_events[EVENTSLEN] = { 0, 0 }

Definition at line 20 of file derived.c.

const int PAPI_events_len = 1 [static]

Definition at line 21 of file derived.c.

Definition at line 11 of file test_utils.c.


Generated on 26 Jan 2016 for PAPI by  doxygen 1.6.1