예제 #1
0
        public void DCTComparisonTest()
        {
            const int maxVariance = 2;
            var       source      = new float[8][];
            var       destAan     = new float[8][];
            var       destNvidia  = new float[8][];

            for (int i = 0; i < 8; i++)
            {
                source[i]     = new float[] { 100, 110, 120, 130, 140, 150, 160, 170 };
                destAan[i]    = new float[8];
                destNvidia[i] = new float[8];
            }

            var dct = new DCT(20);

            dct.DoDCT_AAN(source, destAan);
            dct.DoDCT_NVidia(source, destNvidia);

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    float diff  = Math.Abs(destAan[i][j] - destNvidia[i][j]);
                    float ratio = destAan[i][j] / destNvidia[i][j];
                    Debug.WriteLine("aan={0}, nvidia={1}, diff={2}, ratio={3}", destAan[i][j], destNvidia[i][j], diff, ratio);
                    Assert.IsTrue(diff <= maxVariance);
                }
            }
        }
예제 #2
0
        public void DCTPerformanceTest()
        {
            const int runs       = 5;
            const int iterations = 100000;
            var       aanPerf    = new PerformanceMonitor("AAN", runs);
            var       nvidiaPerf = new PerformanceMonitor("NVidia", runs);

            var source     = new float[8][];
            var destAan    = new float[8][];
            var destNvidia = new float[8][];

            for (int i = 0; i < 8; i++)
            {
                source[i]     = new float[] { 100, 110, 120, 130, 140, 150, 160, 170 };
                destAan[i]    = new float[8];
                destNvidia[i] = new float[8];
            }

            var dct = new DCT(20);

            for (int run = 0; run < runs; run++)
            {
                aanPerf.Start();
                for (int i = 0; i < iterations; i++)
                {
                    dct.DoDCT_AAN(source, destAan);
                }
                aanPerf.Stop();

                nvidiaPerf.Start();
                for (int i = 0; i < iterations; i++)
                {
                    dct.DoDCT_NVidia(source, destNvidia);
                }
                nvidiaPerf.Stop();
            }

            // We don't really care at this point -- they're very close.
            // Assert.IsTrue(nvidiaPerf.AverageCompletionTimeInMs > aanPerf.AverageCompletionTimeInMs);
        }