private static void TestOmegas() { Print(OmegaCalculator.CalculateOmegasRowBasic(32), true); Console.WriteLine(); Print(OmegaCalculator.CalculateOmegasRowOptimised(32), true); for (int n = 2; n < 12; n++) { int k = (int)Math.Pow(2, n); stopwatch.Restart(); for (int i = 0; i < 1000; i++) { OmegaCalculator.CalculateOmegasRowBasic(k); } stopwatch.Stop(); t1 = stopwatch.ElapsedMilliseconds; t2 = stopwatch.ElapsedTicks; stopwatch.Restart(); for (int i = 0; i < 1000; i++) { OmegaCalculator.CalculateOmegasRowOptimised(k); } stopwatch.Stop(); t3 = stopwatch.ElapsedMilliseconds; t4 = stopwatch.ElapsedTicks; Console.WriteLine($"{k,4} {t1,6} {t2,10} {t3,6} {t4,10} {t2 / t4}"); //Console.WriteLine($"n = {k}\nBasic: {t1}ms\nOptimised: {t3}ms\nSpeedup: {t2 / t4}x"); } }
private static void TestKernels() { float[] tmp = new float[] { 1, 2, 3, 4, 4, 3, 2, 1, 0, 6, 4, 3, 1, 11, 14, 2 }; ComplexFloat[] test = tmp.Convert(); FFTParallelOptimised.omegas = OmegaCalculator.GenerateOmegas(4); stopwatch.Start(); Print(FFTOptimisedKernels.Kernel16(tmp, ref FFTParallelOptimised.omegas), true); for (int i = 0; i < 1000; i++) { FFTOptimisedKernels.Kernel16(tmp, ref FFTParallelOptimised.omegas); } stopwatch.Stop(); t1 = stopwatch.ElapsedTicks; Console.WriteLine(); stopwatch.Restart(); Print(FFTParallelOptimised.FFT(tmp, false), true); for (int i = 0; i < 1000; i++) { FFTParallelOptimised.FFT(tmp, false); } stopwatch.Stop(); t2 = stopwatch.ElapsedTicks; Console.WriteLine(); Console.WriteLine(t1 + " " + t2 + " " + t1 / (float)t2); }