gpt4 book ai didi

c++ - NVidia推力device_vector的字符串

转载 作者:行者123 更新时间:2023-11-30 04:34:32 25 4
gpt4 key购买 nike

我开始使用NVidia Thrust库,该库是CUDA 4.0工具包的一部分,希望在深入研究之前先进行验证。我可以执行以下操作,并且在构建过程中没有任何问题:

thrust::host_vector <int> iVec;
thrust::device_vector <int> iVec2;
thrust::host_vector <std::string> sVec;

当我尝试以下操作时,出现编译错误:
    thrust::device_vector <std::string> sVec2;

我想知道的是,我可以假定我可以在STL vector 中使用的任何数据类型都可以在推力 vector 中使用,而不论它是设备还是主机?还是这里有限制,我不应该期望它起作用吗?

我得到的错误如下:

c:\ program files \ nvidia gpu计算工具包\ cuda \ v4.0 \ include \ thrust \ detail \ device \ cuda \ for_each.inl(93):错误C2027:使用未定义的类型'thrust::detail::STATIC_ASSERTION_FAILURE'
1>与
1> [
1> x = false
1>]
1> c:\ program files \ nvidia gpu计算工具包\ cuda \ v4.0 \ include \ thrust \ detail \ device \ dispatch \ for_each.h(56):请参见对函数模板实例化“RandomAccessIterator推力:: detail::”的引用device::cuda::for_each_n(RandomAccessIterator,Size,UnaryFunction)'正在编译
1>与
1> [
1> RandomAccessIterator = thrust::detail::normal_iterator>,
1>大小= __ w64 int,
1> UnaryFunction = thrust::detail::device_destroy_functor
1>]
1> c:\ program files \ nvidia gpu计算工具包\ cuda \ v4.0 \ include \ thrust \ detail \ device \ for_each.inl(43):请参见对功能模板实例化的引用'RandomAccessIterator推力:: detail::device: :dispatch::for_each_n(RandomAccessIterator,Size,UnaryFunction,thrust::detail::cuda_device_space_tag)'正在编译
1>与
1> [
1> RandomAccessIterator = thrust::detail::normal_iterator>,
1> OutputIterator = thrust::detail::normal_iterator>,
1>大小= __ w64 int,
1> UnaryFunction = thrust::detail::device_destroy_functor
1>]
1> c:\ program files \ nvidia gpu计算工具包\ cuda \ v4.0 \ include \ thrust \ detail \ device \ for_each.inl(54):请参见对功能模板实例化的引用'OutputIterator推力:: detail::device: :for_each_n(OutputIterator,Size,UnaryFunction)'正在编译
1>与
1> [
1> OutputIterator = thrust::detail::normal_iterator>,
1> InputIterator = thrust::detail::normal_iterator>,
1> UnaryFunction = thrust::detail::device_destroy_functor,
1>大小= __ w64 int
1>]
1> c:\ program files \ nvidia gpu计算工具包\ cuda \ v4.0 \ include \ thrust \ detail \ dispatch \ for_each.h(72):请参见对功能模板实例化的引用'InputIterator推力:: detail::device: :for_each(InputIterator,InputIterator,UnaryFunction)'正在编译
1>与
1> [
1> InputIterator = thrust::detail::normal_iterator>,
1> UnaryFunction = thrust::detail::device_destroy_functor
1>]
1> c:\ program files \ nvidia gpu计算工具包\ cuda \ v4.0 \ include \ thrust \ detail \ for_each.inl(51):请参见对函数模板实例化的引用'InputIterator推力:: detail::dispatch::for_each (InputIterator,InputIterator,UnaryFunction,thrust::device_space_tag)'正在编译
1>与
1> [
1> InputIterator = thrust::detail::normal_iterator>,
1> UnaryFunction = thrust::detail::device_destroy_functor
1>]
1> c:\ program files \ nvidia gpu计算工具包\ cuda \ v4.0 \ include \ thrust \ detail \ for_each.inl(67):请参见对函数模板实例化的引用'InputIterator推力:: detail::for_each(InputIterator, InputIterator,UnaryFunction)'正在编译
1>与
1> [
1> InputIterator = thrust::detail::normal_iterator>,
1> UnaryFunction = thrust::detail::device_destroy_functor
1>]
1> c:\ program files \ nvidia gpu计算工具包\ cuda \ v4.0 \ include \ thrust \ detail \ dispatch \ destroy.h(59):请参见对函数模板实例化的引用'void推力:: for_each>(InputIterator, InputIterator,UnaryFunction)'正在编译
1>与
1> [
1> ForwardIterator = thrust::detail::normal_iterator>,
1> T = value_type,
1> InputIterator = thrust::detail::normal_iterator>,
1> UnaryFunction = thrust::detail::device_destroy_functor
1>]
1> c:\ program files \ nvidia gpu计算工具包\ cuda \ v4.0 \ include \ thrust \ detail \ destroy.h(42):请参见对函数模板实例化的引用'void推力:: detail::dispatch::destroy (ForwardIterator,ForwardIterator,thrust::detail::false_type)'正在编译
1>与
1> [
1> ForwardIterator =推力::细节::正常迭代器>
1>]
1> c:\ program files \ nvidia gpu计算工具包\ cuda \ v4.0 \ include \ thrust \ detail \ vector_base.inl(442):请参见对函数模板实例化的引用'void推力:: detail::destroy>(ForwardIterator ,ForwardIterator)'正在编译
1>与
1> [
1> Pointer = thrust::device_ptr,
1> ForwardIterator =推力::细节::正常迭代器>
1>]
1> c:\ program files \ nvidia gpu计算工具包\ cuda \ v4.0 \ include \ thrust \ detail \ vector_base.inl(440):在编译类模板成员函数'thrust::detail::vector_base::〜vector_base时(无效)”
1>与
1> [
1> T = std::string,
1> Alloc = thrust::device_malloc_allocator
1>]
1> c:\ program files \ nvidia gpu计算工具包\ cuda \ v4.0 \ include \ thrust \ device_vector.h(55):请参见对正在编译的类模板实例化“thrust::detail::vector_base”的引用
1>与
1> [
1> T = std::string,
1> Alloc = thrust::device_malloc_allocator
1>]
1> c:\ users \ fsquared \ mydata \ idata \ main.cpp(119):请参见对正在编译的类模板实例化“thrust::device_vector”的引用
1>与
1> [
1> T = std::string
1>]
==========构建:0成功,1失败,0最新,跳过0 ==========

我在这里使用MSCV 2010。

最佳答案

CUDA在设备代码中不支持标准C++容器类型,它基本上仅限于C++ POD类型。您可以定义自己的类以在GPU上使用,但是构造函数和成员函数必须定义为CUDA __device__函数,并且设备代码支持哪些语言功能仍然存在许多限制。

关于c++ - NVidia推力device_vector的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5931466/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com