start() 공개 메소드

Start (and reset) timer
public start ( ) : void
리턴 void
예제 #1
0
        // each measurement returns approx Mflops
        public static double measureFFT(int N, double mintime, Random R)
        {
            // initialize FFT data as complex (N real/img pairs)

            double[] x = RandomVector(2 * N, R);
            //double oldx[] = NewVectorCopy(x);
            long cycles = 1;
            Stopwatch Q = new Stopwatch();
            while (true)
            {
                Q.start();
                 for (int i = 0; i < cycles; i++)
                {
                    FFT.transform(x); // forward transform
                    FFT.inverse(x); // backward transform
                }
                Q.stop();
                if (Q.read() >= mintime)
                    break;

                cycles *= 2;
            }
            // approx Mflops

            const double EPS = 1.0e-10;
            if (FFT.test(x) / N > EPS)
                return 0.0;

            return FFT.num_flops(N) * cycles / Q.read() * 1.0e-6;
        }
예제 #2
0
        public static double measureLU(int N, double min_time, Random R)
        {
            // compute approx Mlfops, or O if LU yields large errors

            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];

            Stopwatch Q = new Stopwatch();

            int cycles = 1;

            while (true)
            {
                Q.start();
                for (int i = 0; i < cycles; i++)
                {
                    CopyMatrix(lu, A);
                    LU.factor(lu, pivot);
                }
                Q.stop();
                if (Q.read() >= min_time)
                {
                    break;
                }

                cycles *= 2;
            }


            // 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)
            {
                return(0.0);
            }


            // else return approx Mflops
            //
            return(LU.num_flops(N) * cycles / Q.read() * 1.0e-6);
        }
예제 #3
0
        public static double measureLU(int N, double min_time, Random R)
        {
            // compute approx Mlfops, or O if LU yields large errors

            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];

            Stopwatch Q = new Stopwatch();

            int cycles = 1;
            while (true)
            {
                Q.start();
                 for (int i = 0; i < cycles; i++)
                {
                    CopyMatrix(lu, A);
                    LU.factor(lu, pivot);
                }
                Q.stop();
                if (Q.read() >= min_time)
                    break;

                cycles *= 2;
            }

            // 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)
                return 0.0;

            // else return approx Mflops
            //
            return LU.num_flops(N) * cycles / Q.read() * 1.0e-6;
        }
예제 #4
0
        public static double measureMonteCarlo(double min_time, Random R)
        {
            Stopwatch Q = new Stopwatch();

            int cycles = 1;

            while (true)
            {
                Q.start();
                MonteCarlo.integrate(cycles);
                Q.stop();
                if (Q.read() >= min_time)
                {
                    break;
                }

                cycles *= 2;
            }
            // approx Mflops
            return(MonteCarlo.num_flops(cycles) / Q.read() * 1.0e-6);
        }
예제 #5
0
        public static double measureSOR(int N, double min_time, Random R)
        {
            double[][] G = RandomMatrix(N, N, R);

            Stopwatch Q      = new Stopwatch();
            int       cycles = 1;

            while (true)
            {
                Q.start();
                SOR.execute(1.25, G, cycles);
                Q.stop();
                if (Q.read() >= min_time)
                {
                    break;
                }

                cycles *= 2;
            }
            // approx Mflops
            return(SOR.num_flops(N, N, cycles) / Q.read() * 1.0e-6);
        }
예제 #6
0
        // each measurement returns approx Mflops
        public static double measureFFT(int N, double mintime, Random R)
        {
            // initialize FFT data as complex (N real/img pairs)

            double[] x = RandomVector(2 * N, R);
            //double oldx[] = NewVectorCopy(x);
            long      cycles = 1;
            Stopwatch Q      = new Stopwatch();

            while (true)
            {
                Q.start();
                for (int i = 0; i < cycles; i++)
                {
                    FFT.transform(x);                   // forward transform
                    FFT.inverse(x);                     // backward transform
                }
                Q.stop();
                if (Q.read() >= mintime)
                {
                    break;
                }

                cycles *= 2;
            }
            // approx Mflops

            const double EPS = 1.0e-10;

            if (FFT.test(x) / N > EPS)
            {
                return(0.0);
            }

            return(FFT.num_flops(N) * cycles / Q.read() * 1.0e-6);
        }
예제 #7
0
        public static double measureMonteCarlo(double min_time, Random R)
        {
            Stopwatch Q = new Stopwatch();

            int cycles = 1;
            while (true)
            {
                Q.start();
                MonteCarlo.integrate(cycles);
                Q.stop();
                if (Q.read() >= min_time)
                    break;

                cycles *= 2;
            }
            // approx Mflops
            return MonteCarlo.num_flops(cycles) / Q.read() * 1.0e-6;
        }
예제 #8
0
        public static double measureSparseMatmult(int N, int nz, double min_time, Random R)
        {
            // initialize vector multipliers and storage for result
            // y = A*y;

            double[] x = RandomVector(N, R);
            double[] y = new double[N];

            // initialize square sparse matrix
            //
            // for this test, we create a sparse matrix wit M/nz nonzeros
            // per row, with spaced-out evenly between the begining of the
            // row to the main diagonal.  Thus, the resulting pattern looks
            // like
            //             +-----------------+
            //             +*                +
            //             +***              +
            //             +* * *            +
            //             +** *  *          +
            //             +**  *   *        +
            //             +* *   *   *      +
            //             +*  *   *    *    +
            //             +*   *    *    *  +
            //             +-----------------+
            //
            // (as best reproducible with integer artihmetic)
            // Note that the first nr rows will have elements past
            // the diagonal.

            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;

            }

            Stopwatch Q = new Stopwatch();

            int cycles = 1;
            while (true)
            {
                Q.start();
                SparseCompRow.matmult(y, val, row, col, x, cycles);
                Q.stop();
                if (Q.read() >= min_time)
                    break;

                cycles *= 2;
            }
            // approx Mflops
            return SparseCompRow.num_flops(N, nz, cycles) / Q.read() * 1.0e-6;
        }
예제 #9
0
        public static double measureSOR(int N, double min_time, Random R)
        {
            double[][] G = RandomMatrix(N, N, R);

            Stopwatch Q = new Stopwatch();
            int cycles = 1;
            while (true)
            {
                Q.start();
                SOR.execute(1.25, G, cycles);
                Q.stop();
                if (Q.read() >= min_time)
                    break;

                cycles *= 2;
            }
            // approx Mflops
            return SOR.num_flops(N, N, cycles) / Q.read() * 1.0e-6;
        }
예제 #10
0
        public static double measureSparseMatmult(int N, int nz, double min_time, Random R)
        {
            // initialize vector multipliers and storage for result
            // y = A*y;

            double[] x = RandomVector(N, R);
            double[] y = new double[N];

            // initialize square sparse matrix
            //
            // for this test, we create a sparse matrix wit M/nz nonzeros
            // per row, with spaced-out evenly between the begining of the
            // row to the main diagonal.  Thus, the resulting pattern looks
            // like
            //             +-----------------+
            //             +*                +
            //             +***              +
            //             +* * *            +
            //             +** *  *          +
            //             +**  *   *        +
            //             +* *   *   *      +
            //             +*  *   *    *    +
            //             +*   *    *    *  +
            //             +-----------------+
            //
            // (as best reproducible with integer artihmetic)
            // Note that the first nr rows will have elements past
            // the diagonal.

            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;
                }
            }

            Stopwatch Q = new Stopwatch();

            int cycles = 1;

            while (true)
            {
                Q.start();
                SparseCompRow.matmult(y, val, row, col, x, cycles);
                Q.stop();
                if (Q.read() >= min_time)
                {
                    break;
                }

                cycles *= 2;
            }
            // approx Mflops
            return(SparseCompRow.num_flops(N, nz, cycles) / Q.read() * 1.0e-6);
        }