17 #ifndef BOLT_ADDRESSOF_H
18 #define BOLT_ADDRESSOF_H
20 #include <bolt/cl/iterator/permutation_iterator.h>
21 #include <bolt/cl/iterator/transform_iterator.h>
28 template <
typename Iterator>
29 typename Iterator::value_type * addressof(Iterator itr)
31 return std::addressof(*itr);
40 template <
typename UnaryFunction,
typename Iterator>
41 typename bolt::cl::transform_iterator<UnaryFunction, Iterator>::pointer
44 typedef typename bolt::cl::transform_iterator<UnaryFunction, Iterator>::pointer pointer;
45 pointer ptr =
const_cast<pointer
>(itr.getPointer());
49 template <
typename value_type>
50 typename bolt::cl::counting_iterator<value_type>::pointer
53 typedef typename bolt::cl::counting_iterator<value_type>::pointer pointer;
54 pointer ptr =
const_cast<pointer
>(itr.getPointer() );
58 template <
typename value_type>
59 typename bolt::cl::constant_iterator<value_type>::pointer
62 typedef typename bolt::cl::constant_iterator<value_type>::pointer pointer;
63 pointer ptr =
const_cast<pointer
>(itr.getPointer() );
67 template <
typename Iterator,
typename DeviceIterator>
71 typedef typename Iterator::unary_func unary_func;
75 template <
typename Iterator,
typename DeviceIterator>
77 create_device_itr(std::random_access_iterator_tag, Iterator itr, DeviceIterator dev_itr_1)
82 template <
typename T,
typename DeviceIterator>
84 create_device_itr(std::random_access_iterator_tag, T* ptr, DeviceIterator dev_itr_1)
89 template <
typename Iterator,
typename DeviceIterator>
90 const constant_iterator<typename Iterator::value_type>
96 template <
typename Iterator,
typename DeviceIterator>
97 const counting_iterator<typename Iterator::value_type>
105 template <
typename Iterator,
typename T>
109 typedef typename Iterator::unary_func unary_func;
113 template <
typename Iterator,
typename T>
117 return ptr + itr.m_Index;
123 template <
typename Iterator,
typename T>
124 const constant_iterator<typename Iterator::value_type> &
130 template <
typename Iterator,
typename T>
131 const counting_iterator<typename Iterator::value_type> &
137 template <
typename Iterator,
typename T>
138 const permutation_iterator<typename Iterator::value_type*, typename Iterator::index_type*>
141 typedef typename Iterator::value_type value_type;
142 typedef typename Iterator::index_type index_type;
143 index_type *i_ptr = ptr;
144 ::cl::Buffer elementBuffer = itr.m_elt_iter.getContainer( ).getBuffer( );
145 size_t elementBuffer_sz = elementBuffer.getInfo<CL_MEM_SIZE>();
147 value_type *mapped_elementPtr = (value_type*)ctl.getCommandQueue().enqueueMapBuffer(elementBuffer,
true,
150 NULL, NULL, &map_err);
152 return bolt::cl::make_permutation_iterator (mapped_elementPtr, i_ptr);