тяга :: устройство_вектор std :: shared_ptr

Я хотел бы ускорить сортировку std::vector из std::shared_ptr<CustomClass>, Поиски здесь и там, кажется, что Библиотека тяги может быть ценной альтернативой. Я попытался имитировать настоящий первый пример на сайте Thrust:

typedef std::shared_ptr<CustomClass> CustomClassSP;
thrust::host_vector<CustomClassSP> h = original_std_vector;
thrust::device_vector<CustomClassSP> d = h;

Я использую XCode 4.6.1 (OSX 10.8.3, clang ++ 4.1, tbb 4.1-20121112, Thrust 1.6) со следующими дополнительными флагами C ++:

-DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_TBB -L/opt/local/lib -ltbb -I/opt/local/include

TBB был установлен через MacPorts (который размещает заголовки и библиотеки в / opt / local). К сожалению, такой код не компилируется:

Undefined symbols for architecture x86_64:
"tbb::task_group_context::init()", referenced from:
tbb::task_group_context::task_group_context(tbb::task_group_context::kind_type, unsigned long) in tc12_policy.o
"tbb::task_group_context::~task_group_context()", referenced from:
tbb::interface6::internal::start_for<tbb::blocked_range<long>, thrust::system::tbb::detail::for_each_detail::body<thrust::detail::normal_iterator<thrust::device_ptr<std::__1::shared_ptr<ds::Task> > >, long, thrust::detail::host_destroy_functor<std::__1::shared_ptr<ds::Task> > >, tbb::auto_partitioner const>::run(tbb::blocked_range<long> const&, thrust::system::tbb::detail::for_each_detail::body<thrust::detail::normal_iterator<thrust::device_ptr<std::__1::shared_ptr<ds::Task> > >, long, thrust::detail::host_destroy_functor<std::__1::shared_ptr<ds::Task> > > const&, tbb::auto_partitioner const&) in tc12_policy.o
tbb::interface6::internal::start_for<tbb::blocked_range<long>, thrust::system::tbb::detail::for_each_detail::body<thrust::zip_iterator<thrust::tuple<thrust::detail::normal_iterator<thrust::pointer<std::__1::shared_ptr<ds::Task>, thrust::system::tbb::detail::tag, thrust::use_default, thrust::use_default> >, thrust::detail::normal_iterator<thrust::device_ptr<std::__1::shared_ptr<ds::Task> > >, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type> >, long, thrust::system::detail::generic::detail::uninitialized_copy_functor<std::__1::shared_ptr<ds::Task>, std::__1::shared_ptr<ds::Task> > >, tbb::auto_partitioner const>::run(tbb::blocked_range<long> const&, thrust::system::tbb::detail::for_each_detail::body<thrust::zip_iterator<thrust::tuple<thrust::detail::normal_iterator<thrust::pointer<std::__1::shared_ptr<ds::Task>, thrust::system::tbb::detail::tag, thrust::use_default, thrust::use_default> >, thrust::detail::normal_iterator<thrust::device_ptr<std::__1::shared_ptr<ds::Task> > >, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type> >, long, thrust::system::detail::generic::detail::uninitialized_copy_functor<std::__1::shared_ptr<ds::Task>, std::__1::shared_ptr<ds::Task> > > const&, tbb::auto_partitioner const&) in tc12_policy.o
"tbb::task::note_affinity(unsigned short)", referenced from:
vtable for tbb::interface6::internal::signal_task in tc12_policy.o
vtable for tbb::interface6::internal::flag_task in tc12_policy.o
"tbb::internal::get_initial_auto_partitioner_divisor()", referenced from:
tbb::interface6::internal::auto_partition_type_base<tbb::interface6::internal::auto_partition_type>::auto_partition_type_base() in tc12_policy.o
"tbb::task_group_context::is_group_execution_cancelled() const", referenced from:
tbb::task::is_cancelled() const in tc12_policy.o
"tbb::internal::allocate_child_proxy::free(tbb::task&) const", referenced from:
operator delete(void*, tbb::internal::allocate_child_proxy const&) in tc12_policy.o
"tbb::internal::allocate_child_proxy::allocate(unsigned long) const", referenced from:
operator new(unsigned long, tbb::internal::allocate_child_proxy const&) in tc12_policy.o
"tbb::internal::allocate_continuation_proxy::free(tbb::task&) const", referenced from:
operator delete(void*, tbb::internal::allocate_continuation_proxy const&) in tc12_policy.o
"tbb::internal::allocate_continuation_proxy::allocate(unsigned long) const", referenced from:
operator new(unsigned long, tbb::internal::allocate_continuation_proxy const&) in tc12_policy.o
"tbb::internal::allocate_root_with_context_proxy::free(tbb::task&) const", referenced from:
operator delete(void*, tbb::internal::allocate_root_with_context_proxy const&) in tc12_policy.o
"tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const", referenced from:
operator new(unsigned long, tbb::internal::allocate_root_with_context_proxy const&) in tc12_policy.o
"typeinfo for tbb::task", referenced from:
typeinfo for tbb::interface6::internal::start_for<tbb::blocked_range<long>, thrust::system::tbb::detail::for_each_detail::body<thrust::detail::normal_iterator<thrust::device_ptr<std::__1::shared_ptr<ds::Task> > >, long, thrust::detail::host_destroy_functor<std::__1::shared_ptr<ds::Task> > >, tbb::auto_partitioner const> in tc12_policy.o
typeinfo for tbb::interface6::internal::signal_task in tc12_policy.o
typeinfo for tbb::interface6::internal::flag_task in tc12_policy.o
typeinfo for tbb::interface6::internal::start_for<tbb::blocked_range<long>, thrust::system::tbb::detail::for_each_detail::body<thrust::zip_iterator<thrust::tuple<thrust::detail::normal_iterator<thrust::pointer<std::__1::shared_ptr<ds::Task>, thrust::system::tbb::detail::tag, thrust::use_default, thrust::use_default> >, thrust::detail::normal_iterator<thrust::device_ptr<std::__1::shared_ptr<ds::Task> > >, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type> >, long, thrust::system::detail::generic::detail::uninitialized_copy_functor<std::__1::shared_ptr<ds::Task>, std::__1::shared_ptr<ds::Task> > >, tbb::auto_partitioner const> in tc12_policy.o
"vtable for tbb::task", referenced from:
tbb::task::task() in tc12_policy.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Если я изменю thrust::device_vector объявление следующим образом:

thrust::device_vector<CustomClass*> d;

Это соответствует без ошибок. Итак, естественно возникает вопрос: «можно ли использовать std::shared_ptr<T> с библиотекой Thrust? «*

Благодарю.

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]