public static double[] Mark4(int[,] A, int[,] B, int[,] C, int Size, int Size1d, int n, int count) { double dummy = 0.0; double st = 0.0, sst = 0.0; CudafyModule km = CudafyTranslator.Cudafy(); GPGPU gpu = CudafyHost.GetDevice(CudafyModes.Target, CudafyModes.DeviceId); gpu.LoadModule(km); GPGPUProperties GPU_prop = gpu.GetDeviceProperties(); int maxTheadBlockSize = (int)Math.Sqrt(GPU_prop.MaxThreadsPerBlock); for (int j = 0; j < n; j++) { Timer t = new Timer(); for (int i = 0; i < count; i++) dummy += MA(A, B, C, gpu, maxTheadBlockSize, Size); double time = t.Check() / count; st += time; sst += time * time; } double mean = st / n, sdev = Math.Sqrt((sst - mean * mean * n) / (n - 1)); return new double[2] { mean, sdev }; }
public static double[] Mark3(int[,] A, int[,] B, int[,] C, int Size, int Size1d, int n, int count) { double[] result = new double[n]; double dummy = 0.0; CudafyModule km = CudafyTranslator.Cudafy(); GPGPU gpu = CudafyHost.GetDevice(CudafyModes.Target, CudafyModes.DeviceId); gpu.LoadModule(km); GPGPUProperties GPU_prop = gpu.GetDeviceProperties(); int maxTheadBlockSize = (int)Math.Sqrt(GPU_prop.MaxThreadsPerBlock); for (int j = 0; j < n; j++) { Timer t = new Timer(); for (int i = 0; i < count; i++) { dummy += MA(A, B, C, gpu, maxTheadBlockSize,Size); } double time = t.Check() / count; result[j] = time; Console.WriteLine("time: " + time + " ms"); } return result; }