PAPI  5.4.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.

Macros

#define INDEX   1000
 

Functions

void dummy (void *)
 
int main (int argc, char **argv)
 

Variables

char format_string []
 
int TESTS_QUIET
 
float matrixa [INDEX][INDEX]
 
float matrixb [INDEX][INDEX]
 
float mresult [INDEX][INDEX]
 

Macro Definition Documentation

#define INDEX   1000

Definition at line 10 of file flops.c.

Function Documentation

void dummy ( void )

Definition at line 4 of file dummy.c.

5 {
6 /* Confuse the compiler so as not to optimize
7  away the flops in the calling routine */
8 /* Cast the array as a void to eliminate unused argument warning */
9  ( void ) array;
10 }
void
Definition: iozone.c:18627
int main ( int  argc,
char **  argv 
)

Definition at line 20 of file flops.c.

21 {
22  float real_time, proc_time, mflops;
23  long long flpins;
24  int retval;
25  int i, j, k, fip = 0;
26 
27  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
28 
30  if ( retval != PAPI_VER_CURRENT )
31  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
32 
34  fip = 1;
35  else if ( PAPI_query_event( PAPI_FP_OPS ) == PAPI_OK )
36  fip = 2;
37  else {
38  if ( !TESTS_QUIET )
39  printf
40  ( "PAPI_FP_INS and PAPI_FP_OPS are not defined for this platform.\n" );
41  }
42 
43  PAPI_shutdown( );
44 
45  if ( fip > 0 ) {
46  /* Initialize the Matrix arrays */
47  for ( i = 0; i < INDEX; i++ ) {
48  for ( j = 0; j < INDEX; j++) {
49  mresult[j][i] = 0.0;
50  matrixa[j][i] = matrixb[j][i] = ( float ) rand( ) * ( float ) 1.1;
51  }
52  }
53 
54  /* Setup PAPI library and begin collecting data from the counters */
55  if ( fip == 1 ) {
56  if ( ( retval =
57  PAPI_flips( &real_time, &proc_time, &flpins,
58  &mflops ) ) < PAPI_OK )
59  test_fail( __FILE__, __LINE__, "PAPI_flips", retval );
60  } else {
61  if ( ( retval =
62  PAPI_flops( &real_time, &proc_time, &flpins,
63  &mflops ) ) < PAPI_OK )
64  test_fail( __FILE__, __LINE__, "PAPI_flops", retval );
65  }
66 
67  /* Matrix-Matrix multiply */
68  for ( i = 0; i < INDEX; i++ )
69  for ( j = 0; j < INDEX; j++ )
70  for ( k = 0; k < INDEX; k++ )
71  mresult[i][j] =
72  mresult[i][j] + matrixa[i][k] * matrixb[k][j];
73 
74  /* Collect the data into the variables passed in */
75  if ( fip == 1 ) {
76  if ( ( retval =
77  PAPI_flips( &real_time, &proc_time, &flpins,
78  &mflops ) ) < PAPI_OK )
79  test_fail( __FILE__, __LINE__, "PAPI_flips", retval );
80  } else {
81  if ( ( retval =
82  PAPI_flops( &real_time, &proc_time, &flpins,
83  &mflops ) ) < PAPI_OK )
84  test_fail( __FILE__, __LINE__, "PAPI_flops", retval );
85  }
86  dummy( ( void * ) mresult );
87 
88  if ( !TESTS_QUIET ) {
89  if ( fip == 1 ) {
90  printf( "Real_time: %f Proc_time: %f Total flpins: ", real_time,
91  proc_time );
92  } else {
93  printf( "Real_time: %f Proc_time: %f Total flpops: ", real_time,
94  proc_time );
95  }
96  printf( LLDFMT, flpins );
97  printf( " MFLOPS: %f\n", mflops );
98  }
99  }
100  test_pass( __FILE__, NULL, 0 );
101  exit( 1 );
102 }
float matrixb[INDEX][INDEX]
Definition: flops.c:18
#define PAPI_FP_OPS
int PAPI_flops(float *rtime, float *ptime, long long *flpops, float *mflops)
Definition: papi_hl.c:259
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
int dummy
Definition: iozone.c:19741
int TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
int PAPI_flips(float *rtime, float *ptime, long long *flpins, float *mflips)
Definition: papi_hl.c:204
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:497
int i
Definition: fileop.c:140
void PAPI_shutdown(void)
Definition: papi.c:4400
int k
Definition: iozone.c:19136
#define INDEX
Definition: flops.c:10
float mresult[INDEX][INDEX]
Definition: flops.c:18
float matrixa[INDEX][INDEX]
Definition: flops.c:18
int PAPI_query_event(int EventCode)
Definition: papi.c:698
#define LLDFMT
Definition: papi_test.h:118
int rand()
long j
Definition: iozone.c:19135
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:223
void exit()
#define PAPI_FP_INS

Here is the call graph for this function:

Variable Documentation

char format_string[]
Initial value:
=
{ "Real_time: %f Proc_time: %f Total flpins: %lld MFLOPS: %f\n" }

Definition at line 12 of file flops.c.

float matrixa[INDEX][INDEX]

Definition at line 18 of file flops.c.

float matrixb[INDEX][INDEX]

Definition at line 18 of file flops.c.

float mresult[INDEX][INDEX]

Definition at line 18 of file flops.c.

int TESTS_QUIET

Definition at line 11 of file test_utils.c.