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); long cycles = 1; Stopwatch Q = new Stopwatch(); while (true) { Q.start(); innerFFT(x, cycles); Q.stop(); if (Q.read() >= mintime) { break; } cycles *= 2; } validateFFT(N, x); // approx Mflops return(FFT.num_flops(N) * cycles / Q.read() * 1.0e-6); }
public static double measureFFT(int N, double mintime, Random R) { double[] data = kernel.RandomVector(checked (2 * N), R); long num1 = 20000; Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); int num2 = 0; while ((long)num2 < num1) { FFT.transform(data); FFT.inverse(data); checked { ++num2; } } stopwatch.stop(); if (FFT.test(data) / (double)N > 0.0 / 1.0) { return(0.0); } return(FFT.num_flops(N) * (double)num1 / stopwatch.read() * 1E-06); }
// 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 clock = new Stopwatch(); while (true) { clock.Start(); for (int i = 0; i < cycles; i++) { FFT.transform(x); // forward transform FFT.inverse(x); // backward transform } clock.Stop(); if (clock.Elapsed.TotalSeconds >= 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 / clock.Elapsed.TotalMilliseconds * 1.0e-3); }