Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Functions
Core support utilities

Functions

template<typename T >
auto uni20::allocate_temporary_buffer (std::size_t N, std::size_t align=64)
 Allocate a temporary buffer of T[N] aligned to align.
 
template<typename T >
auto uni20::allocate_temporary_buffer_uninitialized (std::size_t N, std::size_t align=64)
 Allocate a temporary buffer of T[N] that is always uninitialized.
 
template<typename T >
detail::aligned_buf_t< T > uni20::allocate_uninitialized_buffer (std::size_t N, std::size_t align=64)
 Allocate raw, aligned storage for T[N] without running constructors or destructors.
 

Detailed Description

This header provides low-overhead, cache-line-aligned buffers, exposed as std::unique_ptr<T[], Deleter> factories:

Function Documentation

◆ allocate_temporary_buffer()

template<typename T >
auto uni20::allocate_temporary_buffer ( std::size_t  N,
std::size_t  align = 64 
)

Allocate a temporary buffer of T[N] aligned to align.

  • If T is trivially initializable, the buffer is left uninitialized.
  • Otherwise each T is default-constructed and the deleter runs destructors before freeing.
    Template Parameters
    TElement type stored in the buffer.
    Parameters
    NNumber of elements to allocate.
    alignAlignment in bytes.
    Returns
    Unique pointer owning the memory and running destructors when needed.
    Exceptions
    std::bad_allocIf allocation fails.

◆ allocate_temporary_buffer_uninitialized()

template<typename T >
auto uni20::allocate_temporary_buffer_uninitialized ( std::size_t  N,
std::size_t  align = 64 
)

Allocate a temporary buffer of T[N] that is always uninitialized.

The deleter destroys elements for non-trivial types, so callers must placement-new each element before use when T is not trivially copyable.

Template Parameters
TElement type stored in the buffer.
Parameters
NNumber of elements to allocate.
alignAlignment in bytes.
Returns
Unique pointer owning the memory and running destructors when needed.
Exceptions
std::bad_allocIf allocation fails.

◆ allocate_uninitialized_buffer()

template<typename T >
detail::aligned_buf_t< T > uni20::allocate_uninitialized_buffer ( std::size_t  N,
std::size_t  align = 64 
)

Allocate raw, aligned storage for T[N] without running constructors or destructors.

When T is not trivially copyable you must placement-new each element before use and invoke std::destroy_n prior to releasing the buffer.

Template Parameters
TElement type stored in the buffer.
Parameters
NNumber of elements to allocate.
alignByte alignment for the allocation (defaults to 64).
Returns
Unique pointer that releases the raw storage without invoking destructors.
Exceptions
std::bad_allocIf allocation fails.