/// <summary> /// Creates a 3D plan. /// </summary> /// <param name="fftType">Type of FFT.</param> /// <param name="dataType">Data type.</param> /// <param name="nx">The number of samples in x dimension.</param> /// <param name="ny">The number of samples in y dimension.</param> /// <param name="nz">The number of samples in z dimension.</param> /// <param name="batchSize">Size of batch.</param> /// <returns>Plan.</returns> public override FFTPlan3D Plan3D(eFFTType fftType, eDataType dataType, int nx, int ny, int nz, int batchSize) { int insize, outsize; CUFFTType cuFFTType = VerifyTypes(fftType, dataType, out insize, out outsize); cufftHandle handle = new cufftHandle(); CUFFTResult res; if (batchSize <= 1) { res = _driver.cufftPlan3d(ref handle, nx, ny, nz, cuFFTType); } else { res = _driver.cufftPlanMany(ref handle, 3, new int[] { nx, ny, nz }, null, 1, 0, null, 1, 0, cuFFTType, batchSize); } if (res != CUFFTResult.Success) { throw new CudafyHostException(res.ToString()); } FFTPlan3D plan = new FFTPlan3D(nx, ny, nz, batchSize, this); FFTPlan3DEx planEx = new FFTPlan3DEx(plan) { CudaFFTHandle = handle, CudaFFTType = cuFFTType, DataType = dataType }; Plans.Add(plan, planEx); return(plan); }
/// <summary> /// Creates a 3D plan. /// </summary> /// <param name="fftType">Type of FFT.</param> /// <param name="dataType">The data type.</param> /// <param name="nx">The x length in samples.</param> /// <param name="ny">The y length in samples.</param> /// <param name="nz">The z length in samples.</param> /// <param name="batch">The number of FFTs in batch.</param> /// <returns> /// Plan. /// </returns> public override FFTPlan3D Plan3D(eFFTType fftType, eDataType dataType, int nx, int ny, int nz, int batch = 1) { int insize, outsize; int totalSize = nx * ny * nz; CUFFTType cuFFTType = VerifyTypes(fftType, dataType, out insize, out outsize); //Console.WriteLine(size); IntPtr pin = fftwf.malloc(totalSize * insize * batch); IntPtr pout = fftwf.malloc(totalSize * outsize * batch); Ifftw_plan fwdPlan; Ifftw_plan invPlan; if (dataType == eDataType.Single) { if (batch == 1) { fwdPlan = fftwf_plan.dft_3d(fftType, nx, ny, nz, pin, pout, fftw_direction.Forward, fftw_flags.Estimate); invPlan = fftwf_plan.dft_3d(fftType, nx, ny, nz, pin, pout, fftw_direction.Backward, fftw_flags.Estimate); } else { fwdPlan = fftwf_plan.dft_many(fftType, 3, new int[] { nx, ny, nz }, batch, pin, null, 1, nx * ny * nz, pout, null, 1, nx * ny * nz, fftw_direction.Forward, fftw_flags.Estimate); invPlan = fftwf_plan.dft_many(fftType, 3, new int[] { nx, ny, nz }, batch, pin, null, 1, nx * ny * nz, pout, null, 1, nx * ny * nz, fftw_direction.Backward, fftw_flags.Estimate); } } else { if (batch == 1) { fwdPlan = fftw_plan.dft_3d(fftType, nx, ny, nz, pin, pout, fftw_direction.Forward, fftw_flags.Estimate); invPlan = fftw_plan.dft_3d(fftType, nx, ny, nz, pin, pout, fftw_direction.Backward, fftw_flags.Estimate); } else { fwdPlan = fftw_plan.dft_many(fftType, 3, new int[] { nx, ny, nz }, batch, pin, null, 1, nx * ny * nz, pout, null, 1, nx * ny * nz, fftw_direction.Forward, fftw_flags.Estimate); invPlan = fftw_plan.dft_many(fftType, 3, new int[] { nx, ny, nz }, batch, pin, null, 1, nx * ny * nz, pout, null, 1, nx * ny * nz, fftw_direction.Backward, fftw_flags.Estimate); } } FFTPlan3D plan = new FFTPlan3D(nx, ny, nz, batch, this); FFTPlan3DEx planEx = new FFTPlan3DEx(plan) { FFTWFwdPlan = fwdPlan, FFTWInvPlan = invPlan, N = totalSize, DataType = dataType }; Plans.Add(plan, planEx); return(plan); }
/// <summary> /// Creates a 1D plan. /// </summary> /// <param name="fftType">Type of FFT.</param> /// <param name="dataType">The data type.</param> /// <param name="nx">The length in samples.</param> /// <param name="batch">The number of FFTs in batch.</param> /// <param name="istride">The istride.</param> /// <param name="idist">The idist.</param> /// <param name="ostride">The ostride.</param> /// <param name="odist">The odist.</param> /// <returns>Plan.</returns> public override FFTPlan1D Plan1D(eFFTType fftType, eDataType dataType, int nx, int batch, int istride, int idist, int ostride, int odist) { int insize, outsize; CUFFTType cuFFTType = VerifyTypes(fftType, dataType, out insize, out outsize); //Console.WriteLine(size); IntPtr pin = fftwf.malloc(nx * insize * batch); IntPtr pout = fftwf.malloc(nx * outsize * batch); Ifftw_plan fwdPlan; Ifftw_plan invPlan; if (dataType == eDataType.Single) { fwdPlan = fftwf_plan.dft_many(fftType, 1, new int[] { nx }, batch, pin, null, istride, idist, pout, null, ostride, odist, fftw_direction.Forward, fftw_flags.Estimate); invPlan = fftwf_plan.dft_many(fftType, 1, new int[] { nx }, batch, pin, null, istride, idist, pout, null, ostride, odist, fftw_direction.Backward, fftw_flags.Estimate); } else { fwdPlan = fftw_plan.dft_many(fftType, 1, new int[] { nx }, batch, pin, null, istride, idist, pout, null, ostride, odist, fftw_direction.Forward, fftw_flags.Estimate); invPlan = fftw_plan.dft_many(fftType, 1, new int[] { nx }, batch, pin, null, istride, idist, pout, null, ostride, odist, fftw_direction.Backward, fftw_flags.Estimate); } FFTPlan1D plan = new FFTPlan1D(nx, batch, this); FFTPlan1DEx planEx = new FFTPlan1DEx(plan) { FFTWFwdPlan = fwdPlan, FFTWInvPlan = invPlan, N = nx, DataType = dataType }; Plans.Add(plan, planEx); return(plan); }
public override FFTPlan1D Plan1D(eFFTType fftType, eDataType dataType, int nx, int batchSize, int istride, int idist, int ostride, int odist) { int insize, outsize; CUFFTType cuFFTType = VerifyTypes(fftType, dataType, out insize, out outsize); cufftHandle handle = new cufftHandle(); CUFFTResult res; if (batchSize <= 1) { res = _driver.cufftPlan1d(ref handle, nx, cuFFTType, batchSize); } else { res = _driver.cufftPlanMany(ref handle, 1, new int[] { nx }, new int[] { idist }, //inembed istride, //istride idist, //idist new int[] { odist }, //onembed ostride, //ostride odist, //odist cuFFTType, batchSize); } if (res != CUFFTResult.Success) { throw new CudafyHostException(res.ToString()); } FFTPlan1D plan = new FFTPlan1D(nx, batchSize, this); FFTPlan1DEx planEx = new FFTPlan1DEx(plan) { CudaFFTHandle = handle, CudaFFTType = cuFFTType, DataType = dataType }; Plans.Add(plan, planEx); return(plan); }
public static extern CUFFTResult cufftPlan3d(ref cufftHandle plan, int nx, int ny, int nz, CUFFTType type);
public cufftHandle Plan1D(int nx, CUFFTType type, int batch) { this.plan = new cufftHandle(); this.LastError = _driver.cufftPlan1d(ref this.plan, nx, type, batch); return this.plan; }
private static extern CUFFTResult cufftPlanMany_ext(ref cufftHandle plan, int rank, [In, Out] int[] n, [In, Out] int[] inembed, int istride, int idist, [In, Out] int[] onembed, int ostride, int odist, CUFFTType type, int batch);
private static extern CUFFTResult cufftPlan3d_ext(ref cufftHandle plan, int nx, int ny, int nz, CUFFTType type);
public CUFFTResult cufftPlanMany(ref cufftHandle plan, int rank, int[] n, int[] inembed, int istride, int idist, int[] onembed, int ostride, int odist, CUFFTType type, int batch) { return(cufftPlanMany_ext(ref plan, rank, n, inembed, istride, idist, onembed, ostride, odist, type, batch)); }
public CUFFTResult cufftPlan3d(ref cufftHandle plan, int nx, int ny, int nz, CUFFTType type) { return cufftPlan3d_ext(ref plan, nx, ny, nz, type); }
public CUFFTResult cufftPlan1d(ref cufftHandle plan, int nx, CUFFTType type, int batch) { return cufftPlan1d_ext(ref plan, nx, type, batch); }
private static extern CUFFTResult cufftPlanMany_ext(ref cufftHandle plan, int rank, IntPtr n, IntPtr inembed, int istride, int idist, IntPtr onembed, int ostride, int odist, CUFFTType type, int batch);
private static extern CUFFTResult cufftPlan3d_ext(ref cufftHandle plan, int nx, int ny, int nz, CUFFTType type);
private static extern CUFFTResult cufftPlan1d_ext(ref cufftHandle plan, int nx, CUFFTType type, int batch);
public cufftHandle Plan3D(int nx, int ny, int nz, CUFFTType type) { this.plan = new cufftHandle(); this.LastError = _driver.cufftPlan3d(ref this.plan, nx, ny, nz, type); return(this.plan); }
public cufftHandle Plan1D(int nx, CUFFTType type, int batch) { this.plan = new cufftHandle(); this.LastError = _driver.cufftPlan1d(ref this.plan, nx, type, batch); return(this.plan); }
public CUFFTResult cufftPlan3d(ref cufftHandle plan, int nx, int ny, int nz, CUFFTType type) { return(cufftPlan3d_ext(ref plan, nx, ny, nz, type)); }
public CUFFTResult cufftPlanMany(ref cufftHandle plan, int rank, IntPtr n, IntPtr inembed, int istride, int idist, IntPtr onembed, int ostride, int odist, CUFFTType type, int batch) { return cufftPlanMany_ext(ref plan, rank, n, inembed, istride, idist, onembed, ostride, odist, type, batch); }
private static extern CUFFTResult cufftPlan1d_ext(ref cufftHandle plan, int nx, CUFFTType type, int batch);
public static extern CUFFTResult cufftPlan1d(ref cufftHandle plan, int nx, CUFFTType type, int batch);
private static extern CUFFTResult cufftPlanMany_ext(ref cufftHandle plan, int rank, IntPtr n, IntPtr inembed, int istride, int idist, IntPtr onembed, int ostride, int odist, CUFFTType type, int batch);
public static extern CUFFTResult cufftPlan3d(ref cufftHandle plan, int nx, int ny, int nz, CUFFTType type);
public CUFFTResult cufftPlan1d(ref cufftHandle plan, int nx, CUFFTType type, int batch) { return(cufftPlan1d_ext(ref plan, nx, type, batch)); }
public static extern CUFFTResult cufftPlanMany(ref cufftHandle plan, int rank, [In, Out] int[] n, [In, Out] int[] inembed, int istride, int idist, [In, Out] int[] onembed, int ostride, int odist, CUFFTType type, int batch);
public cufftHandle Plan3D(int nx, int ny, int nz, CUFFTType type) { this.plan = new cufftHandle(); this.LastError = _driver.cufftPlan3d(ref this.plan, nx, ny, nz, type); return this.plan; }
public static extern CUFFTResult cufftPlan1d(ref cufftHandle plan, int nx, CUFFTType type, int batch);