Lift
Library of parallel computing primitives for GPUs and multi-core CPUs
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Public Types | Public Member Functions | List of all members
lift::pointer< system, T, _index_type > Struct Template Reference

Lift's tagged pointer class. More...

#include <pointer.h>

Inheritance diagram for lift::pointer< system, T, _index_type >:
lift::tagged_pointer_base< system, T, _index_type > lift::allocation< system, T, _index_type > lift::allocation< system, T, _index_type, allocator > lift::persistent_allocation< system, T, _index_type, allocator >

Public Types

typedef tagged_pointer_base
< host, T, _index_type > 
base
 
typedef base::reference_type reference_type
 
typedef base::const_reference_type const_reference_type
 
typedef base::value_type value_type
 
typedef base::index_type index_type
 
typedef base::size_type size_type
 
typedef base::iterator_type iterator_type
 
typedef base::const_iterator_type const_iterator_type
 
- Public Types inherited from lift::tagged_pointer_base< system, T, _index_type >
enum  { system_tag = system }
 
typedef T value_type
 
typedef const T const_value_type
 
typedef _index_type index_type
 
typedef index_type size_type
 
typedef index_type difference_type
 
typedef T & reference_type
 
typedef const T & const_reference_type
 
typedef T * pointer_type
 
typedef const T * const_pointer_type
 
typedef T * iterator_type
 
typedef const T * const_iterator_type
 
typedef
thrust_iterator_adaptor
< system, value_type,
iterator_type
thrust_iterator_type
 Thrust-compatible iterator types. More...
 
typedef
thrust_iterator_adaptor
< system, value_type,
const_iterator_type
thrust_const_iterator_type
 

Public Member Functions

LIFT_HOST_DEVICE pointer range (const size_type offset, size_type len=size_type(-1)) const
 
LIFT_HOST_DEVICE pointer operator+ (off_t offset) const
 
LIFT_HOST_DEVICE pointer operator- (off_t offset) const
 
LIFT_HOST_DEVICE pointer truncate (size_t new_size)
 
value_type peek (index_type pos)
 
void poke (index_type pos, const value_type value)
 
- Public Member Functions inherited from lift::tagged_pointer_base< system, T, _index_type >
LIFT_HOST_DEVICE tagged_pointer_base ()
 The default constructor initializes the pointer to null. More...
 
LIFT_HOST_DEVICE tagged_pointer_base (T *storage, size_type storage_size)
 Construct a tagged pointer from a raw pointer. More...
 
template<target_system other_system, typename other_value_type >
LIFT_HOST_DEVICE tagged_pointer_base (tagged_pointer_base< other_system, other_value_type, index_type > &other)
 Copy constructor creates a copy of the pointer. More...
 
template<typename other_pointer >
LIFT_HOST_DEVICE tagged_pointer_base (other_pointer &other)
 
template<target_system other_system, typename other_value_type >
LIFT_HOST_DEVICE
tagged_pointer_base
operator= (tagged_pointer_base< other_system, other_value_type, index_type > &other)
 Copy constructor creates a copy of the pointer. More...
 
LIFT_HOST_DEVICE
const_reference_type 
at (size_type pos) const
 
LIFT_HOST_DEVICE reference_type at (size_type pos)
 
LIFT_HOST_DEVICE
const_reference_type 
operator[] (size_type pos) const
 
LIFT_HOST_DEVICE reference_type operator[] (size_type pos)
 
LIFT_HOST_DEVICE
const_reference_type 
front () const
 
LIFT_HOST_DEVICE reference_type front ()
 
LIFT_HOST_DEVICE
const_reference_type 
back () const
 
LIFT_HOST_DEVICE reference_type back ()
 
LIFT_HOST_DEVICE
const_iterator_type 
begin () const
 
LIFT_HOST_DEVICE iterator_type begin ()
 
LIFT_HOST_DEVICE
const_iterator_type 
end () const
 
LIFT_HOST_DEVICE iterator_type end ()
 
LIFT_HOST_DEVICE
const_iterator_type 
cbegin () const
 
LIFT_HOST_DEVICE
const_iterator_type 
cend () const
 
LIFT_HOST_DEVICE
thrust_const_iterator_type 
t_begin () const
 Returns a Thrust-compatible iterator pointing at the base address of the pointer. More...
 
LIFT_HOST_DEVICE
thrust_iterator_type 
t_begin ()
 Returns a Thrust-compatible iterator pointing at the base address of the pointer. More...
 
LIFT_HOST_DEVICE
thrust_const_iterator_type 
t_end () const
 Returns a Thrust-compatible iterator pointing at the end of the memory region covered by this pointer object. More...
 
LIFT_HOST_DEVICE
thrust_iterator_type 
t_end ()
 Returns a Thrust-compatible iterator pointing at the end of the memory region covered by this pointer object. More...
 
LIFT_HOST_DEVICE size_type size () const
 
LIFT_HOST_DEVICE bool empty () const
 
LIFT_HOST_DEVICE pointer_type data () const
 

Additional Inherited Members

- Protected Attributes inherited from lift::tagged_pointer_base< system, T, _index_type >
pointer_type storage
 
size_type storage_size
 

Detailed Description

template<target_system system, typename T, typename _index_type = uint32>
struct lift::pointer< system, T, _index_type >

Lift's tagged pointer class.

The type of a pointer includes a system tag, which identifies each pointer based on the memory space it belongs to. When dereferencing the pointer, the type of the index is also selectable at compile-time. This is because GPU implementations can benefit from 32-bit indexing even in 64-bit mode, as certain index calculations can be slow.

Lift pointers are sized (meaning they track the amount of memory they point at), but no bounds-checking is performed. They implement C-style pointer semantics, allowing assignment from compatible pointer types as well as pointer arithmetic.

Note that despite the fact that pointers are tagged with the memory space they belong to, Lift does not directly handle cross-device dereferencing in the pointer dereference operator. Directly dereferencing a GPU pointer on the CPU (or vice-versa) yields undefined behavior. Lift pointers provide an explicit interface for cross-memory-space reads/writes (peek() / poke()).

Definition at line 276 of file pointer.h.

Member Typedef Documentation

template<target_system system, typename T, typename _index_type = uint32>
typedef tagged_pointer_base<host, T, _index_type> lift::pointer< system, T, _index_type >::base

Definition at line 281 of file pointer.h.

template<target_system system, typename T, typename _index_type = uint32>
typedef base::const_iterator_type lift::pointer< system, T, _index_type >::const_iterator_type

Definition at line 289 of file pointer.h.

template<target_system system, typename T, typename _index_type = uint32>
typedef base::const_reference_type lift::pointer< system, T, _index_type >::const_reference_type

Definition at line 284 of file pointer.h.

template<target_system system, typename T, typename _index_type = uint32>
typedef base::index_type lift::pointer< system, T, _index_type >::index_type

Definition at line 286 of file pointer.h.

template<target_system system, typename T, typename _index_type = uint32>
typedef base::iterator_type lift::pointer< system, T, _index_type >::iterator_type

Definition at line 288 of file pointer.h.

template<target_system system, typename T, typename _index_type = uint32>
typedef base::reference_type lift::pointer< system, T, _index_type >::reference_type

Definition at line 283 of file pointer.h.

template<target_system system, typename T, typename _index_type = uint32>
typedef base::size_type lift::pointer< system, T, _index_type >::size_type

Definition at line 287 of file pointer.h.

template<target_system system, typename T, typename _index_type = uint32>
typedef base::value_type lift::pointer< system, T, _index_type >::value_type

Definition at line 285 of file pointer.h.

Member Function Documentation

template<target_system system, typename T, typename _index_type = uint32>
LIFT_HOST_DEVICE pointer lift::pointer< system, T, _index_type >::operator+ ( off_t  offset) const
template<target_system system, typename T, typename _index_type = uint32>
LIFT_HOST_DEVICE pointer lift::pointer< system, T, _index_type >::operator- ( off_t  offset) const
template<target_system system, typename T, typename _index_type = uint32>
value_type lift::pointer< system, T, _index_type >::peek ( index_type  pos)
template<target_system system, typename T, typename _index_type = uint32>
void lift::pointer< system, T, _index_type >::poke ( index_type  pos,
const value_type  value 
)
template<target_system system, typename T, typename _index_type = uint32>
LIFT_HOST_DEVICE pointer lift::pointer< system, T, _index_type >::range ( const size_type  offset,
size_type  len = size_type(-1) 
) const
template<target_system system, typename T, typename _index_type = uint32>
LIFT_HOST_DEVICE pointer lift::pointer< system, T, _index_type >::truncate ( size_t  new_size)

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