ttg_parsec::Buffer< T, Allocator > Struct Template Reference
Inheritance diagram for ttg_parsec::Buffer< T, Allocator >:
ttg_parsec::detail::ttg_parsec_data_wrapper_t

Documentation

template<typename T, typename Allocator>
struct ttg_parsec::Buffer< T, Allocator >

A buffer that is mirrored between host memory and different devices. The runtime is free to move data between device and host memory based on where the tasks are executing.

Note that a buffer is movable and should not be shared between two objects (e.g., through a pointer) in order for TTG to properly facilitate ownership tracking of the containing object.

Definition at line 40 of file buffer.h.

Public Types

using value_type = std::remove_all_extents_t< T >
 
using pointer_type = std::add_pointer_t< value_type >
 
using const_pointer_type = const std::remove_const_t< value_type > *
 
using element_type = std::decay_t< T >
 
using allocator_traits = std::allocator_traits< Allocator >
 
using allocator_type = typename allocator_traits::allocator_type
 

Public Member Functions

 Buffer ()
 
 Buffer (std::size_t n, ttg::scope scope=ttg::scope::SyncIn)
 
 Buffer (pointer_type ptr, std::size_t n=1, ttg::scope scope=ttg::scope::SyncIn)
 
virtual ~Buffer ()
 
 Buffer (Buffer &&db)
 
 Buffer (const Buffer &db)=delete
 
Bufferoperator= (Buffer &&db)
 
Bufferoperator= (const Buffer &db)=delete
 
void set_current_device (const ttg::device::Device &device)
 
ttg::device::Device get_owner_device () const
 
pointer_type current_device_ptr ()
 
const_pointer_type current_device_ptr () const
 
pointer_type owner_device_ptr ()
 
const_pointer_type owner_device_ptr () const
 
pointer_type device_ptr_on (const ttg::device::Device &device)
 
const_pointer_type device_ptr_on (const ttg::device::Device &device) const
 
pointer_type host_ptr ()
 
const_pointer_type host_ptr () const
 
bool is_valid_on (const ttg::device::Device &device) const
 
void allocate_on (const ttg::device::Device &device_id)
 
void pin ()
 
void unpin ()
 
void pin_on (int device_id)
 
void unpin_on (int device_id)
 
bool is_valid () const
 
 operator bool () const
 
std::size_t size () const
 
void reset (std::size_t n, ttg::scope scope=ttg::scope::SyncIn)
 
void reset (pointer_type ptr, std::size_t n=1, ttg::scope scope=ttg::scope::SyncIn)
 
void reset_scope (ttg::scope scope)
 
void prefer_device (ttg::device::Device dev)
 
void add_device (ttg::device::Device dev, pointer_type ptr, bool is_current=false)
 

Friends

parsec_data_t * detail::get_parsec_data (const ttg_parsec::Buffer< T, Allocator > &)
 

Additional Inherited Members

- Protected Types inherited from ttg_parsec::detail::ttg_parsec_data_wrapper_t
using parsec_data_ptr = std::unique_ptr< parsec_data_t, decltype(&parsec_data_destroy)>
 
- Protected Member Functions inherited from ttg_parsec::detail::ttg_parsec_data_wrapper_t
parsec_data_t * parsec_data ()
 
const parsec_data_t * parsec_data () const
 
void remove_from_owner ()
 
void reset_parsec_data (void *ptr, size_t size, bool sync_to_device)
 
 ttg_parsec_data_wrapper_t ()
 
 ttg_parsec_data_wrapper_t (const ttg_parsec_data_wrapper_t &other)=delete
 
 ttg_parsec_data_wrapper_t (ttg_parsec_data_wrapper_t &&other)
 
ttg_parsec_data_wrapper_toperator= (const ttg_parsec_data_wrapper_t &other)=delete
 
ttg_parsec_data_wrapper_toperator= (ttg_parsec_data_wrapper_t &&other)
 
virtual ~ttg_parsec_data_wrapper_t ()
 
void set_owner (ttg_data_copy_t &new_copy)
 
void add_copy (int parsec_dev, void *ptr)
 
- Static Protected Member Functions inherited from ttg_parsec::detail::ttg_parsec_data_wrapper_t
static parsec_data_t * create_parsec_data (void *ptr, size_t size, bool sync_to_device)
 
static void delete_parsec_data (parsec_data_t *data)
 
static void delete_null_parsec_data (parsec_data_t *)
 
- Protected Attributes inherited from ttg_parsec::detail::ttg_parsec_data_wrapper_t
ttg_data_copy_tm_ttg_copy = nullptr
 
parsec_data_ptr m_data
 
friend ttg_data_copy_t
 

Member Typedef Documentation

◆ allocator_traits

template<typename T , typename Allocator >
using ttg_parsec::Buffer< T, Allocator >::allocator_traits = std::allocator_traits<Allocator>

Definition at line 49 of file buffer.h.

◆ allocator_type

template<typename T , typename Allocator >
using ttg_parsec::Buffer< T, Allocator >::allocator_type = typename allocator_traits::allocator_type

Definition at line 50 of file buffer.h.

◆ const_pointer_type

template<typename T , typename Allocator >
using ttg_parsec::Buffer< T, Allocator >::const_pointer_type = const std::remove_const_t<value_type>*

Definition at line 46 of file buffer.h.

◆ element_type

template<typename T , typename Allocator >
using ttg_parsec::Buffer< T, Allocator >::element_type = std::decay_t<T>

Definition at line 47 of file buffer.h.

◆ pointer_type

template<typename T , typename Allocator >
using ttg_parsec::Buffer< T, Allocator >::pointer_type = std::add_pointer_t<value_type>

Definition at line 45 of file buffer.h.

◆ value_type

template<typename T , typename Allocator >
using ttg_parsec::Buffer< T, Allocator >::value_type = std::remove_all_extents_t<T>

Definition at line 44 of file buffer.h.

Constructor & Destructor Documentation

◆ Buffer() [1/5]

template<typename T , typename Allocator >
ttg_parsec::Buffer< T, Allocator >::Buffer ( )
inline

Definition at line 81 of file buffer.h.

◆ Buffer() [2/5]

template<typename T , typename Allocator >
ttg_parsec::Buffer< T, Allocator >::Buffer ( std::size_t  n,
ttg::scope  scope = ttg::scope::SyncIn 
)
inline

Allocates n elements, unitialized By default, data is synchronized to the device, allowing codes to fill the buffer before making it available on the device. Passing ttg::scope::Allocate will prevent the initial synchronization. Subsequent data transfers behave as expected (i.e., data is transferred to the host and other devices as needed).

Definition at line 92 of file buffer.h.

◆ Buffer() [3/5]

template<typename T , typename Allocator >
ttg_parsec::Buffer< T, Allocator >::Buffer ( pointer_type  ptr,
std::size_t  n = 1,
ttg::scope  scope = ttg::scope::SyncIn 
)
inline

Constructing a buffer using application-managed memory. The memory pointed to by ptr must be accessible during the life-time of the buffer.

Passing ttg::scope::Allocate will prevent the initial synchronization. Subsequent data transfers behave as expected (i.e., data is transferred to the host and other devices as needed).

Definition at line 115 of file buffer.h.

◆ ~Buffer()

template<typename T , typename Allocator >
virtual ttg_parsec::Buffer< T, Allocator >::~Buffer ( )
inlinevirtual

Definition at line 129 of file buffer.h.

◆ Buffer() [4/5]

template<typename T , typename Allocator >
ttg_parsec::Buffer< T, Allocator >::Buffer ( Buffer< T, Allocator > &&  db)
inline

Definition at line 138 of file buffer.h.

◆ Buffer() [5/5]

template<typename T , typename Allocator >
ttg_parsec::Buffer< T, Allocator >::Buffer ( const Buffer< T, Allocator > &  db)
delete

Member Function Documentation

◆ add_device()

template<typename T , typename Allocator >
void ttg_parsec::Buffer< T, Allocator >::add_device ( ttg::device::Device  dev,
pointer_type  ptr,
bool  is_current = false 
)
inline

Definition at line 378 of file buffer.h.

◆ allocate_on()

template<typename T , typename Allocator >
void ttg_parsec::Buffer< T, Allocator >::allocate_on ( const ttg::device::Device device_id)
inline

Definition at line 253 of file buffer.h.

◆ current_device_ptr() [1/2]

template<typename T , typename Allocator >
pointer_type ttg_parsec::Buffer< T, Allocator >::current_device_ptr ( )
inline

Definition at line 196 of file buffer.h.

◆ current_device_ptr() [2/2]

template<typename T , typename Allocator >
const_pointer_type ttg_parsec::Buffer< T, Allocator >::current_device_ptr ( ) const
inline

Definition at line 203 of file buffer.h.

◆ device_ptr_on() [1/2]

template<typename T , typename Allocator >
pointer_type ttg_parsec::Buffer< T, Allocator >::device_ptr_on ( const ttg::device::Device device)
inline

Definition at line 225 of file buffer.h.

◆ device_ptr_on() [2/2]

template<typename T , typename Allocator >
const_pointer_type ttg_parsec::Buffer< T, Allocator >::device_ptr_on ( const ttg::device::Device device) const
inline

Definition at line 233 of file buffer.h.

◆ get_owner_device()

template<typename T , typename Allocator >
ttg::device::Device ttg_parsec::Buffer< T, Allocator >::get_owner_device ( ) const
inline

Definition at line 190 of file buffer.h.

◆ host_ptr() [1/2]

template<typename T , typename Allocator >
pointer_type ttg_parsec::Buffer< T, Allocator >::host_ptr ( )
inline

Definition at line 239 of file buffer.h.

◆ host_ptr() [2/2]

template<typename T , typename Allocator >
const_pointer_type ttg_parsec::Buffer< T, Allocator >::host_ptr ( ) const
inline

Definition at line 243 of file buffer.h.

◆ is_valid()

template<typename T , typename Allocator >
bool ttg_parsec::Buffer< T, Allocator >::is_valid ( void  ) const
inline

Definition at line 287 of file buffer.h.

◆ is_valid_on()

template<typename T , typename Allocator >
bool ttg_parsec::Buffer< T, Allocator >::is_valid_on ( const ttg::device::Device device) const
inline

Definition at line 247 of file buffer.h.

◆ operator bool()

template<typename T , typename Allocator >
ttg_parsec::Buffer< T, Allocator >::operator bool ( ) const
inline

Definition at line 291 of file buffer.h.

◆ operator=() [1/2]

template<typename T , typename Allocator >
Buffer& ttg_parsec::Buffer< T, Allocator >::operator= ( Buffer< T, Allocator > &&  db)
inline

Definition at line 156 of file buffer.h.

◆ operator=() [2/2]

template<typename T , typename Allocator >
Buffer& ttg_parsec::Buffer< T, Allocator >::operator= ( const Buffer< T, Allocator > &  db)
delete

◆ owner_device_ptr() [1/2]

template<typename T , typename Allocator >
pointer_type ttg_parsec::Buffer< T, Allocator >::owner_device_ptr ( )
inline

Definition at line 212 of file buffer.h.

◆ owner_device_ptr() [2/2]

template<typename T , typename Allocator >
const_pointer_type ttg_parsec::Buffer< T, Allocator >::owner_device_ptr ( ) const
inline

Definition at line 218 of file buffer.h.

◆ pin()

template<typename T , typename Allocator >
void ttg_parsec::Buffer< T, Allocator >::pin ( )
inline

Definition at line 263 of file buffer.h.

◆ pin_on()

template<typename T , typename Allocator >
void ttg_parsec::Buffer< T, Allocator >::pin_on ( int  device_id)
inline

Definition at line 278 of file buffer.h.

◆ prefer_device()

template<typename T , typename Allocator >
void ttg_parsec::Buffer< T, Allocator >::prefer_device ( ttg::device::Device  dev)
inline

Definition at line 370 of file buffer.h.

◆ reset() [1/2]

template<typename T , typename Allocator >
void ttg_parsec::Buffer< T, Allocator >::reset ( pointer_type  ptr,
std::size_t  n = 1,
ttg::scope  scope = ttg::scope::SyncIn 
)
inline

Definition at line 323 of file buffer.h.

◆ reset() [2/2]

template<typename T , typename Allocator >
void ttg_parsec::Buffer< T, Allocator >::reset ( std::size_t  n,
ttg::scope  scope = ttg::scope::SyncIn 
)
inline

Definition at line 300 of file buffer.h.

◆ reset_scope()

template<typename T , typename Allocator >
void ttg_parsec::Buffer< T, Allocator >::reset_scope ( ttg::scope  scope)
inline

Resets the scope of the buffer. If scope is SyncIn then the next time the buffer is made available on a device the host data will be copied from the host. If scope is Allocate then no data will be moved.

Definition at line 355 of file buffer.h.

◆ set_current_device()

template<typename T , typename Allocator >
void ttg_parsec::Buffer< T, Allocator >::set_current_device ( const ttg::device::Device device)
inline

Definition at line 178 of file buffer.h.

◆ size()

template<typename T , typename Allocator >
std::size_t ttg_parsec::Buffer< T, Allocator >::size ( ) const
inline

Definition at line 295 of file buffer.h.

◆ unpin()

template<typename T , typename Allocator >
void ttg_parsec::Buffer< T, Allocator >::unpin ( )
inline

Definition at line 270 of file buffer.h.

◆ unpin_on()

template<typename T , typename Allocator >
void ttg_parsec::Buffer< T, Allocator >::unpin_on ( int  device_id)
inline

Definition at line 283 of file buffer.h.

Friends And Related Function Documentation

◆ detail::get_parsec_data

template<typename T , typename Allocator >
parsec_data_t* detail::get_parsec_data ( const ttg_parsec::Buffer< T, Allocator > &  )
friend

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