.cuh
カーネル関数とホスト関数も宣言できるファイルが必要です。これらの関数の実装は、.cu
ファイル内で行われます。実装には、Thrust
ライブラリの使用が含まれます。
ファイルでは、ファイル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
これらのエラーは何を意味し、どうすれば回避できますか?
前もって感謝します