7
Thrust是开始编程CUDA的惊人包装。 我想知道是否有什么东西要封装NVIDIA CUFFT或者我们需要实现自己?使用Thrust进行傅里叶变换
Thrust是开始编程CUDA的惊人包装。 我想知道是否有什么东西要封装NVIDIA CUFFT或者我们需要实现自己?使用Thrust进行傅里叶变换
这是一个非常晚的答案,只是为了从无人答复的清单中删除这个问题。
使用带推力的cuFFT应该非常简单,唯一要做的就是将thrust::device_vector
转换为原始指针。一个非常简单的例子如下:
#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();
}
为什么不使用ArrayFire它拥有一个库中的所有东西? –
另一篇文章是关于如何使用推力来计算外层产品..我期望下一篇文章是如何实现Dijkstra算法的推力)为什么人们不断问这个问题? – 2012-12-03 12:08:42
我也想使用ArrayFire,实际上我必须使用它才能与其他库进行比较。有什么办法吗? –