Thrust is an amazing wrapper for starting programming CUDA. I wonder there is any thing to encapsulate NVIDIA CUFFT with thrust or we need to implement ourselves?
This is a very late answer, just to remove this question from the unanswered list.
Using cuFFT with thrust should be very simple and the only thing to do should be to cast the thrust::device_vector
to a raw pointer. A very simple example is reported below:
#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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With