Extended CUDA Library (ecuda)  2.0
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
Classes | Public Types | Public Member Functions | Friends | List of all members
ecuda::padded_ptr< T, P > Class Template Reference

A specialized pointer to padded memory. More...

#include <iterator.hpp>

Public Types

typedef T element_type
 
typedef P pointer
 
typedef T & reference
 
typedef const T & const_reference
 
typedef std::size_t size_type
 
typedef std::ptrdiff_t difference_type
 

Public Member Functions

__HOST__ __DEVICE__ padded_ptr (pointer ptr=pointer(), size_type pitch=size_type())
 
__HOST__ __DEVICE__ padded_ptr (const padded_ptr &src)
 
__HOST__ __DEVICE__ padded_ptroperator= (const padded_ptr &src)
 
template<typename T2 , class P2 >
__HOST__ __DEVICE__ padded_ptr (const padded_ptr< T2, P2 > &src)
 
__HOST__ __DEVICE__ size_type get_pitch () const
 
__HOST__ __DEVICE__ pointer get () const
 
__DEVICE__ reference operator* ()
 
__DEVICE__ const_reference operator* () const
 
__DEVICE__ pointer operator-> () const
 
__DEVICE__ reference operator[] (std::size_t i)
 
__DEVICE__ const_reference operator[] (std::size_t i) const
 
__HOST__ __DEVICE__ operator bool () const __NOEXCEPT__
 Checks if this stores a non-null pointer. More...
 
__HOST__ __DEVICE__ padded_ptroperator++ ()
 
__HOST__ __DEVICE__ padded_ptroperator-- ()
 
__HOST__ __DEVICE__ padded_ptr operator++ (int)
 
__HOST__ __DEVICE__ padded_ptr operator-- (int)
 
__HOST__ __DEVICE__ padded_ptroperator+= (int x)
 
__HOST__ __DEVICE__ padded_ptroperator-= (int x)
 
__HOST__ __DEVICE__ padded_ptr operator+ (int x) const
 
__HOST__ __DEVICE__ padded_ptr operator- (int x) const
 
__HOST__ __DEVICE__ padded_ptr operator+ (std::size_t x) const
 
__HOST__ __DEVICE__ padded_ptr operator- (std::size_t x) const
 
template<typename T2 , typename P2 >
__HOST__ __DEVICE__ bool operator== (const padded_ptr< T2, P2 > &other) const
 
template<typename T2 , typename P2 >
__HOST__ __DEVICE__ bool operator!= (const padded_ptr< T2, P2 > &other) const
 
template<typename T2 , typename P2 >
__HOST__ __DEVICE__ bool operator< (const padded_ptr< T2, P2 > &other) const
 
template<typename T2 , typename P2 >
__HOST__ __DEVICE__ bool operator> (const padded_ptr< T2, P2 > &other) const
 
template<typename T2 , typename P2 >
__HOST__ __DEVICE__ bool operator<= (const padded_ptr< T2, P2 > &other) const
 
template<typename T2 , typename P2 >
__HOST__ __DEVICE__ bool operator>= (const padded_ptr< T2, P2 > &other) const
 
__HOST__ __DEVICE__ void skip_bytes (difference_type x)
 Move the pointer some number of bytes. More...
 

Friends

template<typename U , typename V >
std::basic_ostream< U, V > & operator<< (std::basic_ostream< U, V > &out, const padded_ptr &ptr)
 

Detailed Description

template<typename T, typename P>
class ecuda::padded_ptr< T, P >

A specialized pointer to padded memory.

A specialized pointer to device memory which is aligned to a certain width. Although this class stores this width it is the responsibility of the user of the class to account for this padding when traversing the data.

The specialization is used to both represent 2D memory allocations using cudaMallocPitch().

Memory use can be conceptualized as:

|- width --| // in multiples of sizeof(T)
|---- pitch ----| // in bytes
+----------+----+
| |xxxx|
| |xxxx| x = allocated but not used
| |xxxx|
| |xxxx|
| |xxxx|
| |xxxx| ... etc. (total size of the allocation is not known internally by padded_ptr)
+----------+----+

This class stores the pitch, but not the width nor the position within the range that the current pointed to element resides. The caller should store the relative position within the padded region and utilize the get_pitch() and skip_bytes() methods to skip over the padded region when needed.

Definition at line 52 of file iterator.hpp.

Member Typedef Documentation

template<typename T , typename P >
typedef const T& ecuda::padded_ptr< T, P >::const_reference

Definition at line 85 of file padded_ptr.hpp.

template<typename T , typename P >
typedef std::ptrdiff_t ecuda::padded_ptr< T, P >::difference_type

Definition at line 87 of file padded_ptr.hpp.

template<typename T , typename P >
typedef T ecuda::padded_ptr< T, P >::element_type

Definition at line 82 of file padded_ptr.hpp.

template<typename T , typename P >
typedef P ecuda::padded_ptr< T, P >::pointer

Definition at line 83 of file padded_ptr.hpp.

template<typename T , typename P >
typedef T& ecuda::padded_ptr< T, P >::reference

Definition at line 84 of file padded_ptr.hpp.

template<typename T , typename P >
typedef std::size_t ecuda::padded_ptr< T, P >::size_type

Definition at line 86 of file padded_ptr.hpp.

Constructor & Destructor Documentation

template<typename T , typename P >
__HOST__ __DEVICE__ ecuda::padded_ptr< T, P >::padded_ptr ( pointer  ptr = pointer(),
size_type  pitch = size_type() 
)
inline

Definition at line 101 of file padded_ptr.hpp.

template<typename T , typename P >
__HOST__ __DEVICE__ ecuda::padded_ptr< T, P >::padded_ptr ( const padded_ptr< T, P > &  src)
inline

Definition at line 103 of file padded_ptr.hpp.

template<typename T , typename P >
template<typename T2 , class P2 >
__HOST__ __DEVICE__ ecuda::padded_ptr< T, P >::padded_ptr ( const padded_ptr< T2, P2 > &  src)
inline

Definition at line 113 of file padded_ptr.hpp.

Member Function Documentation

template<typename T , typename P >
__HOST__ __DEVICE__ pointer ecuda::padded_ptr< T, P >::get ( ) const
inline

Definition at line 126 of file padded_ptr.hpp.

template<typename T , typename P >
__HOST__ __DEVICE__ size_type ecuda::padded_ptr< T, P >::get_pitch ( ) const
inline

Definition at line 125 of file padded_ptr.hpp.

template<typename T , typename P >
__HOST__ __DEVICE__ ecuda::padded_ptr< T, P >::operator bool ( ) const
inline

Checks if this stores a non-null pointer.

Returns
true if *this stores a pointer, false otherwise.

Definition at line 147 of file padded_ptr.hpp.

template<typename T , typename P >
template<typename T2 , typename P2 >
__HOST__ __DEVICE__ bool ecuda::padded_ptr< T, P >::operator!= ( const padded_ptr< T2, P2 > &  other) const
inline

Definition at line 177 of file padded_ptr.hpp.

template<typename T , typename P >
__DEVICE__ reference ecuda::padded_ptr< T, P >::operator* ( )
inline

Definition at line 128 of file padded_ptr.hpp.

template<typename T , typename P >
__DEVICE__ const_reference ecuda::padded_ptr< T, P >::operator* ( ) const
inline

Definition at line 129 of file padded_ptr.hpp.

template<typename T , typename P >
__HOST__ __DEVICE__ padded_ptr ecuda::padded_ptr< T, P >::operator+ ( int  x) const
inline

Definition at line 159 of file padded_ptr.hpp.

template<typename T , typename P >
__HOST__ __DEVICE__ padded_ptr ecuda::padded_ptr< T, P >::operator+ ( std::size_t  x) const
inline

Definition at line 173 of file padded_ptr.hpp.

template<typename T , typename P >
__HOST__ __DEVICE__ padded_ptr& ecuda::padded_ptr< T, P >::operator++ ( )
inline

Definition at line 150 of file padded_ptr.hpp.

template<typename T , typename P >
__HOST__ __DEVICE__ padded_ptr ecuda::padded_ptr< T, P >::operator++ ( int  )
inline

Definition at line 153 of file padded_ptr.hpp.

template<typename T , typename P >
__HOST__ __DEVICE__ padded_ptr& ecuda::padded_ptr< T, P >::operator+= ( int  x)
inline

Definition at line 156 of file padded_ptr.hpp.

template<typename T , typename P >
__HOST__ __DEVICE__ padded_ptr ecuda::padded_ptr< T, P >::operator- ( int  x) const
inline

Definition at line 166 of file padded_ptr.hpp.

template<typename T , typename P >
__HOST__ __DEVICE__ padded_ptr ecuda::padded_ptr< T, P >::operator- ( std::size_t  x) const
inline

Definition at line 174 of file padded_ptr.hpp.

template<typename T , typename P >
__HOST__ __DEVICE__ padded_ptr& ecuda::padded_ptr< T, P >::operator-- ( )
inline

Definition at line 151 of file padded_ptr.hpp.

template<typename T , typename P >
__HOST__ __DEVICE__ padded_ptr ecuda::padded_ptr< T, P >::operator-- ( int  )
inline

Definition at line 154 of file padded_ptr.hpp.

template<typename T , typename P >
__HOST__ __DEVICE__ padded_ptr& ecuda::padded_ptr< T, P >::operator-= ( int  x)
inline

Definition at line 157 of file padded_ptr.hpp.

template<typename T , typename P >
__DEVICE__ pointer ecuda::padded_ptr< T, P >::operator-> ( ) const
inline

Definition at line 130 of file padded_ptr.hpp.

template<typename T , typename P >
template<typename T2 , typename P2 >
__HOST__ __DEVICE__ bool ecuda::padded_ptr< T, P >::operator< ( const padded_ptr< T2, P2 > &  other) const
inline

Definition at line 178 of file padded_ptr.hpp.

template<typename T , typename P >
template<typename T2 , typename P2 >
__HOST__ __DEVICE__ bool ecuda::padded_ptr< T, P >::operator<= ( const padded_ptr< T2, P2 > &  other) const
inline

Definition at line 180 of file padded_ptr.hpp.

template<typename T , typename P >
__HOST__ __DEVICE__ padded_ptr& ecuda::padded_ptr< T, P >::operator= ( const padded_ptr< T, P > &  src)
inline

Definition at line 105 of file padded_ptr.hpp.

template<typename T , typename P >
template<typename T2 , typename P2 >
__HOST__ __DEVICE__ bool ecuda::padded_ptr< T, P >::operator== ( const padded_ptr< T2, P2 > &  other) const
inline

Definition at line 176 of file padded_ptr.hpp.

template<typename T , typename P >
template<typename T2 , typename P2 >
__HOST__ __DEVICE__ bool ecuda::padded_ptr< T, P >::operator> ( const padded_ptr< T2, P2 > &  other) const
inline

Definition at line 179 of file padded_ptr.hpp.

template<typename T , typename P >
template<typename T2 , typename P2 >
__HOST__ __DEVICE__ bool ecuda::padded_ptr< T, P >::operator>= ( const padded_ptr< T2, P2 > &  other) const
inline

Definition at line 181 of file padded_ptr.hpp.

template<typename T , typename P >
__DEVICE__ reference ecuda::padded_ptr< T, P >::operator[] ( std::size_t  i)
inline

Definition at line 131 of file padded_ptr.hpp.

template<typename T , typename P >
__DEVICE__ const_reference ecuda::padded_ptr< T, P >::operator[] ( std::size_t  i) const
inline

Definition at line 132 of file padded_ptr.hpp.

template<typename T , typename P >
__HOST__ __DEVICE__ void ecuda::padded_ptr< T, P >::skip_bytes ( difference_type  x)
inline

Move the pointer some number of bytes.

Remember the movement is always in bytes and doesn't consider sizeof(element_type).

Parameters
xNumber of bytes to move the pointer.

Definition at line 191 of file padded_ptr.hpp.

Friends And Related Function Documentation

template<typename T , typename P >
template<typename U , typename V >
std::basic_ostream<U,V>& operator<< ( std::basic_ostream< U, V > &  out,
const padded_ptr< T, P > &  ptr 
)
friend

Definition at line 201 of file padded_ptr.hpp.


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