Exemplo n.º 1
0
 public void SetUp()
 {
     _gpu = CudafyHost.CreateDevice(CudafyModes.Target);
     Console.WriteLine(_gpu.GetDriverVersion());
     _fft            = GPGPUFFT.Create(_gpu);
     _hostInput      = new float[N * BATCH];
     _hostInputCplx  = new ComplexF[N * BATCH];
     _hostOutput     = new float[N * BATCH];
     _hostOutputCplx = new ComplexF[N * BATCH];
     _devInput       = _gpu.Allocate(_hostInput);
     _devInputCplx   = _gpu.Allocate(_hostInputCplx);
     _devInter       = _gpu.Allocate <float>(N * 2 * BATCH);
     _devInterCplx   = _gpu.Allocate <ComplexF>(N * BATCH);
     _devOutput      = _gpu.Allocate(_hostOutput);
     _devOutputCplx  = _gpu.Allocate(_hostOutputCplx);
     Console.WriteLine(_fft.GetVersion());
     for (int b = 0; b < BATCH; b++)
     {
         for (int i = 0; i < N; i++)
         {
             ComplexF cf = new ComplexF();
             cf.x = (float)((10.0F * Math.Sin(100 * 2 * Math.PI * i / N * Math.PI / 180)));
             cf.y = (float)((10.0F * Math.Sin(200 * 2 * Math.PI * i / N * Math.PI / 180)));
             _hostInput[i + b * N]     = cf.x;
             _hostInputCplx[i + b * N] = cf;
         }
     }
 }
Exemplo n.º 2
0
        public void Test_TwoThreadTwoGPU()
        {
            _gpu0 = CudafyHost.CreateDevice(CudafyModes.Target, 0);
            _gpu1 = CudafyHost.CreateDevice(CudafyModes.Target, 1);
            _gpu0.EnableMultithreading();
            _gpu1.EnableMultithreading();
            bool j1 = false;
            bool j2 = false;

            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine(i);
                Thread t1 = new Thread(Test_TwoThreadTwoGPU_Thread0);
                Thread t2 = new Thread(Test_TwoThreadTwoGPU_Thread1);
                t1.Start();
                t2.Start();
                j1 = t1.Join(10000);
                j2 = t2.Join(10000);
                if (!j1 || !j2)
                {
                    break;
                }
            }
            _gpu0.DisableMultithreading();
            _gpu0.FreeAll();
            _gpu1.DisableMultithreading();
            _gpu1.FreeAll();
            Assert.IsTrue(j1);
            Assert.IsTrue(j2);
        }
Exemplo n.º 3
0
        public void SetUp()
        {
            _gpu = CudafyHost.CreateDevice(CudafyModes.Target);

            _hostInput      = new double[N * BATCH];
            _hostInputCplx  = new ComplexD[N * BATCH];
            _hostOutput     = new double[N * BATCH];
            _hostOutputCplx = new ComplexD[N * BATCH];
            _devInput       = _gpu.Allocate(_hostInput);
            _devInputCplx   = _gpu.Allocate(_hostInputCplx);
            _devInter       = _gpu.Allocate <double>(N * 2 * BATCH);
            _devInterCplx   = _gpu.Allocate <ComplexD>(N * BATCH);
            _devOutput      = _gpu.Allocate(_hostOutput);
            _devOutputCplx  = _gpu.Allocate(_hostOutputCplx);
            _fft            = GPGPUFFT.Create(_gpu);
            for (int b = 0; b < BATCH; b++)
            {
                for (int i = 0; i < N; i++)
                {
                    ComplexD cf = new ComplexD();
                    cf.x = (double)((10.0F * Math.Sin(100 * 2 * Math.PI * i / N * Math.PI / 180)));
                    cf.y = (double)((10.0F * Math.Sin(200 * 2 * Math.PI * i / N * Math.PI / 180)));
                    _hostInput[i + b * N]     = cf.x;
                    _hostInputCplx[i + b * N] = cf;
                }
            }
        }
Exemplo n.º 4
0
 public void SetUp()
 {
     _gpu            = CudafyHost.CreateDevice(CudafyModes.Target, CudafyModes.DeviceId);
     _uintBufferIn1  = new uint[N];
     _uintBufferOut1 = new uint[N];
     _uintBufferIn2  = new uint[N];
     _uintBufferOut2 = new uint[N];
 }
Exemplo n.º 5
0
 public void SetUp()
 {
     _gpu0           = CudafyHost.CreateDevice(CudafyModes.Target, 0);
     _gpu1           = CudafyHost.CreateDevice(CudafyModes.Target, 1);
     _uintBufferIn0  = new uint[N];
     _uintBufferOut0 = new uint[N];
     _uintBufferIn1  = new uint[N];
     _uintBufferOut1 = new uint[N];
 }
Exemplo n.º 6
0
 public void SetUp()
 {
     _gpu        = CudafyHost.CreateDevice(CudafyModes.Target);
     _blas       = GPGPUBLAS.Create(_gpu);
     _hostInput  = new float[ciROWS, ciCOLS];
     _hostInput2 = new float[ciROWS, ciCOLS];
     _hostOutput = new float[ciROWS, ciCOLS];
     _devPtr     = _gpu.Allocate <float>(_hostInput);
     _devPtr2    = _gpu.Allocate <float>(_hostOutput);
 }
Exemplo n.º 7
0
 public void SetUp()
 {
     _gpu  = CudafyHost.CreateDevice(CudafyModes.Target);
     _blas = GPGPUBLAS.Create(_gpu);
     Console.Write("BLAS Version={0}", _blas.GetVersion());
     _hostInput1  = new float[ciN];
     _hostInput2  = new float[ciN];
     _hostOutput1 = new float[ciN];
     _hostOutput2 = new float[ciN];
     _devPtr1     = _gpu.Allocate <float>(_hostInput1);
     _devPtr2     = _gpu.Allocate <float>(_hostOutput1);
 }
Exemplo n.º 8
0
        public void SetUp()
        {
            _gpu    = CudafyHost.CreateDevice(CudafyModes.Target);
            _sparse = GPGPUSPARSE.Create(_gpu);

            _hiMatrixMN   = new double[M * N];
            _hiMatrixMN2  = new double[M * N];
            _hoMatrixMN   = new double[M * N];
            _hoPerVector  = new int[M];
            _hoPerVector2 = new int[N];

            _diPerVector2 = _gpu.Allocate(_hoPerVector2);
            _diMatrixMN   = _gpu.Allocate(_hiMatrixMN);
            _diMatrixMN2  = _gpu.Allocate(_hiMatrixMN2);
            _diPerVector  = _gpu.Allocate(_hoPerVector);
        }
Exemplo n.º 9
0
 public void SetUp()
 {
     _gpu0 = CudafyHost.CreateDevice(CudafyModes.Target, 0);
     try
     {
         _gpu1 = CudafyHost.CreateDevice(CudafyModes.Target, 1);
     }
     catch (Exception)
     {
         Assert.Ignore("MultiGPUTests expects, at least, 2 device.");
     }
     _uintBufferIn0  = new uint[N];
     _uintBufferOut0 = new uint[N];
     _uintBufferIn1  = new uint[N];
     _uintBufferOut1 = new uint[N];
 }