Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
        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);
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
 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);
Exemplo n.º 8
0
 private static extern CUFFTResult cufftPlan3d_ext(ref cufftHandle plan, int nx, int ny, int nz, CUFFTType type);
Exemplo n.º 9
0
 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));
 }
Exemplo n.º 10
0
 public CUFFTResult cufftPlan3d(ref cufftHandle plan, int nx, int ny, int nz, CUFFTType type)
 {
     return cufftPlan3d_ext(ref plan, nx, ny, nz, type);
 }
Exemplo n.º 11
0
 public CUFFTResult cufftPlan1d(ref cufftHandle plan, int nx, CUFFTType type, int batch)
 {
     return cufftPlan1d_ext(ref plan, nx, type, batch);
 }
Exemplo n.º 12
0
 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);
Exemplo n.º 13
0
 private static extern CUFFTResult cufftPlan3d_ext(ref cufftHandle plan, int nx, int ny, int nz, CUFFTType type);
Exemplo n.º 14
0
 private static extern CUFFTResult cufftPlan1d_ext(ref cufftHandle plan, int nx, CUFFTType type, int batch);
Exemplo n.º 15
0
 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);
 }
Exemplo n.º 16
0
 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);
 }
Exemplo n.º 17
0
 public CUFFTResult cufftPlan3d(ref cufftHandle plan, int nx, int ny, int nz, CUFFTType type)
 {
     return(cufftPlan3d_ext(ref plan, nx, ny, nz, type));
 }
Exemplo n.º 18
0
 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);
 }
Exemplo n.º 19
0
 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);
Exemplo n.º 21
0
 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);
Exemplo n.º 23
0
 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);
Exemplo n.º 25
0
 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);