hl_rates.c File Reference

Include dependency graph for hl_rates.c:

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

00043 {
00044     // Multiply the two matrices
00045     int i, j, k;
00046     for (i = 0; i < ROWS; i++) {
00047         for (j = 0; j < COLUMNS; j++) {
00048             float sum = 0.0;
00049             for (k = 0; k < COLUMNS; k++) {
00050                 sum += 
00051                     matrix_a[i][k] * matrix_b[k][j];
00052             }
00053             matrix_c[i][j] = sum;
00054         }
00055     }
00056 }

Here is the caller graph for this function:

static void init_mat (  )  [static]

Definition at line 29 of file hl_rates.c.

00030 {
00031     // Initialize the two matrices
00032     int i, j;
00033     for (i = 0; i < ROWS; i++) {
00034         for (j = 0; j < COLUMNS; j++) {
00035             matrix_a[i][j] = (float) rand() / RAND_MAX;
00036             matrix_b[i][j] = (float) rand() / RAND_MAX;
00037         }
00038     }
00039 
00040 }

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.

00074 {
00075     int retval, event = 0;
00076     float rtime, ptime, mflips, mflops, ipc, epc;
00077     long long flpins, flpops, ins, ref, core, evt;
00078 
00079     tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */
00080 
00081     init_mat();
00082 
00083     printf( "\n----------------------------------\n" );
00084     printf( "PAPI_flips\n");
00085     if ( PAPI_flips(&rtime, &ptime, &flpins, &mflips)  != PAPI_OK )
00086         PAPI_perror( "PAPI_flips" );
00087     printf( "\nStart\n");
00088     printf( "real time:       %f\n", rtime);
00089     printf( "process time:    %f\n", ptime);
00090     printf( "FP Instructions: %lld\n", flpins);
00091     printf( "MFLIPS           %f\n", mflips);
00092     classic_matmul();
00093     if ( PAPI_flips(&rtime, &ptime, &flpins, &mflips)  != PAPI_OK )
00094         PAPI_perror( "PAPI_flips" );
00095     printf( "\nClassic\n");
00096     printf( "real time:       %f\n", rtime);
00097     printf( "process time:    %f\n", ptime);
00098     printf( "FP Instructions: %lld\n", flpins);
00099     printf( "MFLIPS           %f\n", mflips);
00100     swapped_matmul();
00101     if ( PAPI_flips(&rtime, &ptime, &flpins, &mflips)  != PAPI_OK )
00102         PAPI_perror( "PAPI_flips" );
00103     printf( "\nSwapped\n");
00104     printf( "real time:       %f\n", rtime);
00105     printf( "process time:    %f\n", ptime);
00106     printf( "FP Instructions: %lld\n", flpins);
00107     printf( "MFLIPS           %f\n", mflips);
00108 
00109     // turn off flips
00110     if ( PAPI_stop_counters(NULL, 0)  != PAPI_OK )
00111         PAPI_perror( "PAPI_stop_counters" );
00112     printf( "\n----------------------------------\n" );
00113 
00114     printf( "PAPI_flops\n");
00115     if ( PAPI_flops(&rtime, &ptime, &flpops, &mflops)  != PAPI_OK )
00116         PAPI_perror( "PAPI_flops" );
00117     printf( "\nStart\n");
00118     printf( "real time:       %f\n", rtime);
00119     printf( "process time:    %f\n", ptime);
00120     printf( "FP Operations:   %lld\n", flpops);
00121     printf( "MFLOPS           %f\n", mflops);
00122     classic_matmul();
00123     if ( PAPI_flops(&rtime, &ptime, &flpops, &mflops)  != PAPI_OK )
00124         PAPI_perror( "PAPI_flops" );
00125     printf( "\nClassic\n");
00126     printf( "real time:       %f\n", rtime);
00127     printf( "process time:    %f\n", ptime);
00128     printf( "FP Operations:   %lld\n", flpops);
00129     printf( "MFLOPS           %f\n", mflops);
00130     swapped_matmul();
00131     if ( PAPI_flops(&rtime, &ptime, &flpops, &mflops)  != PAPI_OK )
00132         PAPI_perror( "PAPI_flops" );
00133     printf( "\nSwapped\n");
00134     printf( "real time:       %f\n", rtime);
00135     printf( "process time:    %f\n", ptime);
00136     printf( "FP Operations:   %lld\n", flpops);
00137     printf( "MFLOPS           %f\n", mflops);
00138 
00139     // turn off flops
00140     if ( PAPI_stop_counters(NULL, 0)  != PAPI_OK )
00141         PAPI_perror( "PAPI_stop_counters" );
00142     printf( "\n----------------------------------\n" );
00143 
00144     printf( "PAPI_ipc\n");
00145     if ( PAPI_ipc(&rtime, &ptime, &ins, &ipc)  != PAPI_OK )
00146         PAPI_perror( "PAPI_ipc" );
00147     printf( "\nStart\n");
00148     printf( "real time:       %f\n", rtime);
00149     printf( "process time:    %f\n", ptime);
00150     printf( "Instructions:    %lld\n", ins);
00151     printf( "IPC              %f\n", ipc);
00152     classic_matmul();
00153     if ( PAPI_ipc(&rtime, &ptime, &ins, &ipc)  != PAPI_OK )
00154         PAPI_perror( "PAPI_ipc" );
00155     printf( "\nClassic\n");
00156     printf( "real time:       %f\n", rtime);
00157     printf( "process time:    %f\n", ptime);
00158     printf( "Instructions:    %lld\n", ins);
00159     printf( "IPC              %f\n", ipc);
00160     swapped_matmul();
00161     if ( PAPI_ipc(&rtime, &ptime, &ins, &ipc)  != PAPI_OK )
00162         PAPI_perror( "PAPI_ipc" );
00163     printf( "\nSwapped\n");
00164     printf( "real time:       %f\n", rtime);
00165     printf( "process time:    %f\n", ptime);
00166     printf( "Instructions:    %lld\n", ins);
00167     printf( "IPC              %f\n", ipc);
00168 
00169     // turn off ipc
00170     if ( PAPI_stop_counters(NULL, 0)  != PAPI_OK )
00171         PAPI_perror( "PAPI_stop_counters" );
00172     printf( "\n----------------------------------\n" );
00173 
00174     printf( "PAPI_epc\n");
00175     
00176     if ( argc >= 2) {
00177         retval = PAPI_event_name_to_code( argv[1], &event );
00178         if (retval != PAPI_OK) {
00179             PAPI_perror("PAPI_event_name_to_code");
00180             printf("Can't find %s; Using PAPI_TOT_INS\n", argv[1]);
00181             event = 0;
00182         } else {
00183             printf("Using event %s\n", argv[1]);
00184         }
00185     }
00186 
00187     if ( PAPI_epc(event, &rtime, &ptime, &ref, &core, &evt, &epc)  != PAPI_OK )
00188         PAPI_perror( "PAPI_epc" );
00189     printf( "\nStart\n");
00190     printf( "real time:       %f\n", rtime);
00191     printf( "process time:    %f\n", ptime);
00192     printf( "Ref Cycles:      %lld\n", ref);
00193     printf( "Core Cycles:     %lld\n", core);
00194     printf( "Events:          %lld\n", evt);
00195     printf( "EPC:             %f\n", epc);
00196     classic_matmul();
00197     if ( PAPI_epc(event, &rtime, &ptime, &ref, &core, &evt, &epc)  != PAPI_OK )
00198         PAPI_perror( "PAPI_epc" );
00199     printf( "\nClassic\n");
00200     printf( "real time:       %f\n", rtime);
00201     printf( "process time:    %f\n", ptime);
00202     printf( "Ref Cycles:      %lld\n", ref);
00203     printf( "Core Cycles:     %lld\n", core);
00204     printf( "Events:          %lld\n", evt);
00205     printf( "EPC:             %f\n", epc);
00206     swapped_matmul();
00207     if ( PAPI_epc(event, &rtime, &ptime, &ref, &core, &evt, &epc)  != PAPI_OK )
00208         PAPI_perror( "PAPI_epc" );
00209     printf( "\nSwapped\n");
00210     printf( "real time:       %f\n", rtime);
00211     printf( "process time:    %f\n", ptime);
00212     printf( "Ref Cycles:      %lld\n", ref);
00213     printf( "Core Cycles:     %lld\n", core);
00214     printf( "Events:          %lld\n", evt);
00215     printf( "EPC:             %f\n", epc);
00216 
00217     // turn off epc
00218     if ( PAPI_stop_counters(NULL, 0)  != PAPI_OK )
00219         PAPI_perror( "PAPI_stop_counters" );
00220     printf( "\n----------------------------------\n" );
00221     exit( 1 );
00222 }

Here is the call graph for this function:

static void swapped_matmul (  )  [static]

Definition at line 58 of file hl_rates.c.

00059 {
00060     // Multiply the two matrices
00061     int i, j, k;
00062     for (i = 0; i < ROWS; i++) {
00063         for (k = 0; k < COLUMNS; k++) {
00064             for (j = 0; j < COLUMNS; j++) {
00065                 matrix_c[i][j] += 
00066                     matrix_a[i][k] * matrix_b[k][j];
00067             }
00068         }
00069     }
00070 }

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.


Generated on 17 Nov 2016 for PAPI by  doxygen 1.6.1