ttg_parsec::Buffer< T, Allocator > Struct Template Reference

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 191 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 >
 

Public Member Functions

 Buffer ()=default
 
 Buffer (std::size_t n, ttg::scope scope=ttg::scope::SyncIn)
 
 Buffer (std::shared_ptr< value_type[]> ptr, std::size_t n, ttg::scope scope=ttg::scope::SyncIn)
 
template<typename Deleter >
 Buffer (std::unique_ptr< value_type[], Deleter > ptr, std::size_t n, 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)
 
bool is_current_on (ttg::device::Device dev) const
 
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
 
bool empty () const
 
void reset (std::size_t n, ttg::scope scope=ttg::scope::SyncIn)
 
void reset (std::shared_ptr< value_type[]> ptr, std::size_t n, ttg::scope scope=ttg::scope::SyncIn)
 
void reset_scope (ttg::scope scope)
 
ttg::scope scope () const
 
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 > &)
 

Member Typedef Documentation

◆ 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 196 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 197 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 195 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 194 of file buffer.h.

Constructor & Destructor Documentation

◆ Buffer() [1/6]

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

◆ Buffer() [2/6]

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

Definition at line 222 of file buffer.h.

◆ Buffer() [3/6]

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

Constructing a buffer using application-managed memory. The shared_ptr will ensure that the memory is not free'd before the runtime has released all of its references.

Definition at line 232 of file buffer.h.

◆ Buffer() [4/6]

template<typename T , typename Allocator >
template<typename Deleter >
ttg_parsec::Buffer< T, Allocator >::Buffer ( std::unique_ptr< value_type[], Deleter >  ptr,
std::size_t  n,
ttg::scope  scope = ttg::scope::SyncIn 
)
inline

Definition at line 241 of file buffer.h.

◆ ~Buffer()

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

Definition at line 249 of file buffer.h.

◆ Buffer() [5/6]

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

Definition at line 255 of file buffer.h.

◆ Buffer() [6/6]

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 489 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 385 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 322 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 330 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 355 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 364 of file buffer.h.

◆ empty()

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

Definition at line 431 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 315 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 371 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 375 of file buffer.h.

◆ is_current_on()

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

Definition at line 298 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 419 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 379 of file buffer.h.

◆ operator bool()

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

Definition at line 423 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 269 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 340 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 347 of file buffer.h.

◆ pin()

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

Definition at line 395 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 410 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 481 of file buffer.h.

◆ reset() [1/2]

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

Definition at line 444 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 436 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 459 of file buffer.h.

◆ scope()

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

Definition at line 474 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 288 of file buffer.h.

◆ size()

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

Definition at line 427 of file buffer.h.

◆ unpin()

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

Definition at line 402 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 415 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: