OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
cub::CacheModifiedInputIterator< MODIFIER, ValueType, OffsetT > Class Template Reference

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

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
  • CacheModifiedInputIteratorTis 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 CacheModifiedInputIteratorTto 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
A random-access input wrapper for dereferencing array values using a PTX cache load modifier.
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)

Definition at line 107 of file cache_modified_input_iterator.cuh.

Public Types

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

Public Member Functions

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

Data Fields

ValueType * ptr
 Wrapped native pointer.
 

Friends

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

Member Typedef Documentation

◆ difference_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.

Definition at line 113 of file cache_modified_input_iterator.cuh.

◆ iterator_category

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.

Definition at line 127 of file cache_modified_input_iterator.cuh.

◆ pointer

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.

Definition at line 115 of file cache_modified_input_iterator.cuh.

◆ reference

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.

Definition at line 116 of file cache_modified_input_iterator.cuh.

◆ self_type

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

My own type.

Definition at line 112 of file cache_modified_input_iterator.cuh.

◆ value_type

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.

Definition at line 114 of file cache_modified_input_iterator.cuh.

Constructor & Destructor Documentation

◆ CacheModifiedInputIterator()

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

Definition at line 138 of file cache_modified_input_iterator.cuh.

Member Function Documentation

◆ operator!=()

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.

Definition at line 223 of file cache_modified_input_iterator.cuh.

◆ operator*()

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

Indirection.

Definition at line 160 of file cache_modified_input_iterator.cuh.

◆ operator+()

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.

Definition at line 167 of file cache_modified_input_iterator.cuh.

◆ operator++() [1/2]

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

Prefix increment.

Definition at line 153 of file cache_modified_input_iterator.cuh.

◆ operator++() [2/2]

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

Postfix increment.

Definition at line 145 of file cache_modified_input_iterator.cuh.

◆ operator+=()

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.

Definition at line 175 of file cache_modified_input_iterator.cuh.

◆ operator-() [1/2]

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.

Definition at line 183 of file cache_modified_input_iterator.cuh.

◆ operator-() [2/2]

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.

Definition at line 198 of file cache_modified_input_iterator.cuh.

◆ operator-=()

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.

Definition at line 191 of file cache_modified_input_iterator.cuh.

◆ operator->()

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

Structure dereference.

Definition at line 211 of file cache_modified_input_iterator.cuh.

◆ operator==()

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.

Definition at line 217 of file cache_modified_input_iterator.cuh.

◆ operator[]()

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.

Definition at line 205 of file cache_modified_input_iterator.cuh.

Friends And Related Symbol Documentation

◆ operator<<

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

ostream operator

Definition at line 229 of file cache_modified_input_iterator.cuh.

Field Documentation

◆ ptr

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

Wrapped native pointer.

Definition at line 134 of file cache_modified_input_iterator.cuh.


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