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

Go to the source code of this file.

Macros

#define ROWS   1000
 
#define COLUMNS   1000
 

Functions

static void init_mat ()
 
static void classic_matmul ()
 
static void swapped_matmul ()
 
int main (int argc, char **argv)
 

Variables

static float matrix_a [ROWS][COLUMNS]
 
static float matrix_b [ROWS][COLUMNS]
 
static float matrix_c [ROWS][COLUMNS]
 

Macro Definition Documentation

#define COLUMNS   1000

Definition at line 25 of file hl_rates.c.

#define ROWS   1000

Definition at line 24 of file hl_rates.c.

Function Documentation

static void classic_matmul ( )
static

Definition at line 42 of file hl_rates.c.

43 {
44  // Multiply the two matrices
45  int i, j, k;
46  for (i = 0; i < ROWS; i++) {
47  for (j = 0; j < COLUMNS; j++) {
48  float sum = 0.0;
49  for (k = 0; k < COLUMNS; k++) {
50  sum +=
51  matrix_a[i][k] * matrix_b[k][j];
52  }
53  matrix_c[i][j] = sum;
54  }
55  }
56 }
#define ROWS
Definition: hl_rates.c:24
static float matrix_a[ROWS][COLUMNS]
Definition: hl_rates.c:27
int i
Definition: fileop.c:140
int k
Definition: iozone.c:19136
static float matrix_b[ROWS][COLUMNS]
Definition: hl_rates.c:27
static float matrix_c[ROWS][COLUMNS]
Definition: hl_rates.c:27
#define COLUMNS
Definition: hl_rates.c:25
long j
Definition: iozone.c:19135

Here is the caller graph for this function:

static void init_mat ( )
static

Definition at line 29 of file hl_rates.c.

30 {
31  // Initialize the two matrices
32  int i, j;
33  for (i = 0; i < ROWS; i++) {
34  for (j = 0; j < COLUMNS; j++) {
35  matrix_a[i][j] = (float) rand() / RAND_MAX;
36  matrix_b[i][j] = (float) rand() / RAND_MAX;
37  }
38  }
39 
40 }
#define ROWS
Definition: hl_rates.c:24
static float matrix_a[ROWS][COLUMNS]
Definition: hl_rates.c:27
int i
Definition: fileop.c:140
static float matrix_b[ROWS][COLUMNS]
Definition: hl_rates.c:27
#define COLUMNS
Definition: hl_rates.c:25
int rand()
long j
Definition: iozone.c:19135

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 73 of file hl_rates.c.

74 {
75  int retval, event = 0;
76  float rtime, ptime, mflips, mflops, ipc, epc;
77  long long flpins, flpops, ins, ref, core, evt;
78 
79  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
80 
81  init_mat();
82 
83  printf( "\n----------------------------------\n" );
84  printf( "PAPI_flips\n");
85  if ( PAPI_flips(&rtime, &ptime, &flpins, &mflips) != PAPI_OK )
86  PAPI_perror( "PAPI_flips" );
87  printf( "\nStart\n");
88  printf( "real time: %f\n", rtime);
89  printf( "process time: %f\n", ptime);
90  printf( "FP Instructions: %lld\n", flpins);
91  printf( "MFLIPS %f\n", mflips);
93  if ( PAPI_flips(&rtime, &ptime, &flpins, &mflips) != PAPI_OK )
94  PAPI_perror( "PAPI_flips" );
95  printf( "\nClassic\n");
96  printf( "real time: %f\n", rtime);
97  printf( "process time: %f\n", ptime);
98  printf( "FP Instructions: %lld\n", flpins);
99  printf( "MFLIPS %f\n", mflips);
100  swapped_matmul();
101  if ( PAPI_flips(&rtime, &ptime, &flpins, &mflips) != PAPI_OK )
102  PAPI_perror( "PAPI_flips" );
103  printf( "\nSwapped\n");
104  printf( "real time: %f\n", rtime);
105  printf( "process time: %f\n", ptime);
106  printf( "FP Instructions: %lld\n", flpins);
107  printf( "MFLIPS %f\n", mflips);
108 
109  // turn off flips
110  if ( PAPI_stop_counters(NULL, 0) != PAPI_OK )
111  PAPI_perror( "PAPI_stop_counters" );
112  printf( "\n----------------------------------\n" );
113 
114  printf( "PAPI_flops\n");
115  if ( PAPI_flops(&rtime, &ptime, &flpops, &mflops) != PAPI_OK )
116  PAPI_perror( "PAPI_flops" );
117  printf( "\nStart\n");
118  printf( "real time: %f\n", rtime);
119  printf( "process time: %f\n", ptime);
120  printf( "FP Operations: %lld\n", flpops);
121  printf( "MFLOPS %f\n", mflops);
122  classic_matmul();
123  if ( PAPI_flops(&rtime, &ptime, &flpops, &mflops) != PAPI_OK )
124  PAPI_perror( "PAPI_flops" );
125  printf( "\nClassic\n");
126  printf( "real time: %f\n", rtime);
127  printf( "process time: %f\n", ptime);
128  printf( "FP Operations: %lld\n", flpops);
129  printf( "MFLOPS %f\n", mflops);
130  swapped_matmul();
131  if ( PAPI_flops(&rtime, &ptime, &flpops, &mflops) != PAPI_OK )
132  PAPI_perror( "PAPI_flops" );
133  printf( "\nSwapped\n");
134  printf( "real time: %f\n", rtime);
135  printf( "process time: %f\n", ptime);
136  printf( "FP Operations: %lld\n", flpops);
137  printf( "MFLOPS %f\n", mflops);
138 
139  // turn off flops
140  if ( PAPI_stop_counters(NULL, 0) != PAPI_OK )
141  PAPI_perror( "PAPI_stop_counters" );
142  printf( "\n----------------------------------\n" );
143 
144  printf( "PAPI_ipc\n");
145  if ( PAPI_ipc(&rtime, &ptime, &ins, &ipc) != PAPI_OK )
146  PAPI_perror( "PAPI_ipc" );
147  printf( "\nStart\n");
148  printf( "real time: %f\n", rtime);
149  printf( "process time: %f\n", ptime);
150  printf( "Instructions: %lld\n", ins);
151  printf( "IPC %f\n", ipc);
152  classic_matmul();
153  if ( PAPI_ipc(&rtime, &ptime, &ins, &ipc) != PAPI_OK )
154  PAPI_perror( "PAPI_ipc" );
155  printf( "\nClassic\n");
156  printf( "real time: %f\n", rtime);
157  printf( "process time: %f\n", ptime);
158  printf( "Instructions: %lld\n", ins);
159  printf( "IPC %f\n", ipc);
160  swapped_matmul();
161  if ( PAPI_ipc(&rtime, &ptime, &ins, &ipc) != PAPI_OK )
162  PAPI_perror( "PAPI_ipc" );
163  printf( "\nSwapped\n");
164  printf( "real time: %f\n", rtime);
165  printf( "process time: %f\n", ptime);
166  printf( "Instructions: %lld\n", ins);
167  printf( "IPC %f\n", ipc);
168 
169  // turn off ipc
170  if ( PAPI_stop_counters(NULL, 0) != PAPI_OK )
171  PAPI_perror( "PAPI_stop_counters" );
172  printf( "\n----------------------------------\n" );
173 
174  printf( "PAPI_epc\n");
175 
176  if ( argc >= 2) {
177  retval = PAPI_event_name_to_code( argv[1], &event );
178  if (retval != PAPI_OK) {
179  PAPI_perror("PAPI_event_name_to_code");
180  printf("Can't find %s; Using PAPI_TOT_INS\n", argv[1]);
181  event = 0;
182  } else {
183  printf("Using event %s\n", argv[1]);
184  }
185  }
186 
187  if ( PAPI_epc(event, &rtime, &ptime, &ref, &core, &evt, &epc) != PAPI_OK )
188  PAPI_perror( "PAPI_epc" );
189  printf( "\nStart\n");
190  printf( "real time: %f\n", rtime);
191  printf( "process time: %f\n", ptime);
192  printf( "Ref Cycles: %lld\n", ref);
193  printf( "Core Cycles: %lld\n", core);
194  printf( "Events: %lld\n", evt);
195  printf( "EPC: %f\n", epc);
196  classic_matmul();
197  if ( PAPI_epc(event, &rtime, &ptime, &ref, &core, &evt, &epc) != PAPI_OK )
198  PAPI_perror( "PAPI_epc" );
199  printf( "\nClassic\n");
200  printf( "real time: %f\n", rtime);
201  printf( "process time: %f\n", ptime);
202  printf( "Ref Cycles: %lld\n", ref);
203  printf( "Core Cycles: %lld\n", core);
204  printf( "Events: %lld\n", evt);
205  printf( "EPC: %f\n", epc);
206  swapped_matmul();
207  if ( PAPI_epc(event, &rtime, &ptime, &ref, &core, &evt, &epc) != PAPI_OK )
208  PAPI_perror( "PAPI_epc" );
209  printf( "\nSwapped\n");
210  printf( "real time: %f\n", rtime);
211  printf( "process time: %f\n", ptime);
212  printf( "Ref Cycles: %lld\n", ref);
213  printf( "Core Cycles: %lld\n", core);
214  printf( "Events: %lld\n", evt);
215  printf( "EPC: %f\n", epc);
216 
217  // turn off epc
218  if ( PAPI_stop_counters(NULL, 0) != PAPI_OK )
219  PAPI_perror( "PAPI_stop_counters" );
220  printf( "\n----------------------------------\n" );
221  exit( 1 );
222 }
void PAPI_perror(char *msg)
Definition: papi.c:4520
static void swapped_matmul()
Definition: hl_rates.c:58
int PAPI_ipc(float *rtime, float *ptime, long long *ins, float *ipc)
Definition: papi_hl.c:316
int PAPI_flops(float *rtime, float *ptime, long long *flpops, float *mflops)
Definition: papi_hl.c:259
device[deviceId] domain[domainId] event
Definition: linux-cuda.c:306
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
int int argc
Definition: iozone.c:1609
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_epc(int event, float *rtime, float *ptime, long long *ref, long long *core, long long *evt, float *epc)
Definition: papi_hl.c:383
static void init_mat()
Definition: hl_rates.c:29
int PAPI_stop_counters(long long *values, int array_len)
Definition: papi_hl.c:803
static void classic_matmul()
Definition: hl_rates.c:42
int PAPI_event_name_to_code(char *in, int *out)
Definition: papi.c:1003
ssize_t retval
Definition: libasync.c:338
void exit()

Here is the call graph for this function:

static void swapped_matmul ( )
static

Definition at line 58 of file hl_rates.c.

59 {
60  // Multiply the two matrices
61  int i, j, k;
62  for (i = 0; i < ROWS; i++) {
63  for (k = 0; k < COLUMNS; k++) {
64  for (j = 0; j < COLUMNS; j++) {
65  matrix_c[i][j] +=
66  matrix_a[i][k] * matrix_b[k][j];
67  }
68  }
69  }
70 }
#define ROWS
Definition: hl_rates.c:24
static float matrix_a[ROWS][COLUMNS]
Definition: hl_rates.c:27
int i
Definition: fileop.c:140
int k
Definition: iozone.c:19136
static float matrix_b[ROWS][COLUMNS]
Definition: hl_rates.c:27
static float matrix_c[ROWS][COLUMNS]
Definition: hl_rates.c:27
#define COLUMNS
Definition: hl_rates.c:25
long j
Definition: iozone.c:19135

Here is the caller graph for this function:

Variable Documentation

float matrix_a[ROWS][COLUMNS]
static

Definition at line 27 of file hl_rates.c.

float matrix_b[ROWS][COLUMNS]
static

Definition at line 27 of file hl_rates.c.

float matrix_c[ROWS][COLUMNS]
static

Definition at line 27 of file hl_rates.c.