Beispiel #1
0
        static double GetGFlops(ComputeMethod Method, bool IsFloat)
        {
            int upper = 10000000;

            float[]  fvalues = Enumerable.Range(0, upper).Select(x => Convert.ToSingle(x)).ToArray();
            double[] dvalues = Enumerable.Range(0, upper).Select(x => Convert.ToDouble(x)).ToArray();

            long worksize = upper / 1000000;

            if (IsFloat)
            {
                Method.Invoke(worksize, fvalues, 2.0f); //invoke once to cache everything
            }
            else
            {
                Method.Invoke(worksize, dvalues, 2.0); //invoke once to cache everything
            }

            Stopwatch watch = Stopwatch.StartNew();

            while (watch.Elapsed.TotalMilliseconds < 25) //loop until 25ms or 10000000 elements
            {
                watch.Restart();

                if (IsFloat)
                {
                    Method.Invoke(worksize);
                }
                else
                {
                    Method.Invoke(worksize);
                }

                if (worksize == upper)
                {
                    break;
                }
                worksize = Math.Min(worksize * 2, upper);
            }

            double flops  = (double)4096 * worksize / (watch.Elapsed.TotalSeconds);
            double gflops = (flops / 1000000000.0);

            return(gflops);
        }
Beispiel #2
0
        public static double GetDeviceBandwidth_GBps(AcceleratorDevice Device)
        {
            ComputeMethod method = new ComputeMethod(Kernels.PerformanceKernel, "Bandwidth", Device);

            int[]  values = Enumerable.Range(0, 1000000).ToArray();
            double bytes  = values.Length * sizeof(int);

            method.Invoke(values.Length, values);
            method.Invoke(values.Length);

            Stopwatch total = Stopwatch.StartNew();

            method.Invoke(values.Length);

            double bytespersec  = bytes / total.Elapsed.TotalSeconds;
            double GBytespersec = bytespersec / (8 * 1000 * 1000 * 1000.0);

            return(GBytespersec);
        }