I’m pretty sure the following code should work / compile
#include <thrust/scatter.h>
#include <thrust/device_vector.h>
#include <thrust/sequence.h>
int main(void) {
thrust::device_vector<unsigned int> map(10);
thrust::sequence(map.begin(), map.end(), 0);
thrust::device_vector<unsigned int> output(10);
thrust::scatter(thrust::make_counting_iterator(0), thrust::make_counting_iterator(10),
map.begin(), output.begin());
return 0;
}
however it doesn’t compile for me with the following error message:
/usr/local/cuda/bin/../include/thrust/detail/scatter.inl(38): error: more than one instance of overloaded function "thrust::detail::dispatch::scatter" matches the argument list:
function template "void thrust::detail::dispatch::scatter(InputIterator1, InputIterator1, InputIterator2, RandomAccessIterator, thrust::device_space_tag, thrust::device_space_tag, thrust::device_space_tag)"
function template "void thrust::detail::dispatch::scatter(InputIterator1, InputIterator1, InputIterator2, RandomAccessIterator, thrust::host_space_tag, thrust::device_space_tag, thrust::device_space_tag)"
argument types are: (thrust::counting_iterator<int, thrust::use_default, thrust::use_default, thrust::use_default>, thrust::counting_iterator<int, thrust::use_default, thrust::use_default, thrust::use_default>, thrust::detail::normal_iterator<thrust::device_ptr<unsigned int>>, thrust::detail::normal_iterator<thrust::device_ptr<unsigned int>>, thrust::any_space_tag, thrust::device_space_tag, thrust::device_space_tag)
detected during instantiation of "void thrust::scatter(InputIterator1, InputIterator1, InputIterator2, RandomAccessIterator) [with InputIterator1=thrust::counting_iterator<int, thrust::use_default, thrust::use_default, thrust::use_default>, InputIterator2=thrust::detail::normal_iterator<thrust::device_ptr<unsigned int>>, RandomAccessIterator=thrust::detail::normal_iterator<thrust::device_ptr<unsigned int>>]"
scatter.cu(10): here
This is easy to workaround by using a sequence as input instead of a counting iterator, but it is theoretically less efficient.