PAPI  5.3.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ipc.c
Go to the documentation of this file.
1 /*
2  * A simple example for the use of PAPI, using PAPI_ipc
3  * -Kevin London
4  */
5 
6 #include "papi_test.h"
7 
8 
9 #define INDEX 500
10 extern int TESTS_QUIET; /* Declared in test_utils.c */
11 
12 
13 int
14 main( int argc, char **argv )
15 {
16  extern void dummy( void * );
18  float real_time, proc_time, ipc;
19  long long ins;
20  int retval;
21  int i, j, k;
22 
23  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
24 
25 
26  /* Initialize the Matrix arrays */
27  for( i = 0; i < INDEX; i++ ) {
28  for( j= 0; j < INDEX; j++ ) {
29  mresult[i][j] = 0.0;
30  matrixa[i][j] = matrixb[i][j] = ( float ) rand( ) * ( float ) 1.1;
31  }
32  }
33 
34  /* Setup PAPI library and begin collecting data from the counters */
35  if ( ( retval = PAPI_ipc( &real_time, &proc_time, &ins, &ipc ) ) < PAPI_OK )
36  test_fail( __FILE__, __LINE__, "PAPI_ipc", retval );
37 
38  /* Matrix-Matrix multiply */
39  for ( i = 0; i < INDEX; i++ )
40  for ( j = 0; j < INDEX; j++ )
41  for ( k = 0; k < INDEX; k++ )
42  mresult[i][j] = mresult[i][j] + matrixa[i][k] * matrixb[k][j];
43 
44  /* Collect the data into the variables passed in */
45  if ( ( retval = PAPI_ipc( &real_time, &proc_time, &ins, &ipc ) ) < PAPI_OK )
46  test_fail( __FILE__, __LINE__, "PAPI_ipc", retval );
47  dummy( ( void * ) mresult );
48 
49  if ( !TESTS_QUIET ) {
50  printf( "Real_time: %f Proc_time: %f Total ins: ", real_time,
51  proc_time );
52  printf( LLDFMT, ins );
53  printf( " IPC: %f\n", ipc );
54  }
55 
56  /* This should not happen unless the optimizer */
57  /* gets too good */
58  if (ins < INDEX*INDEX) {
59  test_fail( __FILE__, __LINE__, "Instruction count too low.",
60  5 );
61  }
62  /* Something is broken, or else you have a really */
63  /* slow processor */
64  if (ipc<0.01 ) {
65  test_fail( __FILE__, __LINE__, "IPC equals zero.",
66  5 );
67  }
68 
69  test_pass( __FILE__, NULL, 0 );
70  exit( 1 );
71 }
#define INDEX
Definition: ipc.c:9
float matrixb[INDEX][INDEX]
Definition: flops.c:18
int PAPI_ipc(float *rtime, float *ptime, long long *ins, float *ipc)
Definition: papi_hl.c:316
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
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int i
Definition: fileop.c:140
int k
Definition: iozone.c:19136
float mresult[INDEX][INDEX]
Definition: flops.c:18
float matrixa[INDEX][INDEX]
Definition: flops.c:18
#define LLDFMT
Definition: papi_test.h:118
int rand()
long j
Definition: iozone.c:19135
ssize_t retval
Definition: libasync.c:338
int main(int argc, char **argv)
List all appio events codes and names.
void exit()