31 #if defined(__CUDACC__) 32 #include <cub/cub.cuh> 35 #include <cugar/basic/types.h> 36 #include <cugar/basic/iterator.h> 74 #if defined(__CUDACC__) 75 template <CacheLoadModifier MOD>
struct cub_load_mod {};
85 template <CacheStoreModifier MOD>
struct cub_store_mod {};
97 template <CacheLoadModifier LOAD_MOD,
typename T>
98 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
101 #if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 350 102 return cub::ThreadLoad<cub_load_mod<LOAD_MOD>::MOD>(
const_cast<T*
>(ptr) );
110 template <CacheStoreModifier STORE_MOD,
typename T>
111 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
114 #if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 350 115 cub::ThreadStore<cub_store_mod<STORE_MOD>::MOD>( ptr, value );
124 template <
typename T, CacheLoadModifier MOD>
127 typedef T value_type;
128 typedef value_type reference;
129 typedef value_type const_reference;
130 typedef value_type* pointer;
131 typedef typename std::iterator_traits<const T*>::difference_type difference_type;
132 typedef std::random_access_iterator_tag iterator_category;
136 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
141 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
146 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
151 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
154 return load<MOD>( m_base + i );
159 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
162 return load<MOD>( m_base );
167 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
176 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
186 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
195 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
205 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
213 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
221 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
230 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
239 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
242 return m_base - it.m_base;
247 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
259 template <CacheLoadModifier MOD,
typename T>
260 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
269 template <
typename T, CacheStoreModifier STORE_MOD, CacheLoadModifier LOAD_MOD = LOAD_DEFAULT>
272 typedef T value_type;
276 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
281 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
286 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
291 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
294 store<STORE_MOD>( m_base, value );
300 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
301 operator value_type()
303 return load<LOAD_MOD>( m_base );
308 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
311 const value_type old = load<LOAD_MOD>( m_base );
312 store<STORE_MOD>( m_base, old + value );
318 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
321 const value_type old = load<LOAD_MOD>( m_base );
322 store<STORE_MOD>( m_base, old - value );
332 template <
typename T, CacheStoreModifier STORE_MOD, CacheLoadModifier LOAD_MOD = LOAD_DEFAULT>
335 typedef T value_type;
337 typedef value_type const_reference;
338 typedef value_type* pointer;
339 typedef typename std::iterator_traits<T*>::difference_type difference_type;
340 typedef std::random_access_iterator_tag iterator_category;
344 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
349 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
354 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
359 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
362 return reference( m_base + i );
367 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
370 return reference( m_base );
375 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
384 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
394 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
403 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
413 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
421 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
429 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
438 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
447 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
450 return m_base - it.m_base;
455 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
467 template <CacheStoreModifier STORE_MOD, CacheLoadModifier LOAD_MOD,
typename T>
468 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
Cache at global level.
Definition: pointers.h:54
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_pointer< T, STORE_MOD, LOAD_MOD > operator++(int i)
Definition: pointers.h:385
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE load_pointer(const T *base)
Definition: pointers.h:142
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_pointer()
Definition: pointers.h:345
CacheStoreModifier
Enumeration of cache modifiers for memory load operations.
Definition: pointers.h:64
Definition: pointers.h:125
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE load_pointer< T, MOD > & operator-=(const difference_type i)
Definition: pointers.h:231
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_reference & operator+=(const value_type value)
Definition: pointers.h:309
Cache as volatile (including cached system lines)
Definition: pointers.h:56
Cache streaming (likely to be accessed once)
Definition: pointers.h:69
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE load_pointer< T, MOD > & operator++()
Definition: pointers.h:168
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE T load(const T *ptr)
Definition: pointers.h:99
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE load_pointer< T, MOD > operator+(const difference_type i) const
Definition: pointers.h:206
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE load_pointer()
Definition: pointers.h:137
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE load_pointer< T, MOD > operator--(int i)
Definition: pointers.h:196
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE load_pointer & operator=(const load_pointer< T, MOD > &it)
Definition: pointers.h:248
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_pointer< T, STORE_MOD, LOAD_MOD > operator--(int i)
Definition: pointers.h:404
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_pointer< T, STORE_MOD, LOAD_MOD > & operator+=(const difference_type i)
Definition: pointers.h:430
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_reference(T *base)
Definition: pointers.h:282
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_reference & operator-=(const value_type value)
Definition: pointers.h:319
Volatile shared (any memory space)
Definition: pointers.h:71
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_pointer< T, STORE_MOD, LOAD_MOD > operator+(const difference_type i) const
Definition: pointers.h:414
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_reference & operator=(const value_type value)
Definition: pointers.h:292
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE load_pointer< T, MOD > operator++(int i)
Definition: pointers.h:177
Default (no modifier)
Definition: pointers.h:52
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE reference operator[](const uint32 i)
Definition: pointers.h:360
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_pointer(T *base)
Definition: pointers.h:350
Cache as texture.
Definition: pointers.h:57
Cache at all levels.
Definition: pointers.h:53
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_reference()
Definition: pointers.h:277
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE load_pointer< T, MOD > make_load_pointer(const T *it)
Definition: pointers.h:261
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_pointer< T, STORE_MOD, LOAD_MOD > & operator-=(const difference_type i)
Definition: pointers.h:439
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE reference operator*()
Definition: pointers.h:368
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_pointer< T, STORE_MOD, LOAD_MOD > & operator--()
Definition: pointers.h:395
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE value_type operator*() const
Definition: pointers.h:160
Definition: pointers.h:333
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_pointer< T, STORE_MOD, LOAD_MOD > operator-(const difference_type i) const
Definition: pointers.h:422
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE void store(T *ptr, const T &value)
Definition: pointers.h:112
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_pointer< T, STORE_MOD, LOAD_MOD > & operator++()
Definition: pointers.h:376
Default (no modifier)
Definition: pointers.h:66
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_reference(const store_reference &it)
Definition: pointers.h:287
CacheLoadModifier
Enumeration of cache modifiers for memory load operations.
Definition: pointers.h:50
Cache write-through (to system memory)
Definition: pointers.h:70
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE difference_type operator-(const load_pointer< T, MOD > it) const
Definition: pointers.h:240
Define a vector_view POD type and plain_view() for std::vector.
Definition: diff.h:38
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE load_pointer< T, MOD > & operator+=(const difference_type i)
Definition: pointers.h:222
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_pointer< T, STORE_MOD, LOAD_MOD > make_store_pointer(const T *it)
Definition: pointers.h:469
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE load_pointer< T, MOD > operator-(const difference_type i) const
Definition: pointers.h:214
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE difference_type operator-(const store_pointer< T, STORE_MOD, LOAD_MOD > it) const
Definition: pointers.h:448
Volatile (any memory space)
Definition: pointers.h:58
Cache streaming (likely to be accessed once)
Definition: pointers.h:55
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_pointer & operator=(const store_pointer< T, STORE_MOD, LOAD_MOD > &it)
Definition: pointers.h:456
Cache at global level.
Definition: pointers.h:68
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE load_pointer(const load_pointer &it)
Definition: pointers.h:147
Definition: pointers.h:270
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE value_type operator[](const uint32 i) const
Definition: pointers.h:152
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE load_pointer< T, MOD > & operator--()
Definition: pointers.h:187
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE store_pointer(const store_pointer &it)
Definition: pointers.h:355
Cache write-back all coherent levels.
Definition: pointers.h:67