コード例 #1
0
ファイル: CudaFFT.cs プロジェクト: uzbekdev1/CUDAfy.NET-1
        private void DoExecute(FFTPlan plan, object input, object output, bool inverse = false)
        {
            FFTPlanEx     planEx = Plans[plan];
            CUDevicePtrEx inPtrEx;
            CUDevicePtrEx outPtrEx;

            inPtrEx  = _gpu.GetDeviceMemory(input) as CUDevicePtrEx;
            outPtrEx = _gpu.GetDeviceMemory(output) as CUDevicePtrEx;

            CUFFTDirection dir = inverse ? CUFFTDirection.Inverse : CUFFTDirection.Forward;
            CUFFTResult    res = CUFFTResult.ExecFailed;

            if (planEx.CudaFFTType == CUFFTType.C2C)
            {
                res = _driver.cufftExecC2C(planEx.CudaFFTHandle, inPtrEx.DevPtr, outPtrEx.DevPtr, dir);
            }
            else if (planEx.CudaFFTType == CUFFTType.C2R)
            {
                res = _driver.cufftExecC2R(planEx.CudaFFTHandle, inPtrEx.DevPtr, outPtrEx.DevPtr);
            }
            else if (planEx.CudaFFTType == CUFFTType.D2Z)
            {
                res = _driver.cufftExecD2Z(planEx.CudaFFTHandle, inPtrEx.DevPtr, outPtrEx.DevPtr);
            }
            else if (planEx.CudaFFTType == CUFFTType.R2C)
            {
                res = _driver.cufftExecR2C(planEx.CudaFFTHandle, inPtrEx.DevPtr, outPtrEx.DevPtr);
            }
            else if (planEx.CudaFFTType == CUFFTType.Z2D)
            {
                res = _driver.cufftExecZ2D(planEx.CudaFFTHandle, inPtrEx.DevPtr, outPtrEx.DevPtr);
            }
            else if (planEx.CudaFFTType == CUFFTType.Z2Z)
            {
                res = _driver.cufftExecZ2Z(planEx.CudaFFTHandle, inPtrEx.DevPtr, outPtrEx.DevPtr, dir);
            }
            if (res != CUFFTResult.Success)
            {
                throw new CudafyMathException(res.ToString());
            }
        }
コード例 #2
0
ファイル: CUFFT.cs プロジェクト: JustasB/cudafy
 public void ExecuteComplexToComplex(cufftHandle plan, CUdeviceptr input, CUdeviceptr output, CUFFTDirection direction)
 {
     this.LastError = _driver.cufftExecC2C(plan, input, output, direction);
 }
コード例 #3
0
ファイル: CUFFT.cs プロジェクト: JustasB/cudafy
        //public void Execute1D(cuFloatComplex[] input, cuFloatComplex[] output, int nx, int batch)
        //{
        //    this.Execute1D(input, output, nx, batch, CUFFTDirection.Forward);
        //}

        //public void Execute1D(cuFloatComplex[] input, cuFloatReal[] output, int nx, int batch)
        //{
        //    cufftHandle plan = new cufftHandle();
        //    this.LastError = CUFFTDriver.cufftPlan1d(ref plan, nx, CUFFTType.C2R, batch);
        //    CUdeviceptr idata = this.cuda.CopyHostToDevice<cuFloatComplex>(input);
        //    CUdeviceptr odata = this.cuda.Allocate<cuFloatReal>(output);
        //    CUFFTDriver.cufftExecC2R(plan, idata, odata);
        //    this.cuda.CopyDeviceToHost<cuFloatReal>(odata, output);
        //    CUFFTDriver.cufftDestroy(plan);
        //    this.cuda.Free(idata);
        //    this.cuda.Free(odata);
        //}

        //public void Execute1D(cuFloatReal[] input, cuFloatComplex[] output, int nx, int batch)
        //{
        //    cufftHandle plan = new cufftHandle();
        //    this.LastError = CUFFTDriver.cufftPlan1d(ref plan, nx, CUFFTType.R2C, batch);
        //    CUdeviceptr idata = this.cuda.CopyHostToDevice<cuFloatReal>(input);
        //    CUdeviceptr odata = this.cuda.Allocate<cuFloatComplex>(output);
        //    CUFFTDriver.cufftExecR2C(plan, idata, odata);
        //    this.cuda.CopyDeviceToHost<cuFloatComplex>(odata, output);
        //    CUFFTDriver.cufftDestroy(plan);
        //    this.cuda.Free(idata);
        //    this.cuda.Free(odata);
        //}

        //public void Execute1D(cuFloatComplex[] input, cuFloatComplex[] output, int nx, int batch, CUFFTDirection direction)
        //{
        //    cufftHandle plan = new cufftHandle();
        //    this.LastError = CUFFTDriver.cufftPlan1d(ref plan, nx, CUFFTType.C2C, batch);
        //    CUdeviceptr idata = this.cuda.CopyHostToDevice<cuFloatComplex>(input);
        //    CUdeviceptr odata = this.cuda.Allocate<cuFloatComplex>(output);
        //    CUFFTDriver.cufftExecC2C(plan, idata, odata, direction);
        //    this.cuda.CopyDeviceToHost<cuFloatComplex>(odata, output);
        //    CUFFTDriver.cufftDestroy(plan);
        //    this.cuda.Free(idata);
        //    this.cuda.Free(odata);
        //}

        //public void Execute2D(cuFloatComplex[] input, cuFloatComplex[] output, int nx, int ny)
        //{
        //    this.Execute2D(input, output, nx, ny, CUFFTDirection.Forward);
        //}

        //public void Execute2D(cuFloatComplex[] input, cuFloatReal[] output, int nx, int ny)
        //{
        //    cufftHandle plan = new cufftHandle();
        //    this.LastError = CUFFTDriver.cufftPlan2d(ref plan, nx, ny, CUFFTType.C2R);
        //    CUdeviceptr idata = this.cuda.CopyHostToDevice<cuFloatComplex>(input);
        //    CUdeviceptr odata = this.cuda.Allocate<cuFloatReal>(output);
        //    CUFFTDriver.cufftExecC2R(plan, idata, odata);
        //    this.cuda.CopyDeviceToHost<cuFloatReal>(odata, output);
        //    CUFFTDriver.cufftDestroy(plan);
        //    this.cuda.Free(idata);
        //    this.cuda.Free(odata);
        //}

        //public void Execute2D(cuFloatReal[] input, cuFloatComplex[] output, int nx, int ny)
        //{
        //    cufftHandle plan = new cufftHandle();
        //    this.LastError = CUFFTDriver.cufftPlan2d(ref plan, nx, ny, CUFFTType.R2C);
        //    CUdeviceptr idata = this.cuda.CopyHostToDevice<cuFloatReal>(input);
        //    CUdeviceptr odata = this.cuda.Allocate<cuFloatComplex>(output);
        //    CUFFTDriver.cufftExecR2C(plan, idata, odata);
        //    this.cuda.CopyDeviceToHost<cuFloatComplex>(odata, output);
        //    CUFFTDriver.cufftDestroy(plan);
        //    this.cuda.Free(idata);
        //    this.cuda.Free(odata);
        //}

        //public void Execute2D(cuFloatComplex[] input, cuFloatComplex[] output, int nx, int ny, CUFFTDirection direction)
        //{
        //    cufftHandle plan = new cufftHandle();
        //    this.LastError = CUFFTDriver.cufftPlan2d(ref plan, nx, ny, CUFFTType.C2C);
        //    CUdeviceptr idata = this.cuda.CopyHostToDevice<cuFloatComplex>(input);
        //    CUdeviceptr odata = this.cuda.Allocate<cuFloatComplex>(output);
        //    CUFFTDriver.cufftExecC2C(plan, idata, odata, direction);
        //    this.cuda.CopyDeviceToHost<cuFloatComplex>(odata, output);
        //    CUFFTDriver.cufftDestroy(plan);
        //    this.cuda.Free(idata);
        //    this.cuda.Free(odata);
        //}

        //public void Execute3D(cuFloatComplex[] input, cuFloatComplex[] output, int nx, int ny, int nz)
        //{
        //    this.Execute3D(input, output, nx, ny, nz, CUFFTDirection.Forward);
        //}

        //public void Execute3D(cuFloatComplex[] input, cuFloatReal[] output, int nx, int ny, int nz)
        //{
        //    cufftHandle plan = new cufftHandle();
        //    this.LastError = CUFFTDriver.cufftPlan3d(ref plan, nx, ny, nz, CUFFTType.C2R);
        //    CUdeviceptr idata = this.cuda.CopyHostToDevice<cuFloatComplex>(input);
        //    CUdeviceptr odata = this.cuda.Allocate<cuFloatReal>(output);
        //    CUFFTDriver.cufftExecC2R(plan, idata, odata);
        //    this.cuda.CopyDeviceToHost<cuFloatReal>(odata, output);
        //    CUFFTDriver.cufftDestroy(plan);
        //    this.cuda.Free(idata);
        //    this.cuda.Free(odata);
        //}

        //public void Execute3D(cuFloatReal[] input, cuFloatComplex[] output, int nx, int ny, int nz)
        //{
        //    cufftHandle plan = new cufftHandle();
        //    this.LastError = CUFFTDriver.cufftPlan3d(ref plan, nx, ny, nz, CUFFTType.R2C);
        //    CUdeviceptr idata = this.cuda.CopyHostToDevice<cuFloatReal>(input);
        //    CUdeviceptr odata = this.cuda.Allocate<cuFloatComplex>(output);
        //    CUFFTDriver.cufftExecR2C(plan, idata, odata);
        //    this.cuda.CopyDeviceToHost<cuFloatComplex>(odata, output);
        //    CUFFTDriver.cufftDestroy(plan);
        //    this.cuda.Free(idata);
        //    this.cuda.Free(odata);
        //}

        //public void Execute3D(cuFloatComplex[] input, cuFloatComplex[] output, int nx, int ny, int nz, CUFFTDirection direction)
        //{
        //    cufftHandle plan = new cufftHandle();
        //    this.LastError = CUFFTDriver.cufftPlan3d(ref plan, nx, ny, nz, CUFFTType.C2C);
        //    CUdeviceptr idata = this.cuda.CopyHostToDevice<cuFloatComplex>(input);
        //    CUdeviceptr odata = this.cuda.Allocate<cuFloatComplex>(output);
        //    CUFFTDriver.cufftExecC2C(plan, idata, odata, direction);
        //    this.cuda.CopyDeviceToHost<cuFloatComplex>(odata, output);
        //    CUFFTDriver.cufftDestroy(plan);
        //    this.cuda.Free(idata);
        //    this.cuda.Free(odata);
        //}

        public void ExecuteComplexToComplex(CUdeviceptr input, CUdeviceptr output, CUFFTDirection direction)
        {
            this.ExecuteComplexToComplex(this.plan, input, output, direction);
        }
コード例 #4
0
 public CUFFTResult cufftExecZ2Z(cufftHandle plan, CUdeviceptr idata, CUdeviceptr odata, CUFFTDirection direction)
 {
     return(cufftExecZ2Z_ext(plan, idata, odata, direction));
 }
コード例 #5
0
 private static extern CUFFTResult cufftExecZ2Z_ext(cufftHandle plan, CUdeviceptr idata, CUdeviceptr odata, CUFFTDirection direction);
コード例 #6
0
 public static extern CUFFTResult cufftExecZ2Z(cufftHandle plan, CUdeviceptr idata, CUdeviceptr odata, CUFFTDirection direction);
コード例 #7
0
ファイル: CUFFTDriver.cs プロジェクト: JustasB/cudafy
 public CUFFTResult cufftExecZ2Z(cufftHandle plan, CUdeviceptr idata, CUdeviceptr odata, CUFFTDirection direction)
 {
     return cufftExecZ2Z_ext(plan, idata, odata, direction);
 }
コード例 #8
0
ファイル: CUFFTDriver.cs プロジェクト: JustasB/cudafy
 private static extern CUFFTResult cufftExecZ2Z_ext(cufftHandle plan, CUdeviceptr idata, CUdeviceptr odata, CUFFTDirection direction);
コード例 #9
0
ファイル: CUFFT.cs プロジェクト: uzbekdev1/CUDAfy.NET-1
 public void ExecuteComplexToComplex(cufftHandle plan, CUdeviceptr input, CUdeviceptr output, CUFFTDirection direction)
 {
     this.LastError = _driver.cufftExecC2C(plan, input, output, direction);
 }
コード例 #10
0
ファイル: CUFFT.cs プロジェクト: uzbekdev1/CUDAfy.NET-1
        //public void Execute1D(cuFloatComplex[] input, cuFloatComplex[] output, int nx, int batch)
        //{
        //    this.Execute1D(input, output, nx, batch, CUFFTDirection.Forward);
        //}

        //public void Execute1D(cuFloatComplex[] input, cuFloatReal[] output, int nx, int batch)
        //{
        //    cufftHandle plan = new cufftHandle();
        //    this.LastError = CUFFTDriver.cufftPlan1d(ref plan, nx, CUFFTType.C2R, batch);
        //    CUdeviceptr idata = this.cuda.CopyHostToDevice<cuFloatComplex>(input);
        //    CUdeviceptr odata = this.cuda.Allocate<cuFloatReal>(output);
        //    CUFFTDriver.cufftExecC2R(plan, idata, odata);
        //    this.cuda.CopyDeviceToHost<cuFloatReal>(odata, output);
        //    CUFFTDriver.cufftDestroy(plan);
        //    this.cuda.Free(idata);
        //    this.cuda.Free(odata);
        //}

        //public void Execute1D(cuFloatReal[] input, cuFloatComplex[] output, int nx, int batch)
        //{
        //    cufftHandle plan = new cufftHandle();
        //    this.LastError = CUFFTDriver.cufftPlan1d(ref plan, nx, CUFFTType.R2C, batch);
        //    CUdeviceptr idata = this.cuda.CopyHostToDevice<cuFloatReal>(input);
        //    CUdeviceptr odata = this.cuda.Allocate<cuFloatComplex>(output);
        //    CUFFTDriver.cufftExecR2C(plan, idata, odata);
        //    this.cuda.CopyDeviceToHost<cuFloatComplex>(odata, output);
        //    CUFFTDriver.cufftDestroy(plan);
        //    this.cuda.Free(idata);
        //    this.cuda.Free(odata);
        //}

        //public void Execute1D(cuFloatComplex[] input, cuFloatComplex[] output, int nx, int batch, CUFFTDirection direction)
        //{
        //    cufftHandle plan = new cufftHandle();
        //    this.LastError = CUFFTDriver.cufftPlan1d(ref plan, nx, CUFFTType.C2C, batch);
        //    CUdeviceptr idata = this.cuda.CopyHostToDevice<cuFloatComplex>(input);
        //    CUdeviceptr odata = this.cuda.Allocate<cuFloatComplex>(output);
        //    CUFFTDriver.cufftExecC2C(plan, idata, odata, direction);
        //    this.cuda.CopyDeviceToHost<cuFloatComplex>(odata, output);
        //    CUFFTDriver.cufftDestroy(plan);
        //    this.cuda.Free(idata);
        //    this.cuda.Free(odata);
        //}

        //public void Execute2D(cuFloatComplex[] input, cuFloatComplex[] output, int nx, int ny)
        //{
        //    this.Execute2D(input, output, nx, ny, CUFFTDirection.Forward);
        //}

        //public void Execute2D(cuFloatComplex[] input, cuFloatReal[] output, int nx, int ny)
        //{
        //    cufftHandle plan = new cufftHandle();
        //    this.LastError = CUFFTDriver.cufftPlan2d(ref plan, nx, ny, CUFFTType.C2R);
        //    CUdeviceptr idata = this.cuda.CopyHostToDevice<cuFloatComplex>(input);
        //    CUdeviceptr odata = this.cuda.Allocate<cuFloatReal>(output);
        //    CUFFTDriver.cufftExecC2R(plan, idata, odata);
        //    this.cuda.CopyDeviceToHost<cuFloatReal>(odata, output);
        //    CUFFTDriver.cufftDestroy(plan);
        //    this.cuda.Free(idata);
        //    this.cuda.Free(odata);
        //}

        //public void Execute2D(cuFloatReal[] input, cuFloatComplex[] output, int nx, int ny)
        //{
        //    cufftHandle plan = new cufftHandle();
        //    this.LastError = CUFFTDriver.cufftPlan2d(ref plan, nx, ny, CUFFTType.R2C);
        //    CUdeviceptr idata = this.cuda.CopyHostToDevice<cuFloatReal>(input);
        //    CUdeviceptr odata = this.cuda.Allocate<cuFloatComplex>(output);
        //    CUFFTDriver.cufftExecR2C(plan, idata, odata);
        //    this.cuda.CopyDeviceToHost<cuFloatComplex>(odata, output);
        //    CUFFTDriver.cufftDestroy(plan);
        //    this.cuda.Free(idata);
        //    this.cuda.Free(odata);
        //}

        //public void Execute2D(cuFloatComplex[] input, cuFloatComplex[] output, int nx, int ny, CUFFTDirection direction)
        //{
        //    cufftHandle plan = new cufftHandle();
        //    this.LastError = CUFFTDriver.cufftPlan2d(ref plan, nx, ny, CUFFTType.C2C);
        //    CUdeviceptr idata = this.cuda.CopyHostToDevice<cuFloatComplex>(input);
        //    CUdeviceptr odata = this.cuda.Allocate<cuFloatComplex>(output);
        //    CUFFTDriver.cufftExecC2C(plan, idata, odata, direction);
        //    this.cuda.CopyDeviceToHost<cuFloatComplex>(odata, output);
        //    CUFFTDriver.cufftDestroy(plan);
        //    this.cuda.Free(idata);
        //    this.cuda.Free(odata);
        //}

        //public void Execute3D(cuFloatComplex[] input, cuFloatComplex[] output, int nx, int ny, int nz)
        //{
        //    this.Execute3D(input, output, nx, ny, nz, CUFFTDirection.Forward);
        //}

        //public void Execute3D(cuFloatComplex[] input, cuFloatReal[] output, int nx, int ny, int nz)
        //{
        //    cufftHandle plan = new cufftHandle();
        //    this.LastError = CUFFTDriver.cufftPlan3d(ref plan, nx, ny, nz, CUFFTType.C2R);
        //    CUdeviceptr idata = this.cuda.CopyHostToDevice<cuFloatComplex>(input);
        //    CUdeviceptr odata = this.cuda.Allocate<cuFloatReal>(output);
        //    CUFFTDriver.cufftExecC2R(plan, idata, odata);
        //    this.cuda.CopyDeviceToHost<cuFloatReal>(odata, output);
        //    CUFFTDriver.cufftDestroy(plan);
        //    this.cuda.Free(idata);
        //    this.cuda.Free(odata);
        //}

        //public void Execute3D(cuFloatReal[] input, cuFloatComplex[] output, int nx, int ny, int nz)
        //{
        //    cufftHandle plan = new cufftHandle();
        //    this.LastError = CUFFTDriver.cufftPlan3d(ref plan, nx, ny, nz, CUFFTType.R2C);
        //    CUdeviceptr idata = this.cuda.CopyHostToDevice<cuFloatReal>(input);
        //    CUdeviceptr odata = this.cuda.Allocate<cuFloatComplex>(output);
        //    CUFFTDriver.cufftExecR2C(plan, idata, odata);
        //    this.cuda.CopyDeviceToHost<cuFloatComplex>(odata, output);
        //    CUFFTDriver.cufftDestroy(plan);
        //    this.cuda.Free(idata);
        //    this.cuda.Free(odata);
        //}

        //public void Execute3D(cuFloatComplex[] input, cuFloatComplex[] output, int nx, int ny, int nz, CUFFTDirection direction)
        //{
        //    cufftHandle plan = new cufftHandle();
        //    this.LastError = CUFFTDriver.cufftPlan3d(ref plan, nx, ny, nz, CUFFTType.C2C);
        //    CUdeviceptr idata = this.cuda.CopyHostToDevice<cuFloatComplex>(input);
        //    CUdeviceptr odata = this.cuda.Allocate<cuFloatComplex>(output);
        //    CUFFTDriver.cufftExecC2C(plan, idata, odata, direction);
        //    this.cuda.CopyDeviceToHost<cuFloatComplex>(odata, output);
        //    CUFFTDriver.cufftDestroy(plan);
        //    this.cuda.Free(idata);
        //    this.cuda.Free(odata);
        //}

        public void ExecuteComplexToComplex(CUdeviceptr input, CUdeviceptr output, CUFFTDirection direction)
        {
            this.ExecuteComplexToComplex(this.plan, input, output, direction);
        }
コード例 #11
0
 public static extern CUFFTResult cufftExecZ2Z(cufftHandle plan, CUdeviceptr idata, CUdeviceptr odata, CUFFTDirection direction);