Contents

class

SushiBLAS::Storage

A class to manage memory for tensors.

Declared in
include/SushiBLAS/storage.hpp
Inherits
SushiRuntime::Core::RefCounted

This class holds the pointer to memory and information about the allocation. it uses SYCL Unified Shared Memory (USM) through a SushiRuntime RuntimeContext. It is reference counted to help share data safely between tensors.

Public member functions

Storage(SushiRuntime::Execution::RuntimeContext &ctx, size_t n_bytes, SushiRuntime::API::Residency residency=SushiRuntime::API::Residency::Shared, size_t device_index=0)

Allocates aligned memory of n_bytes from a runtime context, with a residency.

Parameters

ctx

Runtime context that performs the allocation; must outlive this Storage.

n_bytes

Number of bytes requested.

residency

Kind of USM to allocate.

device_index

Device queue that owns the allocation.

Exceptions

std::runtime_error

if the size is zero or the allocation fails.

Storage(const Storage &)=delete
Storage & operator=(const Storage &)=delete
void * allocation_base() const noexcept

Returns the base address of the whole allocation, ignoring every view's offset.

Returns

The pointer the runtime context handed back, or nullptr before construction completed.

Warning

Never a tensor's data; use Tensor::data() to address elements.

See also

include/SushiBLAS/README.md

SushiRuntime::Execution::RuntimeContext & get_context() const noexcept

Returns the runtime context that made the allocation and frees it.

Warning

Non-owning; the context must outlive every Storage, as it must outlive Engine.

SushiRuntime::API::Residency get_residency() const noexcept

Returns the kind of USM the allocation lives in (Shared, Device, or Host).

size_t get_device_index() const noexcept

Returns the device queue that owns the allocation.

size_t size_bytes() const noexcept

Returns the allocated size in bytes: the requested size rounded up to DEFAULT_ALIGNMENT.

Protected member functions

~Storage() override

Destroy the Storage object.

This will automatically free the allocated memory.