PAPI  5.6.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
flops.c File Reference
Include dependency graph for flops.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 18 of file flops.c.

19 {
20  float real_time, proc_time, mflops;
21  long long flpins;
22  int retval;
23  int fip = 0;
24  int quiet=0;
25  long long expected;
26  double double_result,error;
27 
28  /* Set TESTS_QUIET variable */
29  quiet=tests_quiet( argc, argv );
30 
31  /* Initialize PAPI library */
33  if ( retval != PAPI_VER_CURRENT ) {
34  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
35  }
36 
37  /* Try to use one of the FP events */
38  if ( PAPI_query_event( PAPI_FP_INS ) == PAPI_OK ) {
39  fip = 1;
40  }
41  else if ( PAPI_query_event( PAPI_FP_OPS ) == PAPI_OK ) {
42  fip = 2;
43  }
44  else {
45  if ( !quiet ) printf( "PAPI_FP_INS and PAPI_FP_OPS are not defined for this platform.\n" );
46  test_skip(__FILE__,__LINE__,"No FP events available",1);
47  }
48 
49  /* Shutdown? */
50  /* I guess because it would interfere with the high-level interface? */
51  PAPI_shutdown( );
52 
53  /* Initialize the Matrix arrays */
54  expected=flops_float_init_matrix();
55 
56  /* Setup PAPI library and begin collecting data from the counters */
57  if ( fip == 1 ) {
58  retval = PAPI_flips( &real_time, &proc_time, &flpins, &mflops );
59  if (retval!=PAPI_OK) {
60  test_fail( __FILE__, __LINE__, "PAPI_flips", retval );
61  }
62  }
63  else {
64  retval = PAPI_flops( &real_time, &proc_time, &flpins, &mflops );
65  if (retval!=PAPI_OK) {
66  test_fail( __FILE__, __LINE__, "PAPI_flops", retval );
67  }
68  }
69 
70  /* Matrix-Matrix multiply */
71  double_result=flops_float_matrix_matrix_multiply();
72 
73  /* Collect the data into the variables passed in */
74  if ( fip == 1 ) {
75  retval = PAPI_flips( &real_time, &proc_time, &flpins, &mflops );
76  if (retval!=PAPI_OK) {
77  test_fail( __FILE__, __LINE__, "PAPI_flips", retval );
78  }
79  } else {
80  retval = PAPI_flops( &real_time, &proc_time, &flpins, &mflops );
81  if (retval!=PAPI_OK) {
82  test_fail( __FILE__, __LINE__, "PAPI_flops", retval );
83  }
84  }
85 
86  if (!quiet) printf("result=%lf\n",double_result);
87 
88  if ( !quiet ) {
89  printf( "Real_time: %f Proc_time: %f MFLOPS: %f\n",
90  real_time, proc_time, mflops );
91  if ( fip == 1 ) {
92  printf( "Total flpins: ");
93  } else {
94  printf( "Total flpops: ");
95  }
96  printf( "%lld\n\n", flpins );
97  }
98 
99  error=display_error(flpins,flpins,flpins,expected,quiet);
100 
101  if ((error > 1.0) || (error<-1.0)) {
102  if (!quiet) printf("Instruction count off by more than 1%%\n");
103  test_fail( __FILE__, __LINE__, "Validation failed", 1 );
104  }
105 
106  test_pass( __FILE__ );
107 
108  return 0;
109 
110 }
void test_pass(const char *filename)
Definition: test_utils.c:432
static int expected[NUM_THREADS]
#define PAPI_FP_OPS
double display_error(long long average, long long high, long long low, long long expected, int quiet)
Definition: display_error.c:7
int PAPI_flops(float *rtime, float *ptime, long long *flpops, float *mflops)
Definition: papi_hl.c:259
return PAPI_OK
Definition: linux-nvml.c:497
int int argc
Definition: iozone.c:1609
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:559
char ** argv
Definition: iozone.c:1610
int PAPI_flips(float *rtime, float *ptime, long long *flpins, float *mflips)
Definition: papi_hl.c:204
int PAPI_library_init(int version)
Definition: papi.c:500
void PAPI_shutdown(void)
Definition: papi.c:4461
int quiet
Definition: rapl_overflow.c:18
int flops_float_init_matrix(void)
int PAPI_query_event(int EventCode)
Definition: papi.c:684
printf("\tTry: -i 0 -i 1 \n\n")
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
float flops_float_matrix_matrix_multiply(void)
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:225
#define PAPI_FP_INS

Here is the call graph for this function: