mendes-alt.c File Reference

Include dependency graph for mendes-alt.c:

Go to the source code of this file.

Defines

#define MAX   10000
#define TIMES   1000
#define PAPI_MAX_EVENTS   2

Functions

int main (int argc, argv)
void funcX (a, b, int n)
void funcA (a, b, int n)

Variables

long long PAPI_values1 [PAPI_MAX_EVENTS]
long long PAPI_values2 [PAPI_MAX_EVENTS]
long long PAPI_values3 [PAPI_MAX_EVENTS]
static int EventSet = PAPI_NULL
int TESTS_QUIET

Define Documentation

#define MAX   10000

Definition at line 9 of file mendes-alt.c.

#define PAPI_MAX_EVENTS   2

Definition at line 13 of file mendes-alt.c.

#define TIMES   1000

Definition at line 11 of file mendes-alt.c.


Function Documentation

void funcA ( a  ,
b  ,
int  n 
)

Definition at line 173 of file mendes-alt.c.

00176 {
00177     int i, k;
00178     double t[MAX];
00179     for ( k = 0; k < TIMES; k++ )
00180         for ( i = 0; i < n; i++ ) {
00181             t[i] = b[n - i];
00182             b[i] = a[n - i];
00183             a[i] = t[i];
00184         }
00185 }

Here is the caller graph for this function:

void funcX ( a  ,
b  ,
int  n 
)

Definition at line 162 of file mendes-alt.c.

00165 {
00166     int i, k;
00167     for ( k = 0; k < TIMES; k++ )
00168         for ( i = 0; i < n; i++ )
00169             a[i] = a[i] * b[i] + 1.;
00170 }

Here is the caller graph for this function:

int main ( int  argc,
argv   
)

Definition at line 22 of file mendes-alt.c.

00025 {
00026     int i, retval;
00027     double a[MAX], b[MAX];
00028     void funcX(  ), funcA(  );
00029 
00030     tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */
00031 
00032     for ( i = 0; i < MAX; i++ ) {
00033         a[i] = 0.0;
00034         b[i] = 0.;
00035     }
00036 
00037     for ( i = 0; i < PAPI_MAX_EVENTS; i++ )
00038         PAPI_values1[i] = PAPI_values2[i] = 0;
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 #ifdef MULTIPLEX
00045     if ( !TESTS_QUIET ) {
00046         printf( "Activating PAPI Multiplex\n" );
00047     }
00048     init_multiplex(  );
00049 #endif
00050 
00051     retval = PAPI_create_eventset( &EventSet );
00052     if ( retval != PAPI_OK )
00053         test_fail( __FILE__, __LINE__, "PAPI set event fail\n", retval );
00054 
00055 #ifdef MULTIPLEX
00056     /* In Component PAPI, EventSets must be assigned a component index
00057        before you can fiddle with their internals.
00058        0 is always the cpu component */
00059     retval = PAPI_assign_eventset_component( EventSet, 0 );
00060     if ( retval != PAPI_OK )
00061         test_fail( __FILE__, __LINE__, "PAPI_assign_eventset_component",
00062                    retval );
00063 
00064     retval = PAPI_set_multiplex( EventSet );
00065         if (retval == PAPI_ENOSUPP) {
00066        test_skip( __FILE__, __LINE__, "Multiplex not supported", 1 );
00067     }
00068     else if ( retval != PAPI_OK )
00069         test_fail( __FILE__, __LINE__, "PAPI_set_multiplex fails \n", retval );
00070 #endif
00071 
00072     retval = PAPI_add_event( EventSet, PAPI_FP_INS );
00073     if ( retval < PAPI_OK ) {
00074         retval = PAPI_add_event( EventSet, PAPI_TOT_INS );
00075         if ( retval < PAPI_OK )
00076             test_fail( __FILE__, __LINE__,
00077                        "PAPI add PAPI_FP_INS or PAPI_TOT_INS fail\n", retval );
00078         else if ( !TESTS_QUIET ) {
00079             printf( "PAPI_TOT_INS\n" );
00080         }
00081     } else if ( !TESTS_QUIET ) {
00082         printf( "PAPI_FP_INS\n" );
00083     }
00084 
00085     retval = PAPI_add_event( EventSet, PAPI_TOT_CYC );
00086     if ( retval < PAPI_OK )
00087         test_fail( __FILE__, __LINE__, "PAPI add PAPI_TOT_CYC  fail\n",
00088                    retval );
00089     if ( !TESTS_QUIET ) {
00090         printf( "PAPI_TOT_CYC\n" );
00091     }
00092 
00093     retval = PAPI_start( EventSet );
00094     if ( retval != PAPI_OK )
00095         test_fail( __FILE__, __LINE__, "PAPI start fail\n", retval );
00096 
00097     funcX( a, b, MAX );
00098 
00099     retval = PAPI_read( EventSet, PAPI_values1 );
00100     if ( retval != PAPI_OK )
00101         test_fail( __FILE__, __LINE__, "PAPI read fail \n", retval );
00102 
00103     funcX( a, b, MAX );
00104 
00105     retval = PAPI_read( EventSet, PAPI_values2 );
00106     if ( retval != PAPI_OK )
00107         test_fail( __FILE__, __LINE__, "PAPI read fail \n", retval );
00108 
00109 #ifdef RESET
00110     retval = PAPI_reset( EventSet );
00111     if ( retval != PAPI_OK )
00112         test_fail( __FILE__, __LINE__, "PAPI read fail \n", retval );
00113 #endif
00114 
00115     funcA( a, b, MAX );
00116 
00117     retval = PAPI_stop( EventSet, PAPI_values3 );
00118     if ( retval != PAPI_OK )
00119         test_fail( __FILE__, __LINE__, "PAPI read fail \n", retval );
00120 
00121     if ( !TESTS_QUIET ) {
00122         printf( "values1 is:\n" );
00123         for ( i = 0; i < PAPI_MAX_EVENTS; i++ )
00124             printf( LLDFMT15, PAPI_values1[i] );
00125 
00126         printf( "\nvalues2 is:\n" );
00127         for ( i = 0; i < PAPI_MAX_EVENTS; i++ )
00128             printf( LLDFMT15, PAPI_values2[i] );
00129         printf( "\nvalues3 is:\n" );
00130         for ( i = 0; i < PAPI_MAX_EVENTS; i++ )
00131             printf( LLDFMT15, PAPI_values3[i] );
00132 
00133 #ifndef RESET
00134         printf( "\nPAPI value (2-1) is : \n" );
00135         for ( i = 0; i < PAPI_MAX_EVENTS; i++ )
00136             printf( LLDFMT15, PAPI_values2[i] - PAPI_values1[i] );
00137         printf( "\nPAPI value (3-2) is : \n" );
00138         for ( i = 0; i < PAPI_MAX_EVENTS; i++ ) {
00139           long long diff;
00140                   diff = PAPI_values3[i] - PAPI_values2[i];
00141           printf( LLDFMT15, diff);
00142           if (diff<0) {
00143             test_fail( __FILE__, __LINE__, "Multiplexed counter decreased", 1 );
00144           }
00145         }
00146 #endif
00147 
00148         printf( "\n\nVerification:\n" );
00149         printf( "From start to first PAPI_read %d fp operations are made.\n",
00150                 2 * MAX * TIMES );
00151         printf( "Between 1st and 2nd PAPI_read %d fp operations are made.\n",
00152                 2 * MAX * TIMES );
00153         printf( "Between 2nd and 3rd PAPI_read %d fp operations are made.\n",
00154                 0 );
00155         printf( "\n" );
00156     }
00157     test_pass( __FILE__, NULL, 0 );
00158     exit( 1 );
00159 }

Here is the call graph for this function:


Variable Documentation

int EventSet = PAPI_NULL [static]

Definition at line 17 of file mendes-alt.c.

long long PAPI_values1[PAPI_MAX_EVENTS]

Definition at line 14 of file mendes-alt.c.

long long PAPI_values2[PAPI_MAX_EVENTS]

Definition at line 15 of file mendes-alt.c.

long long PAPI_values3[PAPI_MAX_EVENTS]

Definition at line 16 of file mendes-alt.c.

Definition at line 11 of file test_utils.c.


Generated on 26 Jan 2016 for PAPI by  doxygen 1.6.1