Ich versuche, eine c++
Datei mit nvcc
mit cuda 7.5.18 und gcc 5.4.0 zu kompilieren und bin in Fehler. Nehmen Sie das folgende einfache Beispiel:Klasse hat kein Mitglied "second_argument_type" bei Verwendung von Std :: Ref() mit nvcc
#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));
}
Kompilieren dieses Codes mit nvcc -c -std=c++11 test.cu -o test.o
Ergebnisse in der folgenden Fehlerausgang:
/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".
ich nichts nvcc verwandten mit den Linien error: ... has no member "second_argument_type"
und so weiter finden, so dass ich bin völlig ahnungslos. Anscheinend werden die Klassenmitglieder von std::function
irgendwie nicht gefunden (siehe here).
Was kann ich tun, um dieses Problem zu umgehen?
Ihr Code macht nicht viel Sinn machen. Wenn Sie 'Funktion' und Freunde aus der C++ - Standardbibliothek verwenden, warum gibt es kein' #include 'irgendwo? Und warum importierst du 'schub :: funktional'? Die beiden sind nicht austauschbar .... –
talonmies
Egal was ich mit Ihrem Code mache (mit den offensichtlichen Fehlern, die fehlen), kann ich mit g ++ 4.8 und dem CUDA 7.5 Release Toolkit keinen Kompilierfehler reproduzieren. Das sieht nach einem einfachen Fall aus, in dem CUDA gcc nicht unterstützt. 5. Upgrade auf den CUDA 8 RC-Kandidaten oder Downgrade auf einen unterstützten Compiler – talonmies