1

ラムダ式は初めてです。data[10]次の式で推力装置ベクトルを初期化しようとしています。

data [i] = i * 0.1 + 0.5;

これらのヘッダーファイルと名前空間をインクルードしました

#include <thrust/device_vector.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
#include <thrust/functional.h>
using namespace thrust::placeholders;

これが定義と初期化のコードですdata

thrust::device_vector<double> data(
        thrust::make_transform_iterator(
                thrust::counting_iterator<double>(0), _1 * 0.1 + 0.5),
        thrust::make_transform_iterator(
                thrust::counting_iterator<double>(0), _1 * 0.1 + 0.5) + 10);

しかし、それはコンパイルできず、投稿の最後に示されているように非常に長いエラーメッセージを示しています。

私は何か間違ったことをしていますか?

CUDA 5.0、CentOS 6.3 x86_64、gcc4.4.6を使用しています

/usr/local/cuda-5.0/bin/../include/thrust/iterator/detail/transform_iterator.inl(94): error: no instance of overloaded function "thrust::detail::functional::actor<Eval>::operator() [with Eval=thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::plus>, thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::multiplies>, thrust::detail::functional::actor<thrust::detail::functional::argument<0U>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>]" matches the argument list
            argument types are: (double)
            object type is: thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::plus>, thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::multiplies>, thrust::detail::functional::actor<thrust::detail::functional::argument<0U>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>
          detected during:
            instantiation of "thrust::detail::backend::dereference_result<thrust::transform_iterator<UnaryFunc, Iterator, Reference, Value>>::type thrust::detail::backend::dereference(const thrust::transform_iterator<UnaryFunc, Iterator, Reference, Value> &) [with UnaryFunc=thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::plus>, thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::multiplies>, thrust::detail::functional::actor<thrust::detail::functional::argument<0U>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, Iterator=thrust::counting_iterator<double, thrust::use_default, thrust::use_default, thrust::use_default>, Reference=thrust::use_default, Value=thrust::use_default]" 
/usr/local/cuda-5.0/bin/../include/thrust/iterator/detail/zip_iterator_base.h(128): here
            instantiation of "thrust::detail::device_dereference_iterator::apply<Iterator>::type thrust::detail::device_dereference_iterator::operator()(const Iterator &) [with Iterator=thrust::transform_iterator<thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::plus>, thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::multiplies>, thrust::detail::functional::actor<thrust::detail::functional::argument<0U>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::counting_iterator<double, thrust::use_default, thrust::use_default, thrust::use_default>, thrust::use_default, thrust::use_default>]" 
/usr/local/cuda-5.0/bin/../include/thrust/detail/tuple_transform.h(102): here
            instantiation of "thrust::detail::tuple_meta_transform<Tuple, UnaryMetaFunction, thrust::tuple_size<Tuple>::value>::type thrust::detail::tuple_transform_functor<Tuple, UnaryMetaFunction, UnaryFunction, 2U>::do_it_on_the_host_or_device(const Tuple &, UnaryFunction) [with Tuple=thrust::tuple<thrust::transform_iterator<thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::plus>, thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::multiplies>, thrust::detail::functional::actor<thrust::detail::functional::argument<0U>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::counting_iterator<double, thrust::use_default, thrust::use_default, thrust::use_default>, thrust::use_default, thrust::use_default>, thrust::detail::normal_iterator<thrust::device_ptr<double>>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>, UnaryMetaFunction=thrust::detail::device_dereference_iterator::apply, UnaryFunction=thrust::detail::device_dereference_iterator]" 
/usr/local/cuda-5.0/bin/../include/thrust/detail/tuple_transform.h(412): here
            instantiation of "thrust::detail::tuple_meta_transform<Tuple, UnaryMetaFunction, thrust::tuple_size<Tuple>::value>::type thrust::detail::tuple_host_device_transform<UnaryMetaFunction,Tuple,UnaryFunction>(const Tuple &, UnaryFunction) [with UnaryMetaFunction=thrust::detail::device_dereference_iterator::apply, Tuple=thrust::tuple<thrust::transform_iterator<thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::plus>, thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::multiplies>, thrust::detail::functional::actor<thrust::detail::functional::argument<0U>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::counting_iterator<double, thrust::use_default, thrust::use_default, thrust::use_default>, thrust::use_default, thrust::use_default>, thrust::detail::normal_iterator<thrust::device_ptr<double>>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>, UnaryFunction=thrust::detail::device_dereference_iterator]" 
/usr/local/cuda-5.0/bin/../include/thrust/iterator/detail/zip_iterator.inl(160): here
            instantiation of "thrust::detail::backend::dereference_result<thrust::zip_iterator<IteratorTuple>>::type thrust::detail::backend::dereference(const thrust::zip_iterator<IteratorTuple> &) [with IteratorTuple=thrust::tuple<thrust::transform_iterator<thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::plus>, thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::multiplies>, thrust::detail::functional::actor<thrust::detail::functional::argument<0U>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::counting_iterator<double, thrust::use_default, thrust::use_default, thrust::use_default>, thrust::use_default, thrust::use_default>, thrust::detail::normal_iterator<thrust::device_ptr<double>>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>]" 
/usr/local/cuda-5.0/bin/../include/thrust/detail/backend/cuda/for_each.inl(75): here
            [ 24 instantiation contexts not shown ]
            instantiation of "void thrust::detail::vector_base<T, Alloc>::allocate_and_copy(thrust::detail::vector_base<T, Alloc>::size_type, ForwardIterator, ForwardIterator, thrust::detail::vector_base<T, Alloc>::storage_type &) [with T=double, Alloc=thrust::device_malloc_allocator<double>, ForwardIterator=thrust::transform_iterator<thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::plus>, thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::multiplies>, thrust::detail::functional::actor<thrust::detail::functional::argument<0U>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::counting_iterator<double, thrust::use_default, thrust::use_default, thrust::use_default>, thrust::use_default, thrust::use_default>]" 
/usr/local/cuda-5.0/bin/../include/thrust/detail/vector_base.inl(191): here
            instantiation of "void thrust::detail::vector_base<T, Alloc>::range_init(ForwardIterator, ForwardIterator, thrust::detail::false_type) [with T=double, Alloc=thrust::device_malloc_allocator<double>, ForwardIterator=thrust::transform_iterator<thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::plus>, thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::multiplies>, thrust::detail::functional::actor<thrust::detail::functional::argument<0U>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::counting_iterator<double, thrust::use_default, thrust::use_default, thrust::use_default>, thrust::use_default, thrust::use_default>]" 
/usr/local/cuda-5.0/bin/../include/thrust/detail/vector_base.inl(168): here
            instantiation of "void thrust::detail::vector_base<T, Alloc>::init_dispatch(IteratorOrIntegralType, IteratorOrIntegralType, thrust::detail::false_type) [with T=double, Alloc=thrust::device_malloc_allocator<double>, IteratorOrIntegralType=thrust::transform_iterator<thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::plus>, thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::multiplies>, thrust::detail::functional::actor<thrust::detail::functional::argument<0U>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::counting_iterator<double, thrust::use_default, thrust::use_default, thrust::use_default>, thrust::use_default, thrust::use_default>]" 
/usr/local/cuda-5.0/bin/../include/thrust/detail/vector_base.inl(207): here
            instantiation of "thrust::detail::vector_base<T, Alloc>::vector_base(InputIterator, InputIterator) [with T=double, Alloc=thrust::device_malloc_allocator<double>, InputIterator=thrust::transform_iterator<thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::plus>, thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::multiplies>, thrust::detail::functional::actor<thrust::detail::functional::argument<0U>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::counting_iterator<double, thrust::use_default, thrust::use_default, thrust::use_default>, thrust::use_default, thrust::use_default>]" 
/usr/local/cuda-5.0/bin/../include/thrust/device_vector.h(131): here
            instantiation of "thrust::device_vector<T, Alloc>::device_vector(InputIterator, InputIterator) [with T=double, Alloc=thrust::device_malloc_allocator<double>, InputIterator=thrust::transform_iterator<thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::plus>, thrust::detail::functional::actor<thrust::detail::functional::composite<thrust::detail::functional::binary_operator<thrust::multiplies>, thrust::detail::functional::actor<thrust::detail::functional::argument<0U>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::detail::functional::value<double>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>, thrust::counting_iterator<double, thrust::use_default, thrust::use_default, thrust::use_default>, thrust::use_default, thrust::use_default>]" 
test/lambda.cu(27): here
4

1 に答える 1

2

@RobertCrovellaの提案に感謝します。

推力をv1.6/v1.7にアップグレードした後、質問に表示されているコードを変更せずに問題が修正されます。cuda5.0のthrustv1.53は、ラムダ式機能には古すぎるようです。

于 2013-01-11T21:18:28.207 に答える