Performing Fourier Transform Using Traction

Thrust is a terrific shell for starting CUDA programming. I wonder if there is anything to encapsulate NVIDIA CUFFT with traction or do we need to realize ourselves?

+7
source share
1 answer

This is a very late answer, just to remove this question from the unanswered list.

Using cuFFT with traction should be very simple, and the only thing to do is to make thrust::device_vector raw pointer. The following is a very simple example:

 #include <iostream> #include <cufft.h> #include <stdlib.h> #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/generate.h> #include <thrust/transform.h> int main(void){ int N=4; // --- Setting up input device vector thrust::device_vector<cuFloatComplex> d_in(N,make_cuComplex(1.f,2.f)), d_out(N); cufftHandle plan; cufftPlan1d(&plan, N, CUFFT_C2C, 1); cufftExecC2C(plan, thrust::raw_pointer_cast(d_in.data()), thrust::raw_pointer_cast(d_out.data()), CUFFT_FORWARD); // --- Setting up output host vector thrust::host_vector<cuFloatComplex> h_out(d_out); for (int i=0; i<N; i++) printf("Element #%i; Real part = %f; Imaginary part: %f\n",i,h_out[i].x,h_out[i].y); getchar(); } 
+6
source

All Articles