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

Go to the source code of this file.

Macros

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

Functions

void funcX (double a[MAX], double b[MAX], int n)
 
void funcA (double a[MAX], double b[MAX], int n)
 
int main (int argc, char **argv)
 

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
 

Macro Definition Documentation

#define MAX   10000

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

#define PAPI_MAX_EVENTS   2

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

#define TIMES   1000

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

Function Documentation

void funcA ( double  a[MAX],
double  b[MAX],
int  n 
)

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

30 {
31  int i, k;
32  double t[MAX];
33  for ( k = 0; k < TIMES; k++ )
34  for ( i = 0; i < n; i++ ) {
35  t[i] = b[n - i];
36  b[i] = a[n - i];
37  a[i] = t[i];
38  }
39 }
t
Definition: iozone.c:23562
int i
Definition: fileop.c:140
int k
Definition: iozone.c:19136
#define TIMES
Definition: mendes-alt.c:13
#define MAX
Definition: mendes-alt.c:11
static double b[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:39
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:38

Here is the caller graph for this function:

void funcX ( double  a[MAX],
double  b[MAX],
int  n 
)

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

22 {
23  int i, k;
24  for ( k = 0; k < TIMES; k++ )
25  for ( i = 0; i < n; i++ )
26  a[i] = a[i] * b[i] + 1.;
27 }
int i
Definition: fileop.c:140
int k
Definition: iozone.c:19136
#define TIMES
Definition: mendes-alt.c:13
static double b[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:39
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:38

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

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

43 {
44  int i, retval;
45  double a[MAX], b[MAX];
46  int quiet;
47 
48  /* Set TESTS_QUIET variable */
49  quiet=tests_quiet( argc, argv );
50 
51  for ( i = 0; i < MAX; i++ ) {
52  a[i] = 0.0;
53  b[i] = 0.;
54  }
55 
56  for ( i = 0; i < PAPI_MAX_EVENTS; i++ )
57  PAPI_values1[i] = PAPI_values2[i] = 0;
58 
60  if ( retval != PAPI_VER_CURRENT )
61  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
62 
63 #ifdef MULTIPLEX
64  if ( !quiet ) {
65  printf( "Activating PAPI Multiplex\n" );
66  }
67 
68  retval = PAPI_multiplex_init( );
69  if ( retval != PAPI_OK ) {
70  test_fail( __FILE__, __LINE__, "PAPI multiplex init fail\n",
71  retval );
72  }
73 
74 #endif
75 
76  retval = PAPI_create_eventset( &EventSet );
77  if ( retval != PAPI_OK )
78  test_fail( __FILE__, __LINE__, "PAPI set event fail\n", retval );
79 
80 #ifdef MULTIPLEX
81  /* In Component PAPI, EventSets must be assigned a component index
82  before you can fiddle with their internals.
83  0 is always the cpu component */
85  if ( retval != PAPI_OK )
86  test_fail( __FILE__, __LINE__, "PAPI_assign_eventset_component",
87  retval );
88 
89  retval = PAPI_set_multiplex( EventSet );
90  if (retval == PAPI_ENOSUPP) {
91  test_skip( __FILE__, __LINE__, "Multiplex not supported", 1 );
92  }
93  else if ( retval != PAPI_OK )
94  test_fail( __FILE__, __LINE__, "PAPI_set_multiplex fails \n", retval );
95 #endif
96 
97  retval = PAPI_add_event( EventSet, PAPI_FP_INS );
98  if ( retval < PAPI_OK ) {
100  if ( retval < PAPI_OK ) {
101  if (!quiet) printf("Trouble adding events\n");
102  test_skip( __FILE__, __LINE__,
103  "PAPI add PAPI_FP_INS or PAPI_TOT_INS fail\n", retval );
104  } else if ( !quiet ) {
105  printf( "PAPI_TOT_INS\n" );
106  }
107  } else if ( !quiet ) {
108  printf( "PAPI_FP_INS\n" );
109  }
110 
111  retval = PAPI_add_event( EventSet, PAPI_TOT_CYC );
112  if ( retval < PAPI_OK )
113  test_fail( __FILE__, __LINE__, "PAPI add PAPI_TOT_CYC fail\n",
114  retval );
115  if ( !quiet ) {
116  printf( "PAPI_TOT_CYC\n" );
117  }
118 
119  retval = PAPI_start( EventSet );
120  if ( retval != PAPI_OK )
121  test_fail( __FILE__, __LINE__, "PAPI start fail\n", retval );
122 
123  funcX( a, b, MAX );
124 
125  retval = PAPI_read( EventSet, PAPI_values1 );
126  if ( retval != PAPI_OK )
127  test_fail( __FILE__, __LINE__, "PAPI read fail \n", retval );
128 
129  funcX( a, b, MAX );
130 
131  retval = PAPI_read( EventSet, PAPI_values2 );
132  if ( retval != PAPI_OK )
133  test_fail( __FILE__, __LINE__, "PAPI read fail \n", retval );
134 
135 #ifdef RESET
136  retval = PAPI_reset( EventSet );
137  if ( retval != PAPI_OK )
138  test_fail( __FILE__, __LINE__, "PAPI read fail \n", retval );
139 #endif
140 
141  funcA( a, b, MAX );
142 
143  retval = PAPI_stop( EventSet, PAPI_values3 );
144  if ( retval != PAPI_OK )
145  test_fail( __FILE__, __LINE__, "PAPI read fail \n", retval );
146 
147  if ( !quiet ) {
148  printf( "values1 is:\n" );
149  for ( i = 0; i < PAPI_MAX_EVENTS; i++ )
151 
152  printf( "\nvalues2 is:\n" );
153  for ( i = 0; i < PAPI_MAX_EVENTS; i++ )
155  printf( "\nvalues3 is:\n" );
156  for ( i = 0; i < PAPI_MAX_EVENTS; i++ )
158 
159 #ifndef RESET
160  printf( "\nPAPI value (2-1) is : \n" );
161  for ( i = 0; i < PAPI_MAX_EVENTS; i++ )
163  printf( "\nPAPI value (3-2) is : \n" );
164  for ( i = 0; i < PAPI_MAX_EVENTS; i++ ) {
165  long long diff;
166  diff = PAPI_values3[i] - PAPI_values2[i];
167  printf( LLDFMT15, diff);
168  if (diff<0) {
169  test_fail( __FILE__, __LINE__, "Multiplexed counter decreased", 1 );
170  }
171  }
172 #endif
173 
174  printf( "\n\nVerification:\n" );
175  printf( "From start to first PAPI_read %d fp operations are made.\n",
176  2 * MAX * TIMES );
177  printf( "Between 1st and 2nd PAPI_read %d fp operations are made.\n",
178  2 * MAX * TIMES );
179  printf( "Between 2nd and 3rd PAPI_read %d fp operations are made.\n",
180  0 );
181  printf( "\n" );
182  }
183 
184  test_pass( __FILE__ );
185 
186  return 0;
187 
188 }
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
void test_pass(const char *filename)
Definition: test_utils.c:432
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
int PAPI_reset(int EventSet)
Definition: papi.c:2459
#define PAPI_ENOSUPP
Definition: papi.h:271
#define PAPI_TOT_INS
int EventSet
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_library_init(int version)
Definition: papi.c:500
int i
Definition: fileop.c:140
int quiet
Definition: rapl_overflow.c:18
#define PAPI_TOT_CYC
#define PAPI_MAX_EVENTS
Definition: mendes-alt.c:15
long long PAPI_values3[PAPI_MAX_EVENTS]
Definition: mendes-alt.c:18
long long PAPI_values1[PAPI_MAX_EVENTS]
Definition: mendes-alt.c:16
int PAPI_assign_eventset_component(int EventSet, int cidx)
Definition: papi.c:1526
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
void funcA(double a[MAX], double b[MAX], int n)
Definition: mendes-alt.c:29
int PAPI_multiplex_init(void)
Definition: papi.c:2982
long long PAPI_values2[PAPI_MAX_EVENTS]
Definition: mendes-alt.c:17
printf("\tTry: -i 0 -i 1 \n\n")
#define TIMES
Definition: mendes-alt.c:13
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
void funcX(double a[MAX], double b[MAX], int n)
Definition: mendes-alt.c:21
#define MAX
Definition: mendes-alt.c:11
int PAPI_set_multiplex(int EventSet)
Definition: papi.c:3333
int PAPI_read(int EventSet, long long *values)
Definition: papi.c:2559
#define LLDFMT15
Definition: papi_test.h:97
int PAPI_start(int EventSet)
Definition: papi.c:2096
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:225
static double b[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:39
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:38
#define PAPI_FP_INS

Here is the call graph for this function:

Variable Documentation

int EventSet = PAPI_NULL
static

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

long long PAPI_values1[PAPI_MAX_EVENTS]

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

long long PAPI_values2[PAPI_MAX_EVENTS]

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

long long PAPI_values3[PAPI_MAX_EVENTS]

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