我从推力webpage下载了推力1.70和1.60到我的主目录/home/me/project/thrust
。当我尝试使用gcc -c -I/home/me/project thrust_1_example.cpp
运行下面的example时,收到了找不到标题文件的错误消息:In file included from /home/me/project/thrust/detail/config.h:22,
from /home/me/project/thrust/host_vector.h:24,
from thrust_1_example.cpp:1:
/home/me/project/thrust/detail/config/config.h:25:49: error: thrust/detail/config/simple_defines.h: No such file or directory
我发现detail/config
确实是空的。我错过了什么吗?
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <iostream>
int main(void)
{
// H has storage for 4 integers
thrust::host_vector<int> H(4);
// initialize individual elements
H[0] = 14;
H[1] = 20;
H[2] = 38;
H[3] = 46;
// H.size() returns the size of vector H
std::cout << "H has size " << H.size() << std::endl;
// print contents of H
for(int i = 0; i < H.size(); i++)
std::cout << "H[" << i << "] = " << H[i] << std::endl;
// resize H
H.resize(2);
std::cout << "H now has size " << H.size() << std::endl;
// Copy host_vector H to device_vector D
thrust::device_vector<int> D = H;
// elements of D can be modified
D[0] = 99;
D[1] = 88;
// print contents of D
for(int i = 0; i < D.size(); i++)
std::cout << "D[" << i << "] = " << D[i] << std::endl;
// H and D are automatically deleted when the function returns
return 0;
}
答案 0 :(得分:1)
如果您只是安装CUDA 5.5,您将获得推力1.7。
如果您的目标是GPU后端(意味着您想在GPU上运行推力代码),则需要nvcc
,即GPU设备代码编译器/编译器驱动程序,它随CUDA 5.5一起提供。
您无法使用gcc
构建推力GPU代码(必须使用nvcc
),文件名应以.cu
而不是.cpp