NVidia Thrust device_vector of strings - PullRequest
1 голос
/ 09 мая 2011

Я начал использовать библиотеку 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, должен использоваться в векторе тяги независимо от того, устройство это или хост? Или здесь есть ограничения, и я не должен ожидать, что это сработает?

Я получаю следующую ошибку:

c: \ program files \ nvidia gpu compuit toolkit \ cuda \ v4.0 \ include \ thrust \ detail \ device \ cuda \ for_each.inl (93): ошибка C2027: использование неопределенного типа 'thrust :: detail: : STATIC_ASSERTION_FAILURE» 1> с 1> [ 1> х = ложь 1>] 1> c: \ program files \ nvidia gpu compuitkit \ cuda \ v4.0 \ include \ thrust \ detail \ device \ dispatch \ for_each.h (56): см. Ссылку на создание экземпляра шаблона функции 'RandomAccessIterator thrust :: detail :: устройство :: 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 compuitkit \ cuda \ v4.0 \ include \ thrust \ detail \ device \ for_each.inl (43): см. Ссылку на создание экземпляра шаблона функции 'RandomAccessIterator thrust :: 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 compuitkit \ cuda \ v4.0 \ include \ thrust \ detail \ device \ for_each.inl (54): см. Ссылку на создание экземпляра шаблона функции 'OutputIterator thrust :: 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 compuit toolkit \ cuda \ v4.0 \ include \ thrust \ detail \ dispatch \ for_each.h (72): см. Ссылку на создание экземпляра шаблона функции 'InputIterator thrust :: 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 compuitkit \ cuda \ v4.0 \ include \ thrust \ detail \ for_each.inl (51): см. Ссылку на создание экземпляра шаблона функции 'InputIterator thrust :: 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 compuitkit \ cuda \ v4.0 \ include \ thrust \ detail \ for_each.inl (67): см. Ссылку на создание экземпляра шаблона функции 'InputIterator thrust :: 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 compuitkit \ cuda \ v4.0 \ include \ thrust \ detail \ dispatch \ destroy.h (59): см. Ссылку на создание экземпляра шаблона функции 'void thrust :: 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 compuititit \ cuda \ v4.0 \ include \ thrust \ detail \ destroy.h (42): см. ссылку на создание шаблона функции 'void thrust:: detail :: dispatch :: destroy (ForwardIterator, ForwardIterator, thrust :: detail :: false_type) 'компилируется 1> с 1> [1> ForwardIterator = thrust :: detail :: normal_iterator> 1>] 1> c:\ program files \ nvidia gpu computing toolkit \ cuda \ v4.0 \ include \ thrust \ detail \ vector_base.inl (442): см. ссылку на создание экземпляра шаблона функции 'void thrust :: detail :: destroy> (ForwardIterator, ForwardIterator)'компилируется 1>с 1> [1> Pointer = thrust :: device_ptr, 1> ForwardIterator = thrust :: detail :: normal_iterator> 1>] 1> c: \ программные файлы \ nvidia gpu для вычислительных инструментов \ cuda \ v4.0 \ include \ thrust\ detail \ vector_base.inl (440): при компиляции функции-члена шаблона класса 'thrust :: detail :: vector_base :: ~ vector_base (void)' 1> с 1> [1> T = std :: string, 1> Alloc= thrust :: device_malloc_allocator 1>] 1> c: \ program files \ nvidia gpu compuititit \ 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 здесь.

1 Ответ

2 голосов
/ 09 мая 2011

CUDA не поддерживает стандартные типы контейнеров C ++ в коде устройства, в основном он ограничен только типами POD C ++. Вы можете определить свои собственные классы для использования в графическом процессоре, но функции конструктора и члена должны быть определены как функции CUDA __device__, и все еще существует ряд ограничений на то, какие языковые функции поддерживаются в коде устройства.

...