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

Detailed description

template< typename T, int UNIQUE_ID, typename OffsetT = ptrdiff_t>
class cub::TexRefInputIterator< T, UNIQUE_ID, OffsetT >

A random-access input wrapper for dereferencing array values through texture cache. Uses older Tesla/Fermi-style texture references.

Deprecated:
[Since 1.13.0] The CUDA texture management APIs used by TexRefInputIterator are deprecated. Use cub::TexObjInputIterator instead.
Overview
  • TexRefInputIterator wraps 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.
  • The UNIQUE_ID template parameter is used to statically name the underlying texture reference. Only one TexRefInputIterator instance can be bound at any given time for a specific combination of (1) data type T, (2) UNIQUE_ID, (3) host thread, and (4) compilation .o unit.
  • With regard to nested/dynamic parallelism, TexRefInputIterator iterators may only be created by the host thread and used by a top-level kernel (i.e. the one which is launched from the host).
  • Compatible with Thrust API v1.7 or newer.
Snippet
The code snippet below illustrates the use of TexRefInputIterator to dereference a device array of doubles through texture cache.
#include <cub/cub.cuh> // or equivalently <cub/iterator/tex_ref_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();
Template Parameters
TThe value type of this iterator
UNIQUE_IDA globally-unique identifier (within the compilation unit) to name the underlying texture reference
OffsetTThe difference type of this iterator (Default: ptrdiff_t)

Public Types

typedef TexRefInputIterator self_type
 My own type. More...
 
typedef OffsetT difference_type
 Type to express the result of subtracting one iterator from another. More...
 
typedef T value_type
 The type of the element the iterator can point to. More...
 
typedef T * pointer
 The type of a pointer to an element the iterator can point to. More...
 
typedef T 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 QualifiedT >
cudaError_t BindTexture (QualifiedT *ptr, size_t bytes, size_t tex_offset=0)
 Use this iterator to bind ptr with a texture reference. More...
 
cudaError_t UnbindTexture ()
 Unbind this iterator from its texture reference. More...
 
__host__ __device__
__forceinline__ self_type 
operator++ (int)
 Postfix increment. More...
 
__host__ __device__
__forceinline__ self_type 
operator++ ()
 Prefix increment. More...
 
__host__ __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 >
__host__ __device__
__forceinline__ reference 
operator[] (Distance n) const
 Array subscript. More...
 
__host__ __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...
 

Friends

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

Member Typedef Documentation

template<typename T, int UNIQUE_ID, typename OffsetT = ptrdiff_t>
typedef TexRefInputIterator cub::TexRefInputIterator< T, UNIQUE_ID, OffsetT >::self_type

My own type.

template<typename T, int UNIQUE_ID, typename OffsetT = ptrdiff_t>
typedef OffsetT cub::TexRefInputIterator< T, UNIQUE_ID, OffsetT >::difference_type

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

template<typename T, int UNIQUE_ID, typename OffsetT = ptrdiff_t>
typedef T cub::TexRefInputIterator< T, UNIQUE_ID, OffsetT >::value_type

The type of the element the iterator can point to.

template<typename T, int UNIQUE_ID, typename OffsetT = ptrdiff_t>
typedef T* cub::TexRefInputIterator< T, UNIQUE_ID, OffsetT >::pointer

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

template<typename T, int UNIQUE_ID, typename OffsetT = ptrdiff_t>
typedef T cub::TexRefInputIterator< T, UNIQUE_ID, OffsetT >::reference

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

template<typename T, int UNIQUE_ID, typename OffsetT = ptrdiff_t>
typedef std::random_access_iterator_tag cub::TexRefInputIterator< T, UNIQUE_ID, OffsetT >::iterator_category

The iterator category.

Member Function Documentation

template<typename T, int UNIQUE_ID, typename OffsetT = ptrdiff_t>
template<typename QualifiedT >
cudaError_t cub::TexRefInputIterator< T, UNIQUE_ID, OffsetT >::BindTexture ( QualifiedT *  ptr,
size_t  bytes,
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
template<typename T, int UNIQUE_ID, typename OffsetT = ptrdiff_t>
cudaError_t cub::TexRefInputIterator< T, UNIQUE_ID, OffsetT >::UnbindTexture ( )
inline

Unbind this iterator from its texture reference.

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

Postfix increment.

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

Prefix increment.

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

Indirection.

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

Addition.

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

Addition assignment.

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

Subtraction.

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

Subtraction assignment.

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

Distance.

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

Array subscript.

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

Structure dereference.

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

Equal to.

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

Not equal to.

Friends And Related Function Documentation

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

ostream operator


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