|
PAPI
5.3.0.0
|

Go to the source code of this file.
Defines | |
| #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] |
| #define COLUMNS 1000 |
Definition at line 25 of file hl_rates.c.
| #define ROWS 1000 |
Definition at line 24 of file hl_rates.c.
| static void classic_matmul | ( | ) | [static] |
Definition at line 42 of file hl_rates.c.
{
// Multiply the two matrices
int i, j, k;
for (i = 0; i < ROWS; i++) {
for (j = 0; j < COLUMNS; j++) {
float sum = 0.0;
for (k = 0; k < COLUMNS; k++) {
sum +=
matrix_a[i][k] * matrix_b[k][j];
}
matrix_c[i][j] = sum;
}
}
}

| static void init_mat | ( | ) | [static] |
Definition at line 29 of file hl_rates.c.
{
// Initialize the two matrices
int i, j;
for (i = 0; i < ROWS; i++) {
for (j = 0; j < COLUMNS; j++) {
matrix_a[i][j] = (float) rand() / RAND_MAX;
matrix_b[i][j] = (float) rand() / RAND_MAX;
}
}
}


| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Definition at line 73 of file hl_rates.c.
{
int retval, event = 0;
float rtime, ptime, mflips, mflops, ipc, epc;
long long flpins, flpops, ins, ref, core, evt;
tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
init_mat();
printf( "\n----------------------------------\n" );
printf( "PAPI_flips\n");
if ( PAPI_flips(&rtime, &ptime, &flpins, &mflips) != PAPI_OK )
PAPI_perror( "PAPI_flips" );
printf( "\nStart\n");
printf( "real time: %f\n", rtime);
printf( "process time: %f\n", ptime);
printf( "FP Instructions: %lld\n", flpins);
printf( "MFLIPS %f\n", mflips);
classic_matmul();
if ( PAPI_flips(&rtime, &ptime, &flpins, &mflips) != PAPI_OK )
PAPI_perror( "PAPI_flips" );
printf( "\nClassic\n");
printf( "real time: %f\n", rtime);
printf( "process time: %f\n", ptime);
printf( "FP Instructions: %lld\n", flpins);
printf( "MFLIPS %f\n", mflips);
swapped_matmul();
if ( PAPI_flips(&rtime, &ptime, &flpins, &mflips) != PAPI_OK )
PAPI_perror( "PAPI_flips" );
printf( "\nSwapped\n");
printf( "real time: %f\n", rtime);
printf( "process time: %f\n", ptime);
printf( "FP Instructions: %lld\n", flpins);
printf( "MFLIPS %f\n", mflips);
// turn off flips
if ( PAPI_stop_counters(NULL, 0) != PAPI_OK )
PAPI_perror( "PAPI_stop_counters" );
printf( "\n----------------------------------\n" );
printf( "PAPI_flops\n");
if ( PAPI_flops(&rtime, &ptime, &flpops, &mflops) != PAPI_OK )
PAPI_perror( "PAPI_flops" );
printf( "\nStart\n");
printf( "real time: %f\n", rtime);
printf( "process time: %f\n", ptime);
printf( "FP Operations: %lld\n", flpops);
printf( "MFLOPS %f\n", mflops);
classic_matmul();
if ( PAPI_flops(&rtime, &ptime, &flpops, &mflops) != PAPI_OK )
PAPI_perror( "PAPI_flops" );
printf( "\nClassic\n");
printf( "real time: %f\n", rtime);
printf( "process time: %f\n", ptime);
printf( "FP Operations: %lld\n", flpops);
printf( "MFLOPS %f\n", mflops);
swapped_matmul();
if ( PAPI_flops(&rtime, &ptime, &flpops, &mflops) != PAPI_OK )
PAPI_perror( "PAPI_flops" );
printf( "\nSwapped\n");
printf( "real time: %f\n", rtime);
printf( "process time: %f\n", ptime);
printf( "FP Operations: %lld\n", flpops);
printf( "MFLOPS %f\n", mflops);
// turn off flops
if ( PAPI_stop_counters(NULL, 0) != PAPI_OK )
PAPI_perror( "PAPI_stop_counters" );
printf( "\n----------------------------------\n" );
printf( "PAPI_ipc\n");
if ( PAPI_ipc(&rtime, &ptime, &ins, &ipc) != PAPI_OK )
PAPI_perror( "PAPI_ipc" );
printf( "\nStart\n");
printf( "real time: %f\n", rtime);
printf( "process time: %f\n", ptime);
printf( "Instructions: %lld\n", ins);
printf( "IPC %f\n", ipc);
classic_matmul();
if ( PAPI_ipc(&rtime, &ptime, &ins, &ipc) != PAPI_OK )
PAPI_perror( "PAPI_ipc" );
printf( "\nClassic\n");
printf( "real time: %f\n", rtime);
printf( "process time: %f\n", ptime);
printf( "Instructions: %lld\n", ins);
printf( "IPC %f\n", ipc);
swapped_matmul();
if ( PAPI_ipc(&rtime, &ptime, &ins, &ipc) != PAPI_OK )
PAPI_perror( "PAPI_ipc" );
printf( "\nSwapped\n");
printf( "real time: %f\n", rtime);
printf( "process time: %f\n", ptime);
printf( "Instructions: %lld\n", ins);
printf( "IPC %f\n", ipc);
// turn off ipc
if ( PAPI_stop_counters(NULL, 0) != PAPI_OK )
PAPI_perror( "PAPI_stop_counters" );
printf( "\n----------------------------------\n" );
printf( "PAPI_epc\n");
if ( argc >= 2) {
retval = PAPI_event_name_to_code( argv[1], &event );
if (retval != PAPI_OK) {
PAPI_perror("PAPI_event_name_to_code");
printf("Can't find %s; Using PAPI_TOT_INS\n", argv[1]);
event = 0;
} else {
printf("Using event %s\n", argv[1]);
}
}
if ( PAPI_epc(event, &rtime, &ptime, &ref, &core, &evt, &epc) != PAPI_OK )
PAPI_perror( "PAPI_epc" );
printf( "\nStart\n");
printf( "real time: %f\n", rtime);
printf( "process time: %f\n", ptime);
printf( "Ref Cycles: %lld\n", ref);
printf( "Core Cycles: %lld\n", core);
printf( "Events: %lld\n", evt);
printf( "EPC: %f\n", epc);
classic_matmul();
if ( PAPI_epc(event, &rtime, &ptime, &ref, &core, &evt, &epc) != PAPI_OK )
PAPI_perror( "PAPI_epc" );
printf( "\nClassic\n");
printf( "real time: %f\n", rtime);
printf( "process time: %f\n", ptime);
printf( "Ref Cycles: %lld\n", ref);
printf( "Core Cycles: %lld\n", core);
printf( "Events: %lld\n", evt);
printf( "EPC: %f\n", epc);
swapped_matmul();
if ( PAPI_epc(event, &rtime, &ptime, &ref, &core, &evt, &epc) != PAPI_OK )
PAPI_perror( "PAPI_epc" );
printf( "\nSwapped\n");
printf( "real time: %f\n", rtime);
printf( "process time: %f\n", ptime);
printf( "Ref Cycles: %lld\n", ref);
printf( "Core Cycles: %lld\n", core);
printf( "Events: %lld\n", evt);
printf( "EPC: %f\n", epc);
// turn off epc
if ( PAPI_stop_counters(NULL, 0) != PAPI_OK )
PAPI_perror( "PAPI_stop_counters" );
printf( "\n----------------------------------\n" );
exit( 1 );
}

| static void swapped_matmul | ( | ) | [static] |
Definition at line 27 of file hl_rates.c.
Definition at line 27 of file hl_rates.c.
Definition at line 27 of file hl_rates.c.