Я пытаюсь секционировать массив с помощью функции partition_copy библиотеки thrust.
Я видел примеры, когда передаются указатели, но мне нужно знать, сколько элементов в каждом разделе.
Я пытался передать векторы устройств в качестве параметров OutputIterator, что-то вроде этого:
#include <thrust/device_vector.h>
#include <thrust/device_ptr.h>
#include <thrust/partition.h>
struct is_even {
__host__ __device__ bool operator()(const int &x) {
return (x % 2) == 0;
}
};
int N;
int *d_data;
cudaMalloc(&d_data, N*sizeof(int));
//... Some data is put in the d_data array
thrust::device_ptr<int> dptr_data(d_data);
thrust::device_vector<int> out_true(N);
thrust::device_vector<int> out_false(N);
thrust::partition_copy(dptr_data, dptr_data + N, out_true, out_false, is_even());
Когда я пытаюсь скомпилировать, я получаю эту ошибку:
error: class "thrust::iterator_system<thrust::device_vector<int, thrust::device_allocator<int>>>" has no member "type"
detected during instantiation of "thrust::pair<OutputIterator1, OutputIterator2> thrust::partition_copy(InputIterator, InputIterator, OutputIterator1, OutputIterator2, Predicate) [with InputIterator=thrust::device_ptr<int>, OutputIterator1=thrust::device_vector<int, thrust::device_allocator<int>>, OutputIterator2=thrust::device_vector<int, thrust::device_allocator<int>>, Predicate=leq]"
Итак, мой вопрос is: Как вы можете использовать thrust :: partition или thrust :: partition_copy и узнать, сколько элементов вы получили в каждом разделе?