2012-05-29 53 views
2

我需要一些幫助來追蹤編譯錯誤thrust :: fill正在給我。推力:填充編譯錯誤

是沒有錯的代碼:

line 9 #include <thrust/device_vector.h>    // needed for other thrust stuff 
line 10 #include <thrust/fill.h>      // not needed (same err w/ or w/o) 
. 
. 
line 389 thrust::device_vector<int> junk(20);   // any ol array 
line 390 thrust::fill(junk.begin(), junk.end(), (int)0); // the problem line 

這將編譯好的,如果我註釋掉「填充」行。 任何(raw_pointer,device_vector,..)thrust :: 填充命令,我使用將生成此錯誤。其他THRUST cmds編譯正常。 錯誤只有幾頁。我不確定錯誤是什麼。 'for_each'被提及很多。 'compute_capability'的最後一個沒有意義,因爲它不在我的任何代碼中。我嘗試添加一堆'#include'文件,但它沒有任何幫助。

任何想法,將不勝感激。

In file included from /usr/local/cuda/include/thrust/detail/backend/cuda/for_each.h:54:0, 
       from /usr/local/cuda/include/thrust/detail/backend/for_each.inl:23, 
       from /usr/local/cuda/include/thrust/detail/backend/for_each.h:55, 
       from /usr/local/cuda/include/thrust/detail/for_each.inl:22, 
       from /usr/local/cuda/include/thrust/for_each.h:91, 
       from /usr/local/cuda/include/thrust/detail/swap_ranges.inl:25, 
       from /usr/local/cuda/include/thrust/detail/swap.inl:33, 
       from /usr/local/cuda/include/thrust/swap.h:127, 
       from /usr/local/cuda/include/thrust/detail/contiguous_storage.inl:20, 
       from /usr/local/cuda/include/thrust/detail/contiguous_storage.h:92, 
       from /usr/local/cuda/include/thrust/detail/uninitialized_array.h:26, 
       from /usr/local/cuda/include/thrust/detail/backend/cuda/copy_cross_space.inl:20, 
       from /usr/local/cuda/include/thrust/detail/backend/cuda/copy_cross_space.h:57, 
       from /usr/local/cuda/include/thrust/detail/backend/cuda/dispatch/copy.h:23, 
       from /usr/local/cuda/include/thrust/detail/backend/cuda/copy.h:21, 
       from /usr/local/cuda/include/thrust/detail/backend/dispatch/copy.h:24, 
       from /usr/local/cuda/include/thrust/detail/backend/copy.inl:20, 
       from /usr/local/cuda/include/thrust/detail/backend/copy.h:44, 
       from /usr/local/cuda/include/thrust/detail/copy.inl:20, 
       from /usr/local/cuda/include/thrust/detail/copy.h:39, 
       from /usr/local/cuda/include/thrust/detail/reference_base.inl:18, 
       from /usr/local/cuda/include/thrust/detail/reference_base.h:138, 
       from /usr/local/cuda/include/thrust/device_reference.h:27, 
       from /usr/local/cuda/include/thrust/detail/device_ptr.inl:23, 
       from /usr/local/cuda/include/thrust/device_ptr.h:181, 
       from /usr/local/cuda/include/thrust/device_malloc_allocator.h:25, 
       from /usr/local/cuda/include/thrust/device_vector.h:25, 
       from /home/rrob/workspace/dicol/klm/src/Map.cpp:9: 
/usr/local/cuda/include/thrust/detail/backend/cuda/for_each.inl: In function ‘RandomAccessIterator thrust::detail::backend::cuda::for_each_n(RandomAccessIterator, Size, UnaryFunction) [with RandomAccessIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, Size = long int, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<int> >]’: 
/usr/local/cuda/include/thrust/detail/backend/for_each.inl:56:63: instantiated from ‘OutputIterator thrust::detail::backend::dispatch::for_each_n(OutputIterator, Size, UnaryFunction, thrust::detail::cuda_device_space_tag) [with OutputIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, Size = long int, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<int> >]’ 
/usr/local/cuda/include/thrust/detail/backend/for_each.inl:126:62: instantiated from ‘OutputIterator thrust::detail::backend::for_each_n(OutputIterator, Size, UnaryFunction) [with OutputIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, Size = long int, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<int> >]’ 
/usr/local/cuda/include/thrust/detail/for_each.inl:39:57: instantiated from ‘OutputIterator thrust::detail::for_each_n(OutputIterator, Size, UnaryFunction) [with OutputIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, Size = long int, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<int> >]’ 
/usr/local/cuda/include/thrust/detail/generate.inl:51:100: instantiated from ‘OutputIterator thrust::generate_n(OutputIterator, Size, Generator) [with OutputIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, Size = long int, Generator = thrust::detail::fill_functor<int>]’ 
/usr/local/cuda/include/thrust/detail/backend/cuda/fill.inl:93:43: instantiated from ‘OutputIterator thrust::detail::backend::cuda::detail::fill_n(OutputIterator, Size, const T&, thrust::detail::false_type) [with OutputIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, Size = long int, T = int, thrust::detail::false_type = thrust::detail::integral_constant<bool, false>]’ 
/usr/local/cuda/include/thrust/detail/backend/cuda/fill.inl:123:64: [ skipping 3 instantiation contexts ] 
/usr/local/cuda/include/thrust/detail/backend/fill.inl:93:60: instantiated from ‘OutputIterator thrust::detail::backend::fill_n(OutputIterator, Size, const T&) [with OutputIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, Size = long int, T = int]’ 
/usr/local/cuda/include/thrust/detail/backend/generic/fill.h:51:3: instantiated from ‘void thrust::detail::backend::generic::fill(ForwardIterator, ForwardIterator, const T&) [with ForwardIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, T = int]’ 
/usr/local/cuda/include/thrust/detail/backend/fill.inl:51:3: instantiated from ‘void thrust::detail::backend::dispatch::fill(ForwardIterator, ForwardIterator, const T&, Backend) [with ForwardIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, T = int, Backend = thrust::detail::cuda_device_space_tag]’ 
/usr/local/cuda/include/thrust/detail/backend/fill.inl:83:3: instantiated from ‘void thrust::detail::backend::fill(ForwardIterator, ForwardIterator, const T&) [with ForwardIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, T = int]’ 
/usr/local/cuda/include/thrust/detail/fill.inl:34:3: instantiated from ‘void thrust::fill(ForwardIterator, ForwardIterator, const T&) [with ForwardIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, T = int]’ 
/home/rrob/workspace/dicol/klm/src/Map.cpp:390:49: instantiated from here 
/usr/local/cuda/include/thrust/detail/backend/cuda/for_each.inl:96:1: error: invalid application of ‘sizeof’ to incomplete type ‘thrust::detail::STATIC_ASSERTION_FAILURE<false>’ 
/usr/local/cuda/include/thrust/detail/backend/cuda/for_each.inl: In function ‘RandomAccessIterator thrust::detail::backend::cuda::for_each_n(RandomAccessIterator, Size, UnaryFunction) [with RandomAccessIterator = thrust::device_ptr<int>, Size = long int, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<int> >]’: 
/usr/local/cuda/include/thrust/detail/backend/for_each.inl:56:63: instantiated from ‘OutputIterator thrust::detail::backend::dispatch::for_each_n(OutputIterator, Size, UnaryFunction, thrust::detail::cuda_device_space_tag) [with OutputIterator = thrust::device_ptr<int>, Size = long int, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<int> >]’ 
/usr/local/cuda/include/thrust/detail/backend/for_each.inl:126:62: instantiated from ‘OutputIterator thrust::detail::backend::for_each_n(OutputIterator, Size, UnaryFunction) [with OutputIterator = thrust::device_ptr<int>, Size = long int, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<int> >]’ 
/usr/local/cuda/include/thrust/detail/backend/generic/for_each.inl:36:84: instantiated from ‘InputIterator thrust::detail::backend::generic::for_each(InputIterator, InputIterator, UnaryFunction) [with InputIterator = thrust::device_ptr<int>, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<int> >]’ 
/usr/local/cuda/include/thrust/detail/backend/for_each.inl:91:67: instantiated from ‘InputIterator thrust::detail::backend::dispatch::for_each(InputIterator, InputIterator, UnaryFunction, Space) [with InputIterator = thrust::device_ptr<int>, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<int> >, Space = thrust::detail::cuda_device_space_tag]’ 
/usr/local/cuda/include/thrust/detail/backend/for_each.inl:136:61: instantiated from ‘InputIterator thrust::detail::backend::for_each(InputIterator, InputIterator, UnaryFunction) [with InputIterator = thrust::device_ptr<int>, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<int> >]’ 
/usr/local/cuda/include/thrust/detail/for_each.inl:48:58: [ skipping 7 instantiation contexts ] 
/usr/local/cuda/include/thrust/detail/backend/fill.inl:93:60: instantiated from ‘OutputIterator thrust::detail::backend::fill_n(OutputIterator, Size, const T&) [with OutputIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, Size = long int, T = int]’ 
/usr/local/cuda/include/thrust/detail/backend/generic/fill.h:51:3: instantiated from ‘void thrust::detail::backend::generic::fill(ForwardIterator, ForwardIterator, const T&) [with ForwardIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, T = int]’ 
/usr/local/cuda/include/thrust/detail/backend/fill.inl:51:3: instantiated from ‘void thrust::detail::backend::dispatch::fill(ForwardIterator, ForwardIterator, const T&, Backend) [with ForwardIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, T = int, Backend = thrust::detail::cuda_device_space_tag]’ 
/usr/local/cuda/include/thrust/detail/backend/fill.inl:83:3: instantiated from ‘void thrust::detail::backend::fill(ForwardIterator, ForwardIterator, const T&) [with ForwardIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, T = int]’ 
/usr/local/cuda/include/thrust/detail/fill.inl:34:3: instantiated from ‘void thrust::fill(ForwardIterator, ForwardIterator, const T&) [with ForwardIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, T = int]’ 
/home/rrob/workspace/dicol/klm/src/Map.cpp:390:49: instantiated from here 
/usr/local/cuda/include/thrust/detail/backend/cuda/for_each.inl:96:1: error: invalid application of ‘sizeof’ to incomplete type ‘thrust::detail::STATIC_ASSERTION_FAILURE<false>’ 
/usr/local/cuda/include/thrust/detail/backend/cuda/for_each.inl: In function ‘RandomAccessIterator thrust::detail::backend::cuda::for_each_n(RandomAccessIterator, Size, UnaryFunction) [with RandomAccessIterator = thrust::device_ptr<unsigned int>, Size = long int, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<unsigned int> >]’: 
/usr/local/cuda/include/thrust/detail/backend/for_each.inl:56:63: instantiated from ‘OutputIterator thrust::detail::backend::dispatch::for_each_n(OutputIterator, Size, UnaryFunction, thrust::detail::cuda_device_space_tag) [with OutputIterator = thrust::device_ptr<unsigned int>, Size = long int, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<unsigned int> >]’ 
/usr/local/cuda/include/thrust/detail/backend/for_each.inl:126:62: instantiated from ‘OutputIterator thrust::detail::backend::for_each_n(OutputIterator, Size, UnaryFunction) [with OutputIterator = thrust::device_ptr<unsigned int>, Size = long int, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<unsigned int> >]’ 
/usr/local/cuda/include/thrust/detail/backend/generic/for_each.inl:36:84: instantiated from ‘InputIterator thrust::detail::backend::generic::for_each(InputIterator, InputIterator, UnaryFunction) [with InputIterator = thrust::device_ptr<unsigned int>, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<unsigned int> >]’ 
/usr/local/cuda/include/thrust/detail/backend/for_each.inl:91:67: instantiated from ‘InputIterator thrust::detail::backend::dispatch::for_each(InputIterator, InputIterator, UnaryFunction, Space) [with InputIterator = thrust::device_ptr<unsigned int>, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<unsigned int> >, Space = thrust::detail::cuda_device_space_tag]’ 
/usr/local/cuda/include/thrust/detail/backend/for_each.inl:136:61: instantiated from ‘InputIterator thrust::detail::backend::for_each(InputIterator, InputIterator, UnaryFunction) [with InputIterator = thrust::device_ptr<unsigned int>, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<unsigned int> >]’ 
/usr/local/cuda/include/thrust/detail/for_each.inl:48:58: [ skipping 7 instantiation contexts ] 
/usr/local/cuda/include/thrust/detail/backend/fill.inl:93:60: instantiated from ‘OutputIterator thrust::detail::backend::fill_n(OutputIterator, Size, const T&) [with OutputIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, Size = long int, T = int]’ 
/usr/local/cuda/include/thrust/detail/backend/generic/fill.h:51:3: instantiated from ‘void thrust::detail::backend::generic::fill(ForwardIterator, ForwardIterator, const T&) [with ForwardIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, T = int]’ 
/usr/local/cuda/include/thrust/detail/backend/fill.inl:51:3: instantiated from ‘void thrust::detail::backend::dispatch::fill(ForwardIterator, ForwardIterator, const T&, Backend) [with ForwardIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, T = int, Backend = thrust::detail::cuda_device_space_tag]’ 
/usr/local/cuda/include/thrust/detail/backend/fill.inl:83:3: instantiated from ‘void thrust::detail::backend::fill(ForwardIterator, ForwardIterator, const T&) [with ForwardIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, T = int]’ 
/usr/local/cuda/include/thrust/detail/fill.inl:34:3: instantiated from ‘void thrust::fill(ForwardIterator, ForwardIterator, const T&) [with ForwardIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, T = int]’ 
/home/rrob/workspace/dicol/klm/src/Map.cpp:390:49: instantiated from here 
/usr/local/cuda/include/thrust/detail/backend/cuda/for_each.inl:96:1: error: invalid application of ‘sizeof’ to incomplete type ‘thrust::detail::STATIC_ASSERTION_FAILURE<false>’ 
/usr/local/cuda/include/thrust/detail/backend/cuda/for_each.inl: In function ‘RandomAccessIterator thrust::detail::backend::cuda::for_each_n(RandomAccessIterator, Size, UnaryFunction) [with RandomAccessIterator = thrust::device_ptr<long long unsigned int>, Size = long int, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<long long unsigned int> >]’: 
/usr/local/cuda/include/thrust/detail/backend/for_each.inl:56:63: instantiated from ‘OutputIterator thrust::detail::backend::dispatch::for_each_n(OutputIterator, Size, UnaryFunction, thrust::detail::cuda_device_space_tag) [with OutputIterator = thrust::device_ptr<long long unsigned int>, Size = long int, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<long long unsigned int> >]’ 
/usr/local/cuda/include/thrust/detail/backend/for_each.inl:126:62: instantiated from ‘OutputIterator thrust::detail::backend::for_each_n(OutputIterator, Size, UnaryFunction) [with OutputIterator = thrust::device_ptr<long long unsigned int>, Size = long int, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<long long unsigned int> >]’ 
/usr/local/cuda/include/thrust/detail/backend/generic/for_each.inl:36:84: instantiated from ‘InputIterator thrust::detail::backend::generic::for_each(InputIterator, InputIterator, UnaryFunction) [with InputIterator = thrust::device_ptr<long long unsigned int>, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<long long unsigned int> >]’ 
/usr/local/cuda/include/thrust/detail/backend/for_each.inl:91:67: instantiated from ‘InputIterator thrust::detail::backend::dispatch::for_each(InputIterator, InputIterator, UnaryFunction, Space) [with InputIterator = thrust::device_ptr<long long unsigned int>, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<long long unsigned int> >, Space = thrust::detail::cuda_device_space_tag]’ 
/usr/local/cuda/include/thrust/detail/backend/for_each.inl:136:61: instantiated from ‘InputIterator thrust::detail::backend::for_each(InputIterator, InputIterator, UnaryFunction) [with InputIterator = thrust::device_ptr<long long unsigned int>, UnaryFunction = thrust::detail::device_generate_functor<thrust::detail::fill_functor<long long unsigned int> >]’ 
/usr/local/cuda/include/thrust/detail/for_each.inl:48:58: [ skipping 7 instantiation contexts ] 
/usr/local/cuda/include/thrust/detail/backend/fill.inl:93:60: instantiated from ‘OutputIterator thrust::detail::backend::fill_n(OutputIterator, Size, const T&) [with OutputIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, Size = long int, T = int]’ 
/usr/local/cuda/include/thrust/detail/backend/generic/fill.h:51:3: instantiated from ‘void thrust::detail::backend::generic::fill(ForwardIterator, ForwardIterator, const T&) [with ForwardIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, T = int]’ 
/usr/local/cuda/include/thrust/detail/backend/fill.inl:51:3: instantiated from ‘void thrust::detail::backend::dispatch::fill(ForwardIterator, ForwardIterator, const T&, Backend) [with ForwardIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, T = int, Backend = thrust::detail::cuda_device_space_tag]’ 
/usr/local/cuda/include/thrust/detail/backend/fill.inl:83:3: instantiated from ‘void thrust::detail::backend::fill(ForwardIterator, ForwardIterator, const T&) [with ForwardIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, T = int]’ 
/usr/local/cuda/include/thrust/detail/fill.inl:34:3: instantiated from ‘void thrust::fill(ForwardIterator, ForwardIterator, const T&) [with ForwardIterator = thrust::detail::normal_iterator<thrust::device_ptr<int> >, T = int]’ 
/home/rrob/workspace/dicol/klm/src/Map.cpp:390:49: instantiated from here 
/usr/local/cuda/include/thrust/detail/backend/cuda/for_each.inl:96:1: error: invalid application of ‘sizeof’ to incomplete type ‘thrust::detail::STATIC_ASSERTION_FAILURE<false>’ 
/usr/local/cuda/include/thrust/detail/backend/cuda/arch.h: At global scope: 
/usr/local/cuda/include/thrust/detail/backend/cuda/arch.h:90:15: warning: inline function ‘size_t thrust::detail::backend::cuda::arch::compute_capability()’ used but never defined 
make[2]: *** [CMakeFiles/Map.dir/Map.cpp.o] Error 1 
make[1]: *** [CMakeFiles/Map.dir/all] Error 2 
make: *** [all] Error 2 
+1

包含調用fill()的特定文件是使用NVCC編譯的? – Bart

回答

6

您使用了錯誤的編譯路徑,因爲你的代碼的文件擴展名是不正確的:

make[2]: *** [CMakeFiles/Map.dir/Map.cpp.o] Error 1 

的解決方案是命名文件Map.cu而非Map.ccp。 .cu擴展名告訴nvcc文件中有設備代碼,並且需要設備編譯器軌跡。 thrust::fill調用一個內核並引入設備代碼,而向量聲明只使用主機編譯器可以處理的API調用。這就是爲什麼編譯只有在調用thrust::fill時纔會失敗。

+0

是的,這是問題所在。 (我浪費了幾個小時的時間。)我正在開發Map.cpp文件中的代碼,目的是將它移動到map.cu文件中。我的其他THRUST命令很多都能在cpp文件中很好地編譯,......我從來不會發現它。到目前爲止,我認爲NVCC不關心文件擴展名。 – Doug

+0

@Doug使用其他推力命令時,你確定使用了設備指針嗎? –