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

A random-access input wrapper for dereferencing array values through texture cache. Uses newer Kepler-style texture objects. More...

Detailed Description

template<typename T, typename OffsetT = ptrdiff_t>
class cub::TexObjInputIterator< T, OffsetT >

A random-access input wrapper for dereferencing array values through texture cache. Uses newer Kepler-style texture objects.

Overview
  • TexObjInputIteratorTwraps a native device pointer of type ValueType*. References to elements are to be loaded through texture cache.
  • Can be used to load any data type from memory through texture cache.
  • Can be manipulated and exchanged within and between host and device functions, can only be constructed within host functions, and can only be dereferenced within device functions.
  • With regard to nested/dynamic parallelism, TexObjInputIteratorTiterators may only be created by the host thread, but can be used by any descendant kernel.
  • Compatible with Thrust API v1.7 or newer.
Snippet
The code snippet below illustrates the use of TexRefInputIteratorTto dereference a device array of doubles through texture cache.
#include <cub/cub.cuh> // or equivalently <cub/iterator/tex_obj_input_iterator.cuh>
// Declare, allocate, and initialize a device array
int num_items; // e.g., 7
double *d_in; // e.g., [8.0, 6.0, 7.0, 5.0, 3.0, 0.0, 9.0]
// Create an iterator wrapper
itr.BindTexture(d_in, sizeof(double) * num_items);
...
// Within device code:
printf("%f\n", itr[0]); // 8.0
printf("%f\n", itr[1]); // 6.0
printf("%f\n", itr[6]); // 9.0
...
itr.UnbindTexture();
A random-access input wrapper for dereferencing array values through texture cache....
cudaError_t BindTexture(QualifiedT *ptr, size_t bytes=size_t(-1), size_t tex_offset=0)
Use this iterator to bind ptr with a texture reference.
KeyT const ValueT ValueT OffsetT OffsetT num_items
[in] Total number of input data items
Template Parameters
TThe value type of this iterator
OffsetTThe difference type of this iterator (Default: ptrdiff_t)

Definition at line 111 of file tex_obj_input_iterator.cuh.

Public Types

typedef TexObjInputIterator self_type
 My own type.
 
typedef OffsetT difference_type
 Type to express the result of subtracting one iterator from another.
 
typedef T value_type
 The type of the element the iterator can point to.
 
typedef T * pointer
 The type of a pointer to an element the iterator can point to.
 
typedef T 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

__host__ __device__ __forceinline__ TexObjInputIterator ()
 Constructor.
 
template<typename QualifiedT >
cudaError_t BindTexture (QualifiedT *ptr, size_t bytes=size_t(-1), size_t tex_offset=0)
 Use this iterator to bind ptr with a texture reference.
 
cudaError_t UnbindTexture ()
 Unbind this iterator from its texture reference.
 
__host__ __device__ __forceinline__ self_type operator++ (int)
 Postfix increment.
 
__host__ __device__ __forceinline__ self_type operator++ ()
 Prefix increment.
 
__host__ __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 >
__host__ __device__ __forceinline__ reference operator[] (Distance n) const
 Array subscript.
 
__host__ __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.
 

Private Types

enum  { TEXTURE_MULTIPLE = sizeof(T) / sizeof(TextureWord) }
 
typedef UnitWord< T >::TextureWord TextureWord
 

Private Attributes

T * ptr
 
difference_type tex_offset
 
cudaTextureObject_t tex_obj
 

Friends

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

Member Typedef Documentation

◆ difference_type

template<typename T , typename OffsetT = ptrdiff_t>
typedef OffsetT cub::TexObjInputIterator< T, OffsetT >::difference_type

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

Definition at line 117 of file tex_obj_input_iterator.cuh.

◆ iterator_category

template<typename T , typename OffsetT = ptrdiff_t>
typedef std::random_access_iterator_tag cub::TexObjInputIterator< T, OffsetT >::iterator_category

The iterator category.

Definition at line 131 of file tex_obj_input_iterator.cuh.

◆ pointer

template<typename T , typename OffsetT = ptrdiff_t>
typedef T* cub::TexObjInputIterator< T, OffsetT >::pointer

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

Definition at line 119 of file tex_obj_input_iterator.cuh.

◆ reference

template<typename T , typename OffsetT = ptrdiff_t>
typedef T cub::TexObjInputIterator< T, OffsetT >::reference

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

Definition at line 120 of file tex_obj_input_iterator.cuh.

◆ self_type

template<typename T , typename OffsetT = ptrdiff_t>
typedef TexObjInputIterator cub::TexObjInputIterator< T, OffsetT >::self_type

My own type.

Definition at line 116 of file tex_obj_input_iterator.cuh.

◆ TextureWord

template<typename T , typename OffsetT = ptrdiff_t>
typedef UnitWord<T>::TextureWord cub::TexObjInputIterator< T, OffsetT >::TextureWord
private

Definition at line 137 of file tex_obj_input_iterator.cuh.

◆ value_type

template<typename T , typename OffsetT = ptrdiff_t>
typedef T cub::TexObjInputIterator< T, OffsetT >::value_type

The type of the element the iterator can point to.

Definition at line 118 of file tex_obj_input_iterator.cuh.

Member Enumeration Documentation

◆ anonymous enum

template<typename T , typename OffsetT = ptrdiff_t>
anonymous enum
private

Definition at line 140 of file tex_obj_input_iterator.cuh.

Constructor & Destructor Documentation

◆ TexObjInputIterator()

template<typename T , typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ cub::TexObjInputIterator< T, OffsetT >::TexObjInputIterator ( )
inline

Constructor.

Definition at line 153 of file tex_obj_input_iterator.cuh.

Member Function Documentation

◆ BindTexture()

template<typename T , typename OffsetT = ptrdiff_t>
template<typename QualifiedT >
cudaError_t cub::TexObjInputIterator< T, OffsetT >::BindTexture ( QualifiedT *  ptr,
size_t  bytes = size_t(-1),
size_t  tex_offset = 0 
)
inline

Use this iterator to bind ptr with a texture reference.

Parameters
ptrNative pointer to wrap that is aligned to cudaDeviceProp::textureAlignment
bytesNumber of bytes in the range
tex_offsetOffsetT (in items) from ptr denoting the position of the iterator

Definition at line 162 of file tex_obj_input_iterator.cuh.

◆ operator!=()

template<typename T , typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ bool cub::TexObjInputIterator< T, OffsetT >::operator!= ( const self_type rhs)
inline

Not equal to.

Definition at line 292 of file tex_obj_input_iterator.cuh.

◆ operator*()

template<typename T , typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ reference cub::TexObjInputIterator< T, OffsetT >::operator* ( ) const
inline

Indirection.

Definition at line 205 of file tex_obj_input_iterator.cuh.

◆ operator+()

template<typename T , typename OffsetT = ptrdiff_t>
template<typename Distance >
__host__ __device__ __forceinline__ self_type cub::TexObjInputIterator< T, OffsetT >::operator+ ( Distance  n) const
inline

Addition.

Definition at line 229 of file tex_obj_input_iterator.cuh.

◆ operator++() [1/2]

template<typename T , typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ self_type cub::TexObjInputIterator< T, OffsetT >::operator++ ( )
inline

Prefix increment.

Definition at line 198 of file tex_obj_input_iterator.cuh.

◆ operator++() [2/2]

template<typename T , typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ self_type cub::TexObjInputIterator< T, OffsetT >::operator++ ( int  )
inline

Postfix increment.

Definition at line 190 of file tex_obj_input_iterator.cuh.

◆ operator+=()

template<typename T , typename OffsetT = ptrdiff_t>
template<typename Distance >
__host__ __device__ __forceinline__ self_type & cub::TexObjInputIterator< T, OffsetT >::operator+= ( Distance  n)
inline

Addition assignment.

Definition at line 240 of file tex_obj_input_iterator.cuh.

◆ operator-() [1/2]

template<typename T , typename OffsetT = ptrdiff_t>
template<typename Distance >
__host__ __device__ __forceinline__ self_type cub::TexObjInputIterator< T, OffsetT >::operator- ( Distance  n) const
inline

Subtraction.

Definition at line 248 of file tex_obj_input_iterator.cuh.

◆ operator-() [2/2]

template<typename T , typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ difference_type cub::TexObjInputIterator< T, OffsetT >::operator- ( self_type  other) const
inline

Distance.

Definition at line 266 of file tex_obj_input_iterator.cuh.

◆ operator-=()

template<typename T , typename OffsetT = ptrdiff_t>
template<typename Distance >
__host__ __device__ __forceinline__ self_type & cub::TexObjInputIterator< T, OffsetT >::operator-= ( Distance  n)
inline

Subtraction assignment.

Definition at line 259 of file tex_obj_input_iterator.cuh.

◆ operator->()

template<typename T , typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ pointer cub::TexObjInputIterator< T, OffsetT >::operator-> ( )
inline

Structure dereference.

Definition at line 280 of file tex_obj_input_iterator.cuh.

◆ operator==()

template<typename T , typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ bool cub::TexObjInputIterator< T, OffsetT >::operator== ( const self_type rhs)
inline

Equal to.

Definition at line 286 of file tex_obj_input_iterator.cuh.

◆ operator[]()

template<typename T , typename OffsetT = ptrdiff_t>
template<typename Distance >
__host__ __device__ __forceinline__ reference cub::TexObjInputIterator< T, OffsetT >::operator[] ( Distance  n) const
inline

Array subscript.

Definition at line 273 of file tex_obj_input_iterator.cuh.

◆ UnbindTexture()

template<typename T , typename OffsetT = ptrdiff_t>
cudaError_t cub::TexObjInputIterator< T, OffsetT >::UnbindTexture ( )
inline

Unbind this iterator from its texture reference.

Definition at line 184 of file tex_obj_input_iterator.cuh.

Friends And Related Symbol Documentation

◆ operator<<

template<typename T , typename OffsetT = ptrdiff_t>
std::ostream & operator<< ( std::ostream &  os,
const self_type itr 
)
friend

ostream operator

Definition at line 298 of file tex_obj_input_iterator.cuh.

Field Documentation

◆ ptr

template<typename T , typename OffsetT = ptrdiff_t>
T* cub::TexObjInputIterator< T, OffsetT >::ptr
private

Definition at line 146 of file tex_obj_input_iterator.cuh.

◆ tex_obj

template<typename T , typename OffsetT = ptrdiff_t>
cudaTextureObject_t cub::TexObjInputIterator< T, OffsetT >::tex_obj
private

Definition at line 148 of file tex_obj_input_iterator.cuh.

◆ tex_offset

template<typename T , typename OffsetT = ptrdiff_t>
difference_type cub::TexObjInputIterator< T, OffsetT >::tex_offset
private

Definition at line 147 of file tex_obj_input_iterator.cuh.


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