我想要一个.cuh
文件,我可以在其中声明内核函数和主机函数。这些功能的实现将在.cu
文件中进行。该实施将包括使用Thrust
库。CUDA和Thrust library:将.cuh .cu和.cpp文件与-std = C++一起使用时遇到问题0x
在main.cpp
文件中,我想使用.cu
文件中的实现。所以我们可以说,我们有这样的事情:
myFunctions.cuh
#include <thrust/sort.h>
#include <thrust/device_vector.h>
#include <thrust/remove.h>
#include <thrust/host_vector.h>
#include <iostream>
__host__ void show();
myFunctions.cu
#include "myFunctions.cuh"
__host__ void show(){
std::cout<<"test"<<std::endl;
}
main.cpp
#include "myFunctions.cuh"
int main(void){
show();
return 0;
}
如果我做这个编译
nvcc myFunctions.cu main.cpp -O3
然后键入./a.out
的test
文本将被打印运行可执行文件。
但是,如果我决定通过使用下面的命令包括-std=c++0x
:
nvcc myFunctions.cu main.cpp -O3 --compiler-options "-std=c++0x"
我得到了很多错误,其中一些如下:
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/c++config.h(159): error: identifier "nullptr" is undefined
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/c++config.h(159): error: expected a ";"
/usr/include/c++/4.6/bits/exception_ptr.h(93): error: incomplete type is not allowed
/usr/include/c++/4.6/bits/exception_ptr.h(93): error: expected a ";"
/usr/include/c++/4.6/bits/exception_ptr.h(112): error: expected a ")"
/usr/include/c++/4.6/bits/exception_ptr.h(114): error: expected a ">"
/usr/include/c++/4.6/bits/exception_ptr.h(114): error: identifier "__o" is undefined
做这些错误意味着什么,我该如何避免它们?
预先感谢您
您可能对[此SO问题]感兴趣(http://stackoverflow.com/questions/12073828/c-version-supported-by-cuda-5-0),它是答案。可能最简单的解决方案是限制你使用的实际需要C++ 0x功能的东西到.cpp文件 – 2013-04-22 14:55:09
我认为C++ 11比C++ 0x更新,这就是为什么它不被支持。但是,我仍然想在.cpp文件中使用C++ 0x,这可能吗?谢谢。如果你想要,你可以做出答案,以便我可以接受。 – ksm001 2013-04-22 15:24:01