我想編譯一個c++
文件與nvcc
使用cuda 7.5.18和gcc 5.4.0並且運行時出現錯誤。看看下面簡單的例子:類使用std :: ref()與nvcc時沒有成員「second_argument_type」
#include <thrust/functional.h>
struct test_struct {
//..
}
void f(test_struct& a) {
//..
}
int main() {
test_struct a;
std::function<void()> bound_f = std::bind(f, std::ref(a));
}
編譯此代碼與nvcc -c -std=c++11 test.cu -o test.o
結果在下面的錯誤輸出:
/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/c++/functional(78): error: class "test_struct" has no member "result_type"
detected during:
instantiation of class "std::_Maybe_get_result_type<_Functor, void> [with _Functor=test_struct]"
(86): here
instantiation of class "std::_Weak_result_type_impl<_Functor> [with _Functor=test_struct]"
(184): here
instantiation of class "std::_Weak_result_type<_Functor> [with _Functor=test_struct]"
(264): here
instantiation of class "std::_Reference_wrapper_base_impl<true, true, _Tp> [with _Tp=test_struct]"
(283): here
instantiation of class "std::_Reference_wrapper_base<_Tp> [with _Tp=test_struct]"
(399): here
instantiation of class "std::reference_wrapper<_Tp> [with _Tp=test_struct]"
test.cu(14): here
/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/c++/functional(266): error: class "test_struct" has no member "argument_type"
detected during:
instantiation of class "std::_Reference_wrapper_base_impl<true, true, _Tp> [with _Tp=test_struct]"
(283): here
instantiation of class "std::_Reference_wrapper_base<_Tp> [with _Tp=test_struct]"
(399): here
instantiation of class "std::reference_wrapper<_Tp> [with _Tp=test_struct]"
test.cu(14): here
/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/c++/functional(267): error: class "test_struct" has no member "first_argument_type"
detected during:
instantiation of class "std::_Reference_wrapper_base_impl<true, true, _Tp> [with _Tp=test_struct]"
(283): here
instantiation of class "std::_Reference_wrapper_base<_Tp> [with _Tp=test_struct]"
(399): here
instantiation of class "std::reference_wrapper<_Tp> [with _Tp=test_struct]"
test.cu(14): here
/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/c++/functional(268): error: class "test_struct" has no member "second_argument_type"
detected during:
instantiation of class "std::_Reference_wrapper_base_impl<true, true, _Tp> [with _Tp=test_struct]"
(283): here
instantiation of class "std::_Reference_wrapper_base<_Tp> [with _Tp=test_struct]"
(399): here
instantiation of class "std::reference_wrapper<_Tp> [with _Tp=test_struct]"
test.cu(14): here
5 errors detected in the compilation of "/tmp/tmpxft_00003b29_00000000-7_test.cpp1.ii".
我無法找到任何與NVCC線error: ... has no member "second_argument_type"
相關等等,所以我我完全無能爲力。顯然,std::function
的班級成員找不到(請參閱here)。
我能做些什麼來解決這個問題?
您的代碼並沒有太大的意義。如果你使用C++標準庫中的函數和朋友,爲什麼在任何地方都沒有'#include'?你爲什麼要輸入'thrust :: functional'?這兩者不可互換.... –
talonmies
無論我對代碼做什麼(缺少明顯的錯誤),我都無法使用g ++ 4.8和CUDA 7.5版本工具包來重現任何類型的編譯錯誤。這看起來的CUDA不支持GCC 5.升級到CUDA 8 RC候選版或降級到支持的編譯器 – talonmies