Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:56

0001 #include <stdio.h>
0002 #include <stdlib.h>
0003 #include <string.h>
0004 
0005 #include "Random.h"
0006 #include "kernel.h"
0007 #include "constants.h"
0008 
0009 void print_banner(void);
0010 
0011 int main(int argc, char *argv[]) {
0012   /* default to the (small) cache-contained version */
0013 
0014   double min_time = RESOLUTION_DEFAULT;
0015 
0016   int FFT_size = FFT_SIZE;
0017   int SOR_size = SOR_SIZE;
0018   int Sparse_size_M = SPARSE_SIZE_M;
0019   int Sparse_size_nz = SPARSE_SIZE_nz;
0020   int LU_size = LU_SIZE;
0021 
0022   /* run the benchmark */
0023 
0024   double res[6] = {0.0};
0025   Random R = new_Random_seed(RANDOM_SEED);
0026 
0027   if (argc > 1) {
0028     int current_arg = 1;
0029 
0030     if (strcmp(argv[1], "-help") == 0 || strcmp(argv[1], "-h") == 0) {
0031       fprintf(stderr, "Usage: [-large] [minimum_time]\n");
0032       exit(0);
0033     }
0034 
0035     if (strcmp(argv[1], "-large") == 0) {
0036       FFT_size = LG_FFT_SIZE;
0037       SOR_size = LG_SOR_SIZE;
0038       Sparse_size_M = LG_SPARSE_SIZE_M;
0039       Sparse_size_nz = LG_SPARSE_SIZE_nz;
0040       LU_size = LG_LU_SIZE;
0041 
0042       current_arg++;
0043     }
0044 
0045     if (current_arg < argc) {
0046       min_time = atof(argv[current_arg]);
0047     }
0048   }
0049 
0050   print_banner();
0051   printf("Using %10.2f seconds min time per kenel.\n", min_time);
0052 
0053   res[1] = kernel_measureFFT(FFT_size, min_time, R);
0054   res[2] = kernel_measureSOR(SOR_size, min_time, R);
0055   res[3] = kernel_measureMonteCarlo(min_time, R);
0056   res[4] = kernel_measureSparseMatMult(Sparse_size_M, Sparse_size_nz, min_time, R);
0057   res[5] = kernel_measureLU(LU_size, min_time, R);
0058 
0059   res[0] = (res[1] + res[2] + res[3] + res[4] + res[5]) / 5;
0060 
0061   /* print out results  */
0062   printf("Composite Score:        %8.2f\n", res[0]);
0063   printf("FFT             Mflops: %8.2f    (N=%d)\n", res[1], FFT_size);
0064   printf("SOR             Mflops: %8.2f    (%d x %d)\n", res[2], SOR_size, SOR_size);
0065   printf("MonteCarlo:     Mflops: %8.2f\n", res[3]);
0066   printf("Sparse matmult  Mflops: %8.2f    (N=%d, nz=%d)\n", res[4], Sparse_size_M, Sparse_size_nz);
0067   printf("LU              Mflops: %8.2f    (M=%d, N=%d)\n", res[5], LU_size, LU_size);
0068 
0069   Random_delete(R);
0070 
0071   return 0;
0072 }
0073 
0074 void print_banner() {
0075   printf("**                                                              **\n");
0076   printf("** SciMark2 Numeric Benchmark, see http://math.nist.gov/scimark **\n");
0077   printf("** for details. (Results can be submitted to pozo@nist.gov)     **\n");
0078   printf("**                                                              **\n");
0079 }