legate::TaskLocalBuffer#
-
class TaskLocalBuffer#
A task-local temporary buffer.
A
TaskLocalBuffer
is, as the name implies, “local” to a task. Its lifetime is bound to that of the task. When the task ends, the buffer is destroyed. It is most commonly used as temporary scratch-space within tasks for that reason.The buffer is allocated immediately at the point when
TaskLocalBuffer
is created, so it is safe to use it immediately, even if it used asynchronously (for example, in GPU kernel launches) after the fact.Public Functions
- TaskLocalBuffer(
- const Legion::UntypedDeferredBuffer<> &buf,
- const Type &type,
- const Domain &bounds
Construct a
TaskLocalBuffer
.- Parameters:
buf – The Legion buffer from which to construct this buffer.
type – The type to interpret
buf
as.bounds – The extent of the buffer.
- TaskLocalBuffer(
- const Type &type,
- Span<const std::uint64_t> bounds,
- std::optional<mapping::StoreTarget> mem_kind = std::nullopt
Construct a
TaskLocalBuffer
.If
mem_kind
is not given, the memory kind is automatically deduced based on the type of processor executing the task. For example, GPU tasks will allocate GPU memory (pure GPU memory that is, not zero-copy), while CPU tasks will allocate regular system memory.- Parameters:
type – The type of the buffer.
bounds – The extents of the buffer.
mem_kind – The kind of memory to allocate.
-
template<typename T, std::int32_t DIM>
TaskLocalBuffer(
)# Construct a
TaskLocalBuffer
.If this kind of constructor is used, the user should almost always prefer the
type
-less version of this ctor. That constructor will deduce theType
based onT
. The point of this ctor is to provide the ability to type-pun theBuffer
with an equivalent type.- Parameters:
buf – The typed Legion buffer from which to construct this buffer from.
type – The type to interpret
buf
as.
- Throws:
std::invalid_argument – If
sizeof(T)
is not the same as the type size.std::invalid_argument – If
alignof(T)
is not the same as the type alignment.
-
template<typename T, std::int32_t DIM>
explicit TaskLocalBuffer(
)# Construct a
TaskLocalBuffer
.The type of the buffer is deduced from
T
.- Parameters:
buf – The typed Legion buffer from which to construct this buffer from.
-
std::int32_t dim() const#
- Returns:
The dimension of the buffer
-
const Domain &domain() const#
- Returns:
The shape of the buffer.
-
mapping::StoreTarget memory_kind() const#
- Returns:
The memory kind of the buffer.
-
template<typename T, std::int32_t DIM>
explicit operator Buffer<T, DIM>( Convert this object to a typed
Buffer
.Since
TaskLocalBuffer
is type-erased, there is not a whole lot you can do with it normally. Access to the underlying data (and ability to create accessors) is only possible with a typed buffer.- Returns:
The typed buffer.
-
InlineAllocation get_inline_allocation() const#
Get the
InlineAllocation
for the buffer.This routine constructs a fresh
InlineAllocation
for each call. This process may not be cheap, so the user is encouraged to call this sparingly.- Returns:
The inline allocation object.