コード例 #1
0
ファイル: kernel.cs プロジェクト: wyrover/coreclr
        public static void benchmarkLU()
        {
            int N = Constants.LU_SIZE;

            SciMark2.Random R          = new SciMark2.Random(Constants.RANDOM_SEED);
            int             Iterations = 2000;

            double[][] A  = RandomMatrix(N, N, R);
            double[][] lu = new double[N][];
            for (int i = 0; i < N; i++)
            {
                lu[i] = new double[N];
            }
            int[] pivot = new int[N];

            foreach (var iteration in Benchmark.Iterations)
            {
                using (iteration.StartMeasurement())
                {
                    for (int i = 0; i < Iterations; i++)
                    {
                        CopyMatrix(lu, A);
                        LU.factor(lu, pivot);
                    }
                }
            }

            validateLU(N, R, lu, A, pivot);
        }
コード例 #2
0
        public void SetupSOR()
        {
            Random R = new SciMark2.Random(Constants.RANDOM_SEED);
            int    N = Constants.SOR_SIZE;

            inputSOR = RandomMatrix(N, N, R);
        }
コード例 #3
0
        public void SetupFFT()
        {
            Random R = new SciMark2.Random(Constants.RANDOM_SEED);
            int    N = Constants.FFT_SIZE;

            inputFFT = RandomVector(2 * N, R);
        }
コード例 #4
0
ファイル: kernel.cs プロジェクト: wyrover/coreclr
        public static void benchMonteCarlo()
        {
            SciMark2.Random R          = new SciMark2.Random(Constants.RANDOM_SEED);
            int             Iterations = 40000000;

            foreach (var iteration in Benchmark.Iterations)
            {
                using (iteration.StartMeasurement())
                {
                    MonteCarlo.integrate(Iterations);
                }
            }
        }
コード例 #5
0
        public void SetupLU()
        {
            Random R = new SciMark2.Random(Constants.RANDOM_SEED);

            int N = Constants.LU_SIZE;

            inputLUA = RandomMatrix(N, N, R);
            inputLU  = new double[N][];
            for (int i = 0; i < N; i++)
            {
                inputLU[i] = new double[N];
            }
            inputLUPivot = new int[N];
        }
コード例 #6
0
ファイル: kernel.cs プロジェクト: Alantoo/coreclr
        public static void benchSOR()
        {
            int N = Constants.SOR_SIZE;
            SciMark2.Random R = new SciMark2.Random(Constants.RANDOM_SEED);
            int Iterations = 20000;
            double[][] G = RandomMatrix(N, N, R);

            foreach (var iteration in Benchmark.Iterations)
            {
                using (iteration.StartMeasurement())
                {
                    SOR.execute(1.25, G, Iterations);
                }
            }
        }
コード例 #7
0
ファイル: kernel.cs プロジェクト: wyrover/coreclr
        public static void validateLU(int N, SciMark2.Random R, double[][] lu, double[][] A, int[] pivot)
        {
            // verify that LU is correct
            double[] b = RandomVector(N, R);
            double[] x = NewVectorCopy(b);

            LU.solve(lu, pivot, x);

            const double EPS = 1.0e-12;

            if (normabs(b, matvec(A, x)) / N > EPS)
            {
                throw new Exception("LU failed to validate");
            }
        }
コード例 #8
0
ファイル: kernel.cs プロジェクト: wyrover/coreclr
        public static void benchFFT()
        {
            SciMark2.Random R          = new SciMark2.Random(Constants.RANDOM_SEED);
            int             N          = Constants.FFT_SIZE;
            long            Iterations = 20000;

            double[] x = RandomVector(2 * N, R);
            foreach (var iteration in Benchmark.Iterations)
            {
                using (iteration.StartMeasurement())
                {
                    innerFFT(x, Iterations);
                }
            }
            validateFFT(N, x);
        }
コード例 #9
0
ファイル: kernel.cs プロジェクト: geoffkizer/coreclr
        public static void benchFFT()
        {
            SciMark2.Random R = new SciMark2.Random(Constants.RANDOM_SEED);
            int N = Constants.FFT_SIZE;
            long Iterations = 20000;

            double[] x = RandomVector(2 * N, R);
            foreach (var iteration in Benchmark.Iterations)
            {
                using (iteration.StartMeasurement())
                {
                    innerFFT(x, Iterations);
                }
            }
            validateFFT(N, x);
        }
コード例 #10
0
ファイル: MonteCarlo.cs プロジェクト: Alantoo/coreclr
        public static double integrate(int Num_samples)
        {
            SciMark2.Random R = new SciMark2.Random(SEED);


            int under_curve = 0;
            for (int count = 0; count < Num_samples; count++)
            {
                double x = R.nextDouble();
                double y = R.nextDouble();

                if (x * x + y * y <= 1.0)
                    under_curve++;
            }

            return ((double)under_curve / Num_samples) * 4.0;
        }
コード例 #11
0
ファイル: kernel.cs プロジェクト: wyrover/coreclr
        public static void benchSOR()
        {
            int N = Constants.SOR_SIZE;

            SciMark2.Random R          = new SciMark2.Random(Constants.RANDOM_SEED);
            int             Iterations = 20000;

            double[][] G = RandomMatrix(N, N, R);

            foreach (var iteration in Benchmark.Iterations)
            {
                using (iteration.StartMeasurement())
                {
                    SOR.execute(1.25, G, Iterations);
                }
            }
        }
コード例 #12
0
ファイル: kernel.cs プロジェクト: wyrover/coreclr
        public static void benchSparseMult()
        {
            int N          = Constants.SPARSE_SIZE_M;
            int nz         = Constants.SPARSE_SIZE_nz;
            int Iterations = 100000;

            SciMark2.Random R = new SciMark2.Random(Constants.RANDOM_SEED);

            double[] x   = RandomVector(N, R);
            double[] y   = new double[N];
            int      nr  = nz / N; // average number of nonzeros per row
            int      anz = nr * N; // _actual_ number of nonzeros

            double[] val = RandomVector(anz, R);
            int[]    col = new int[anz];
            int[]    row = new int[N + 1];

            row[0] = 0;
            for (int r = 0; r < N; r++)
            {
                // initialize elements for row r

                int rowr = row[r];
                row[r + 1] = rowr + nr;
                int step = r / nr;
                if (step < 1)
                {
                    step = 1;
                }
                // take at least unit steps

                for (int i = 0; i < nr; i++)
                {
                    col[rowr + i] = i * step;
                }
            }

            foreach (var iteration in Benchmark.Iterations)
            {
                using (iteration.StartMeasurement())
                {
                    SparseCompRow.matmult(y, val, row, col, x, Iterations);
                }
            }
        }
コード例 #13
0
        public static double integrate(int Num_samples)
        {
            SciMark2.Random R = new SciMark2.Random(SEED);


            int under_curve = 0;

            for (int count = 0; count < Num_samples; count++)
            {
                double x = R.nextDouble();
                double y = R.nextDouble();

                if (x * x + y * y <= 1.0)
                {
                    under_curve++;
                }
            }

            return(((double)under_curve / Num_samples) * 4.0);
        }
コード例 #14
0
        public void SetupSparseMult()
        {
            Random R = new SciMark2.Random(Constants.RANDOM_SEED);

            int N  = Constants.SPARSE_SIZE_M;
            int nz = Constants.SPARSE_SIZE_nz;

            inputSparseMultX = RandomVector(N, R);
            inputSparseMultY = new double[N];
            int nr  = nz / N; // average number of nonzeros per row
            int anz = nr * N; // _actual_ number of nonzeros

            inputSparseMultVal = RandomVector(anz, R);
            inputSparseMultCol = new int[anz];
            inputSparseMultRow = new int[N + 1];

            inputSparseMultRow[0] = 0;
            for (int r = 0; r < N; r++)
            {
                // initialize elements for row r

                int rowr = inputSparseMultRow[r];
                inputSparseMultRow[r + 1] = rowr + nr;
                int step = r / nr;
                if (step < 1)
                {
                    step = 1;
                }
                // take at least unit steps

                for (int i = 0; i < nr; i++)
                {
                    inputSparseMultCol[rowr + i] = i * step;
                }
            }
        }
コード例 #15
0
ファイル: CommandLine.cs プロジェクト: CheneyWu/coreclr
        /// <summary>
        ///  Benchmark 5 kernels with individual Mflops.
        ///  "results[0]" has the average Mflop rate.
        /// </summary>
        public static int Main(System.String[] args)
        {
#if DEBUG
            double min_time = Constants.RESOLUTION_TINY;
#else
            double min_time = Constants.RESOLUTION_DEFAULT;
#endif

            int FFT_size = Constants.FFT_SIZE;
            int SOR_size = Constants.SOR_SIZE;
            int Sparse_size_M = Constants.SPARSE_SIZE_M;
            int Sparse_size_nz = Constants.SPARSE_SIZE_nz;
            int LU_size = Constants.LU_SIZE;

            // look for runtime options
            if (args.Length > 0)
            {
                if (args[0].ToUpper().Equals("-h") ||
                    args[0].ToUpper().Equals("-help"))
                {
                    Console.WriteLine("Usage: [-large] [iterations]");
                    return -1;
                }

                int current_arg = 0;
                if (args[current_arg].ToUpper().Equals("-LARGE"))
                {
                    FFT_size = Constants.LG_FFT_SIZE;
                    SOR_size = Constants.LG_SOR_SIZE;
                    Sparse_size_M = Constants.LG_SPARSE_SIZE_M;
                    Sparse_size_nz = Constants.LG_SPARSE_SIZE_nz;
                    LU_size = Constants.LG_LU_SIZE;

                    current_arg++;
                }

                if (args.Length > current_arg)
                    min_time = Double.Parse(args[current_arg]);
            }
            Console.WriteLine("**                                                               **");
            Console.WriteLine("** SciMark2a Numeric Benchmark, see http://math.nist.gov/scimark **");
            Console.WriteLine("**                                                               **");

            // run the benchmark
            double[] res = new double[6];
            SciMark2.Random R = new SciMark2.Random(Constants.RANDOM_SEED);

            Console.WriteLine("Mininum running time = {0} seconds", min_time);

            res[1] = kernel.measureFFT(FFT_size, min_time, R);

            res[2] = kernel.measureSOR(SOR_size, min_time, R);

            res[3] = kernel.measureMonteCarlo(min_time, R);

            res[4] = kernel.measureSparseMatmult(Sparse_size_M, Sparse_size_nz, min_time, R);

            res[5] = kernel.measureLU(LU_size, min_time, R);

            res[0] = (res[1] + res[2] + res[3] + res[4] + res[5]) / 5;

            // print out results
            Console.WriteLine();
            Console.WriteLine("Composite Score: {0:F2} MFlops", res[0]);
            Console.WriteLine("FFT            : {0} - ({1})", res[1] == 0.0 ? "ERROR, INVALID NUMERICAL RESULT!" : res[1].ToString("F2"), FFT_size);
            Console.WriteLine("SOR            : {1:F2} - ({0}x{0})", SOR_size, res[2]);
            Console.WriteLine("Monte Carlo    :  {0:F2}", res[3]);
            Console.WriteLine("Sparse MatMult : {2:F2} - (N={0}, nz={1})", Sparse_size_M, Sparse_size_nz, res[4]);
            Console.WriteLine("LU             : {1} - ({0}x{0})", LU_size, res[1] == 0.0 ? "ERROR, INVALID NUMERICAL RESULT!" : res[5].ToString("F2"));

            return 100;
        }
コード例 #16
0
ファイル: kernel.cs プロジェクト: geoffkizer/coreclr
 public static void benchMonteCarlo()
 {
     SciMark2.Random R = new SciMark2.Random(Constants.RANDOM_SEED);
     int Iterations = 40000000;
     foreach (var iteration in Benchmark.Iterations)
     {
         using (iteration.StartMeasurement())
         {
             MonteCarlo.integrate(Iterations);
         }
     }
 }
コード例 #17
0
ファイル: kernel.cs プロジェクト: geoffkizer/coreclr
        public static void benchSparseMult()
        {
            int N = Constants.SPARSE_SIZE_M;
            int nz = Constants.SPARSE_SIZE_nz;
            int Iterations = 100000;
            SciMark2.Random R = new SciMark2.Random(Constants.RANDOM_SEED);

            double[] x = RandomVector(N, R);
            double[] y = new double[N];
            int nr = nz / N; // average number of nonzeros per row
            int anz = nr * N; // _actual_ number of nonzeros
            double[] val = RandomVector(anz, R);
            int[] col = new int[anz];
            int[] row = new int[N + 1];

            row[0] = 0;
            for (int r = 0; r < N; r++)
            {
                // initialize elements for row r

                int rowr = row[r];
                row[r + 1] = rowr + nr;
                int step = r / nr;
                if (step < 1)
                    step = 1;
                // take at least unit steps

                for (int i = 0; i < nr; i++)
                    col[rowr + i] = i * step;
            }

            foreach (var iteration in Benchmark.Iterations)
            {
                using (iteration.StartMeasurement())
                {
                    SparseCompRow.matmult(y, val, row, col, x, Iterations);
                }
            }
        }
コード例 #18
0
ファイル: kernel.cs プロジェクト: geoffkizer/coreclr
        public static void benchmarkLU()
        {
            int N = Constants.LU_SIZE;
            SciMark2.Random R = new SciMark2.Random(Constants.RANDOM_SEED);
            int Iterations = 2000;

            double[][] A = RandomMatrix(N, N, R);
            double[][] lu = new double[N][];
            for (int i = 0; i < N; i++)
            {
                lu[i] = new double[N];
            }
            int[] pivot = new int[N];

            foreach (var iteration in Benchmark.Iterations)
            {
                using (iteration.StartMeasurement())
                {
                    for (int i = 0; i < Iterations; i++)
                    {
                        CopyMatrix(lu, A);
                        LU.factor(lu, pivot);
                    }
                }
            }

            validateLU(N, R, lu, A, pivot);
        }
コード例 #19
0
ファイル: CommandLine.cs プロジェクト: Fredo-Q/dotnet-coreclr
        /// <summary>
        ///  Benchmark 5 kernels with individual Mflops.
        ///  "results[0]" has the average Mflop rate.
        /// </summary>
        public static int Main(System.String[] args)
        {
#if DEBUG
            double min_time = Constants.RESOLUTION_TINY;
#else
            double min_time = Constants.RESOLUTION_DEFAULT;
#endif

            int FFT_size       = Constants.FFT_SIZE;
            int SOR_size       = Constants.SOR_SIZE;
            int Sparse_size_M  = Constants.SPARSE_SIZE_M;
            int Sparse_size_nz = Constants.SPARSE_SIZE_nz;
            int LU_size        = Constants.LU_SIZE;

            // look for runtime options
            if (args.Length > 0)
            {
                if (args[0].ToUpper().Equals("-h") ||
                    args[0].ToUpper().Equals("-help"))
                {
                    Console.WriteLine("Usage: [-large] [iterations]");
                    return(-1);
                }

                int current_arg = 0;
                if (args[current_arg].ToUpper().Equals("-LARGE"))
                {
                    FFT_size       = Constants.LG_FFT_SIZE;
                    SOR_size       = Constants.LG_SOR_SIZE;
                    Sparse_size_M  = Constants.LG_SPARSE_SIZE_M;
                    Sparse_size_nz = Constants.LG_SPARSE_SIZE_nz;
                    LU_size        = Constants.LG_LU_SIZE;

                    current_arg++;
                }

                if (args.Length > current_arg)
                {
                    min_time = Double.Parse(args[current_arg]);
                }
            }
            Console.WriteLine("**                                                               **");
            Console.WriteLine("** SciMark2a Numeric Benchmark, see http://math.nist.gov/scimark **");
            Console.WriteLine("**                                                               **");

            // run the benchmark
            double[]        res = new double[6];
            SciMark2.Random R   = new SciMark2.Random(Constants.RANDOM_SEED);

            Console.WriteLine("Mininum running time = {0} seconds", min_time);

            res[1] = kernel.measureFFT(FFT_size, min_time, R);

            res[2] = kernel.measureSOR(SOR_size, min_time, R);

            res[3] = kernel.measureMonteCarlo(min_time, R);

            res[4] = kernel.measureSparseMatmult(Sparse_size_M, Sparse_size_nz, min_time, R);

            res[5] = kernel.measureLU(LU_size, min_time, R);

            res[0] = (res[1] + res[2] + res[3] + res[4] + res[5]) / 5;

            // print out results
            Console.WriteLine();
            Console.WriteLine("Composite Score: {0:F2} MFlops", res[0]);
            Console.WriteLine("FFT            : {0} - ({1})", res[1] == 0.0 ? "ERROR, INVALID NUMERICAL RESULT!" : res[1].ToString("F2"), FFT_size);
            Console.WriteLine("SOR            : {1:F2} - ({0}x{0})", SOR_size, res[2]);
            Console.WriteLine("Monte Carlo    :  {0:F2}", res[3]);
            Console.WriteLine("Sparse MatMult : {2:F2} - (N={0}, nz={1})", Sparse_size_M, Sparse_size_nz, res[4]);
            Console.WriteLine("LU             : {1} - ({0}x{0})", LU_size, res[1] == 0.0 ? "ERROR, INVALID NUMERICAL RESULT!" : res[5].ToString("F2"));

            return(100);
        }