Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Friends | List of all members
uni20::cuda::CudaBuffer< T > Class Template Reference

Move-only logical CUDA buffer and completion state. More...

#include <buffer.hpp>

Public Types

using blocking_read_access_type = BlockingReadAccess< T >
 
using blocking_write_access_type = BlockingWriteAccess< T >
 
using element_type = T
 
using read_access_type = ReadAccess< T >
 
using write_access_type = WriteAccess< T >
 

Public Member Functions

std::size_t allocation_offset () const noexcept
 Return this logical buffer's offset in its physical allocation.
 
BlockingReadAccess< T > blocking_read_access () const
 Acquire read-only access after host-waiting for prior CUDA work.
 
BlockingWriteAccess< T > blocking_write_access ()
 Acquire read/write access after host-waiting for prior CUDA work.
 
 CudaBuffer (CudaBuffer &&other) noexcept
 
 CudaBuffer (CudaBuffer const &)=delete
 
 CudaBuffer (DeviceResources &resources, std::size_t size)
 Allocate size elements from one CUDA device's resources.
 
 CudaBuffer (std::size_t size)
 Allocate size elements on the installed runtime's default CUDA device.
 
Device device () const
 Return the allocation's CUDA device.
 
bool empty () const noexcept
 Return whether this is a zero-sized or moved-from allocation.
 
OwningReadAccess< T > into_blocking_read_access () &&
 Move this buffer into an owning host-synchronized read access.
 
OwningReadAccess< T > into_read_synchronized_with (Stream const &stream) &&
 Move this buffer into an owning stream-ordered read access.
 
CudaBuffer & operator= (CudaBuffer &&other) noexcept
 
CudaBuffer & operator= (CudaBuffer const &)=delete
 
auto partition (std::span< CudaBufferRange const > ranges) &&-> std::vector< CudaBuffer >
 Consume this buffer into statically disjoint logical child buffers.
 
ReadAccess< T > read_synchronized_with (Stream const &stream) const
 Acquire scoped read-only access synchronized with stream.
 
DeviceResources & resources () const
 Return the device resources borrowed by this buffer.
 
bool shares_allocation_with (CudaBuffer const &other) const noexcept
 Return whether another logical buffer shares this physical allocation.
 
std::size_t size () const noexcept
 Return the number of typed elements in the allocation.
 
std::size_t size_bytes () const noexcept
 Return the allocation size in bytes.
 
void synchronize () const
 Wait for every submitted operation currently involving this buffer.
 
WriteAccess< T > write_synchronized_with (Stream const &stream)
 Acquire scoped read/write access synchronized with stream.
 
 ~CudaBuffer ()
 

Friends

template<typename >
class BlockingReadAccess
 
template<typename >
class BlockingWriteAccess
 
template<typename >
class OwningReadAccess
 
template<typename >
class PartitionedReadAccess
 
template<typename >
class PartitionedWriteAccess
 
template<typename >
class ReadAccess
 
template<typename >
class WriteAccess
 

Detailed Description

template<typename T>
requires std::is_trivially_copyable_v<T>
class uni20::cuda::CudaBuffer< T >

Move-only logical CUDA buffer and completion state.

A buffer may own an entire CUDA allocation or one statically disjoint region of a shared allocation. Each logical buffer has an independent access ledger. Raw device pointers are exposed only through scoped access objects. Elements must be trivially copyable: allocations and bytewise transfers do not manage host-side owners.

Member Typedef Documentation

◆ blocking_read_access_type

template<typename T >
using uni20::cuda::CudaBuffer< T >::blocking_read_access_type = BlockingReadAccess<T>

◆ blocking_write_access_type

template<typename T >
using uni20::cuda::CudaBuffer< T >::blocking_write_access_type = BlockingWriteAccess<T>

◆ element_type

template<typename T >
using uni20::cuda::CudaBuffer< T >::element_type = T

◆ read_access_type

template<typename T >
using uni20::cuda::CudaBuffer< T >::read_access_type = ReadAccess<T>

◆ write_access_type

template<typename T >
using uni20::cuda::CudaBuffer< T >::write_access_type = WriteAccess<T>

Constructor & Destructor Documentation

◆ CudaBuffer() [1/4]

template<typename T >
uni20::cuda::CudaBuffer< T >::CudaBuffer ( std::size_t  size)
inlineexplicit

Allocate size elements on the installed runtime's default CUDA device.

◆ CudaBuffer() [2/4]

template<typename T >
uni20::cuda::CudaBuffer< T >::CudaBuffer ( DeviceResources &  resources,
std::size_t  size 
)
inline

Allocate size elements from one CUDA device's resources.

◆ CudaBuffer() [3/4]

template<typename T >
uni20::cuda::CudaBuffer< T >::CudaBuffer ( CudaBuffer< T > const &  )
delete

◆ CudaBuffer() [4/4]

template<typename T >
uni20::cuda::CudaBuffer< T >::CudaBuffer ( CudaBuffer< T > &&  other)
inlinenoexcept

◆ ~CudaBuffer()

template<typename T >
uni20::cuda::CudaBuffer< T >::~CudaBuffer ( )
inline

Member Function Documentation

◆ allocation_offset()

template<typename T >
std::size_t uni20::cuda::CudaBuffer< T >::allocation_offset ( ) const
inlinenoexcept

Return this logical buffer's offset in its physical allocation.

◆ blocking_read_access()

template<typename T >
BlockingReadAccess< T > uni20::cuda::CudaBuffer< T >::blocking_read_access ( ) const
inline

Acquire read-only access after host-waiting for prior CUDA work.

◆ blocking_write_access()

template<typename T >
BlockingWriteAccess< T > uni20::cuda::CudaBuffer< T >::blocking_write_access ( )
inline

Acquire read/write access after host-waiting for prior CUDA work.

◆ device()

template<typename T >
Device uni20::cuda::CudaBuffer< T >::device ( ) const
inline

Return the allocation's CUDA device.

◆ empty()

template<typename T >
bool uni20::cuda::CudaBuffer< T >::empty ( ) const
inlinenoexcept

Return whether this is a zero-sized or moved-from allocation.

◆ into_blocking_read_access()

template<typename T >
requires std::is_trivially_copyable_v<T>
OwningReadAccess< T > uni20::cuda::CudaBuffer< T >::into_blocking_read_access ( ) &&

Move this buffer into an owning host-synchronized read access.

◆ into_read_synchronized_with()

template<typename T >
requires std::is_trivially_copyable_v<T>
OwningReadAccess< T > uni20::cuda::CudaBuffer< T >::into_read_synchronized_with ( Stream const &  stream) &&

Move this buffer into an owning stream-ordered read access.

◆ operator=() [1/2]

template<typename T >
CudaBuffer & uni20::cuda::CudaBuffer< T >::operator= ( CudaBuffer< T > &&  other)
inlinenoexcept

◆ operator=() [2/2]

template<typename T >
CudaBuffer & uni20::cuda::CudaBuffer< T >::operator= ( CudaBuffer< T > const &  )
delete

◆ partition()

template<typename T >
auto uni20::cuda::CudaBuffer< T >::partition ( std::span< CudaBufferRange const >  ranges) && -> std::vector<CudaBuffer>
inline

Consume this buffer into statically disjoint logical child buffers.

Every range is relative to this logical buffer. Ranges must be sorted, non-overlapping, and contained within the buffer. The source becomes moved-from and cannot bypass the child ledgers.

◆ read_synchronized_with()

template<typename T >
ReadAccess< T > uni20::cuda::CudaBuffer< T >::read_synchronized_with ( Stream const &  stream) const
inline

Acquire scoped read-only access synchronized with stream.

◆ resources()

template<typename T >
DeviceResources & uni20::cuda::CudaBuffer< T >::resources ( ) const
inline

Return the device resources borrowed by this buffer.

◆ shares_allocation_with()

template<typename T >
bool uni20::cuda::CudaBuffer< T >::shares_allocation_with ( CudaBuffer< T > const &  other) const
inlinenoexcept

Return whether another logical buffer shares this physical allocation.

◆ size()

template<typename T >
std::size_t uni20::cuda::CudaBuffer< T >::size ( ) const
inlinenoexcept

Return the number of typed elements in the allocation.

◆ size_bytes()

template<typename T >
std::size_t uni20::cuda::CudaBuffer< T >::size_bytes ( ) const
inlinenoexcept

Return the allocation size in bytes.

◆ synchronize()

template<typename T >
void uni20::cuda::CudaBuffer< T >::synchronize ( ) const
inline

Wait for every submitted operation currently involving this buffer.

◆ write_synchronized_with()

template<typename T >
WriteAccess< T > uni20::cuda::CudaBuffer< T >::write_synchronized_with ( Stream const &  stream)
inline

Acquire scoped read/write access synchronized with stream.

Friends And Related Symbol Documentation

◆ BlockingReadAccess

template<typename T >
template<typename >
friend class BlockingReadAccess
friend

◆ BlockingWriteAccess

template<typename T >
template<typename >
friend class BlockingWriteAccess
friend

◆ OwningReadAccess

template<typename T >
template<typename >
friend class OwningReadAccess
friend

◆ PartitionedReadAccess

template<typename T >
template<typename >
friend class PartitionedReadAccess
friend

◆ PartitionedWriteAccess

template<typename T >
template<typename >
friend class PartitionedWriteAccess
friend

◆ ReadAccess

template<typename T >
template<typename >
friend class ReadAccess
friend

◆ WriteAccess

template<typename T >
template<typename >
friend class WriteAccess
friend

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