CUB  
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Methods | Public Members | Friends | List of all members
cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT > Class Template Reference

Detailed description

template< CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
class cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >

A random-access input wrapper for dereferencing array values using a PTX cache load modifier.

Overview
  • CacheModifiedInputIterator is a random-access input iterator that wraps a native device pointer of type ValueType*. ValueType references are made by reading ValueType values through loads modified by MODIFIER.
  • Can be used to load any data type from memory using PTX cache load modifiers (e.g., "LOAD_LDG", "LOAD_CG", "LOAD_CA", "LOAD_CS", "LOAD_CV", etc.).
  • Can be constructed, manipulated, and exchanged within and between host and device functions, but can only be dereferenced within device functions.
  • Compatible with Thrust API v1.7 or newer.
Snippet
The code snippet below illustrates the use of CacheModifiedInputIterator to dereference a device array of double using the "ldg" PTX load modifier (i.e., load values through texture cache).
#include <cub/cub.cuh> // or equivalently <cub/iterator/cache_modified_input_iterator.cuh>
// Declare, allocate, and initialize a device array
double *d_in; // e.g., [8.0, 6.0, 7.0, 5.0, 3.0, 0.0, 9.0]
// Create an iterator wrapper
// Within device code:
printf("%f\n", itr[0]); // 8.0
printf("%f\n", itr[1]); // 6.0
printf("%f\n", itr[6]); // 9.0
Template Parameters
CacheLoadModifierThe cub::CacheLoadModifier to use when accessing data
ValueTypeThe value type of this iterator
OffsetTThe difference type of this iterator (Default: ptrdiff_t)

Public Types

typedef CacheModifiedInputIterator self_type
 My own type. More...
 
typedef OffsetT difference_type
 Type to express the result of subtracting one iterator from another. More...
 
typedef ValueType value_type
 The type of the element the iterator can point to. More...
 
typedef ValueType * pointer
 The type of a pointer to an element the iterator can point to. More...
 
typedef ValueType reference
 The type of a reference to an element the iterator can point to. More...
 
typedef
std::random_access_iterator_tag 
iterator_category
 The iterator category. More...
 

Public Methods

template<typename QualifiedValueType >
__host__ __device__ __forceinline__ CacheModifiedInputIterator (QualifiedValueType *ptr)
 Constructor. More...
 
__host__ __device__
__forceinline__ self_type 
operator++ (int)
 Postfix increment. More...
 
__host__ __device__
__forceinline__ self_type 
operator++ ()
 Prefix increment. More...
 
__device__ __forceinline__
reference 
operator* () const
 Indirection. More...
 
template<typename Distance >
__host__ __device__
__forceinline__ self_type 
operator+ (Distance n) const
 Addition. More...
 
template<typename Distance >
__host__ __device__
__forceinline__ self_type
operator+= (Distance n)
 Addition assignment. More...
 
template<typename Distance >
__host__ __device__
__forceinline__ self_type 
operator- (Distance n) const
 Subtraction. More...
 
template<typename Distance >
__host__ __device__
__forceinline__ self_type
operator-= (Distance n)
 Subtraction assignment. More...
 
__host__ __device__
__forceinline__
difference_type 
operator- (self_type other) const
 Distance. More...
 
template<typename Distance >
__device__ __forceinline__
reference 
operator[] (Distance n) const
 Array subscript. More...
 
__device__ __forceinline__ pointer operator-> ()
 Structure dereference. More...
 
__host__ __device__
__forceinline__ bool 
operator== (const self_type &rhs)
 Equal to. More...
 
__host__ __device__
__forceinline__ bool 
operator!= (const self_type &rhs)
 Not equal to. More...
 

Public Members

ValueType * ptr
 Wrapped native pointer. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const self_type &)
 ostream operator More...
 

Member Typedef Documentation

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
typedef CacheModifiedInputIterator cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::self_type

My own type.

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
typedef OffsetT cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::difference_type

Type to express the result of subtracting one iterator from another.

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
typedef ValueType cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::value_type

The type of the element the iterator can point to.

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
typedef ValueType* cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::pointer

The type of a pointer to an element the iterator can point to.

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
typedef ValueType cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::reference

The type of a reference to an element the iterator can point to.

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
typedef std::random_access_iterator_tag cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::iterator_category

The iterator category.

Constructor & Destructor Documentation

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
template<typename QualifiedValueType >
__host__ __device__ __forceinline__ cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::CacheModifiedInputIterator ( QualifiedValueType *  ptr)
inline

Constructor.

Parameters
ptrNative pointer to wrap

Member Function Documentation

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ self_type cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::operator++ ( int  )
inline

Postfix increment.

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ self_type cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::operator++ ( )
inline

Prefix increment.

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
__device__ __forceinline__ reference cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::operator* ( ) const
inline

Indirection.

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
template<typename Distance >
__host__ __device__ __forceinline__ self_type cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::operator+ ( Distance  n) const
inline

Addition.

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
template<typename Distance >
__host__ __device__ __forceinline__ self_type& cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::operator+= ( Distance  n)
inline

Addition assignment.

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
template<typename Distance >
__host__ __device__ __forceinline__ self_type cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::operator- ( Distance  n) const
inline

Subtraction.

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
template<typename Distance >
__host__ __device__ __forceinline__ self_type& cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::operator-= ( Distance  n)
inline

Subtraction assignment.

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ difference_type cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::operator- ( self_type  other) const
inline

Distance.

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
template<typename Distance >
__device__ __forceinline__ reference cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::operator[] ( Distance  n) const
inline

Array subscript.

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
__device__ __forceinline__ pointer cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::operator-> ( )
inline

Structure dereference.

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ bool cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::operator== ( const self_type rhs)
inline

Equal to.

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ bool cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::operator!= ( const self_type rhs)
inline

Not equal to.

Friends And Related Function Documentation

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
std::ostream& operator<< ( std::ostream &  os,
const self_type  
)
friend

ostream operator

Member Data Documentation

template<CacheLoadModifier MODIFIER, typename ValueType, typename OffsetT = ptrdiff_t>
ValueType* cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT >::ptr

Wrapped native pointer.


The documentation for this class was generated from the following file: