Go to the documentation of this file.
6 #ifndef OPENMPCD_CUDA_STRIDEDITERATORRANGE_HPP
7 #define OPENMPCD_CUDA_STRIDEDITERATORRANGE_HPP
11 #include <boost/static_assert.hpp>
12 #include <thrust/functional.h>
13 #include <thrust/iterator/counting_iterator.h>
14 #include <thrust/iterator/permutation_iterator.h>
15 #include <thrust/iterator/transform_iterator.h>
45 template<
typename UnderlyingIterator,
unsigned int str
ide = 0>
49 BOOST_STATIC_ASSERT(stride != 0);
53 typename thrust::iterator_difference<UnderlyingIterator>::type
61 :
public thrust::unary_function<IteratorDifference, IteratorDifference>
81 typename thrust::counting_iterator<IteratorDifference>
85 typename thrust::transform_iterator<StrideFunctor, CountingIterator>
89 typename thrust::permutation_iterator<
105 const UnderlyingIterator& start,
const UnderlyingIterator& pastTheEnd_)
106 : first(start), pastTheEnd(pastTheEnd_)
125 return begin() + ((pastTheEnd - first) + (stride - 1)) / stride;
129 UnderlyingIterator first;
130 UnderlyingIterator pastTheEnd;
139 template<
typename UnderlyingIterator>
145 typename thrust::iterator_difference<UnderlyingIterator>::type
153 :
public thrust::unary_function<IteratorDifference, IteratorDifference>
180 const unsigned int stride;
184 typename thrust::counting_iterator<IteratorDifference>
188 typename thrust::transform_iterator<StrideFunctor, CountingIterator>
192 typename thrust::permutation_iterator<
209 const UnderlyingIterator& start,
const UnderlyingIterator& pastTheEnd_,
210 const unsigned int stride_)
211 : first(start), pastTheEnd(pastTheEnd_), stride(stride_)
231 return begin() + ((pastTheEnd - first) + (stride - 1)) / stride;
235 UnderlyingIterator first;
236 UnderlyingIterator pastTheEnd;
237 const unsigned int stride;
Iterator begin() const
Returns the first iterator in the strided range.
Functor class for advancing a pointer by the given stride.
thrust::iterator_difference< UnderlyingIterator >::type IteratorDifference
The type of the difference of two of the underlying iterators.
#define OPENMPCD_CUDA_HOST_AND_DEVICE
Denotes a function to be callable both from the Host and from a CUDA Device.
Iterator end() const
Returns the first past-the-end iterator of the strided range.
Iterator begin() const
Returns the first iterator in the strided range.
thrust::permutation_iterator< UnderlyingIterator, TransformIterator > PermutationIterator
Type that will be indexing into the UnderlyingIterator according to the TransformIterator.
PermutationIterator Iterator
The effective iterator type.
PermutationIterator Iterator
The effective iterator type.
const OPENMPCD_CUDA_HOST_AND_DEVICE IteratorDifference operator()(const IteratorDifference &i) const
Calculates how many times the underlying iterator has to be incremented to achieve i increments of th...
thrust::transform_iterator< StrideFunctor, CountingIterator > TransformIterator
Type that applies StrideFunctor to the input sequence.
thrust::permutation_iterator< UnderlyingIterator, TransformIterator > PermutationIterator
Type that will be indexing into the UnderlyingIterator according to the TransformIterator.
thrust::transform_iterator< StrideFunctor, CountingIterator > TransformIterator
Type that applies StrideFunctor to the input sequence.
thrust::iterator_difference< UnderlyingIterator >::type IteratorDifference
The type of the difference of two of the underlying iterators.
StrideFunctor(const unsigned int s)
The constructor.
thrust::counting_iterator< IteratorDifference > CountingIterator
Type that is used to linearly increment a count.
Wraps an iterator range such that the iteration stride is not (necessarily) 1.
StridedIteratorRange(const UnderlyingIterator &start, const UnderlyingIterator &pastTheEnd_, const unsigned int stride_)
The constructor.
const IteratorDifference operator()(const IteratorDifference &i) const
Calculates how many times the underlying iterator has to be incremented to achieve i increments of th...
thrust::counting_iterator< IteratorDifference > CountingIterator
Type that is used to linearly increment a count.
StridedIteratorRange(const UnderlyingIterator &start, const UnderlyingIterator &pastTheEnd_)
The constructor.
Iterator end() const
Returns the first past-the-end iterator of the strided range.