Skip to navigation

holoscan::MemoryBuffer

Beta
View as Markdown
#include <holoscan/memory_buffer.hpp>

Constructors

MemoryBuffer

holoscan::MemoryBuffer::MemoryBuffer() = default

Destructor

~MemoryBuffer

virtual holoscan::MemoryBuffer::~MemoryBuffer()

Assignment operators

operator=

MemoryBuffer & holoscan::MemoryBuffer::operator=(
MemoryBuffer &&other
) noexcept

Methods

set_max_fanout_release_streams

expected<void, Error> holoscan::MemoryBuffer::set_max_fanout_release_streams(
std::size_t capacity
)

max_fanout_release_streams

std::size_t holoscan::MemoryBuffer::max_fanout_release_streams() const noexcept

free_buffer

expected<void, Error> holoscan::MemoryBuffer::free_buffer()

resize

expected<void, Error> holoscan::MemoryBuffer::resize(
std::shared_ptr<Allocator> allocator,
uint64_t size,
MemoryStorageType storage_type,
void *stream = nullptr
)

Resize the buffer using a native allocator.

Returns: Success or the original release/allocation Error. Failed release retains the backing storage and prevents a new allocation. Reporting follows the automatic diagnostic policy and cannot replace the returned failure. Use set_stream() to record later consumer work.

Parameters

allocator
std::shared_ptr<Allocator>

Allocator that owns the new backing storage.

size
uint64_t

Requested size in bytes.

storage_type
MemoryStorageType

Requested storage location.

stream
void *Defaults to nullptr

Optional CUDA stream for stream-aware allocation and release.

wrap_memory

expected<void, Error> holoscan::MemoryBuffer::wrap_memory(
void *pointer,
uint64_t size,
MemoryStorageType storage_type,
release_function_t release_func,
int32_t device_id = Allocator::kUnknownDeviceId
)

Wrap externally allocated memory.

Returns: Empty success or Error when existing storage cannot be released or initialized.

Parameters

pointer
void *

Backing memory pointer.

size
uint64_t

Backing memory size in bytes.

storage_type
MemoryStorageType

Memory storage type.

release_func
release_function_t

Optional ownership-release callback.

device_id
int32_tDefaults to Allocator::kUnknownDeviceId

CUDA ordinal or Allocator::kUnknownDeviceId.

storage_type

MemoryStorageType holoscan::MemoryBuffer::storage_type() const noexcept

pointer

std::byte * holoscan::MemoryBuffer::pointer() const noexcept

size

uint64_t holoscan::MemoryBuffer::size() const noexcept

device_id

int32_t holoscan::MemoryBuffer::device_id() const noexcept

set_stream

bool holoscan::MemoryBuffer::set_stream(
void *stream
)

stream

void * holoscan::MemoryBuffer::stream() const noexcept

stream_state

std::shared_ptr<StreamState> holoscan::MemoryBuffer::stream_state() const

report_release_failure

static HOLOSCAN_CORE_EXPORT void holoscan::MemoryBuffer::report_release_failure(
const Error &error,
std::source_location location = std::source_location::current()
) noexcept

Present a release failure through the shared native automatic-report policy.

Parameters

error
const Error &

Original failure, borrowed without rendering until presentation is enabled.

location
std::source_locationDefaults to std::source_location::current()

Inline resize call site retained for the normal logger.

report_allocation_failure

static HOLOSCAN_CORE_EXPORT void holoscan::MemoryBuffer::report_allocation_failure(
const Error &error,
uint64_t size,
MemoryStorageType storage_type,
std::source_location location = std::source_location::current()
) noexcept

Present an allocation rejection without changing the allocator’s Error.

Parameters

error
const Error &

Original failure, borrowed until this synchronous call returns.

size
uint64_t

Requested size in bytes.

storage_type
MemoryStorageType

Requested storage location.

location
std::source_locationDefaults to std::source_location::current()

Inline resize call site retained for the normal logger.


Static methods

validate_fanout_release_stream_capacity

static expected<void, Error> holoscan::MemoryBuffer::validate_fanout_release_stream_capacity(
std::size_t capacity
)

Types

Typedefs

NameDefinition
release_function_tstd::function< expected< void, Error >(void *pointer)>

Member variables

NameTypeDescription
kMaximumFanoutReleaseStreams static constexprstd::size_tMaximum number of distinct CUDA consumer streams retained by one backing allocation.
kDefaultMaxFanoutReleaseStreams static constexprstd::size_tDefault consumer-stream capacity for allocations without a plan-derived bound.
max_fanout_release_streams_std::size_t
size_uint64_t
pointer_std::byte *
storage_type_MemoryStorageType
device_id_int32_t
release_func_release_function_t
stream_state_std::shared_ptr< StreamState >

Inner classes

Options

struct holoscan::MemoryBuffer::Options
NameTypeDescription
max_fanout_release_streamsstd::size_t

StreamState

struct holoscan::MemoryBuffer::StreamState
NameTypeDescription
max_release_streamsconst std::size_t
initial_streamstd::atomic< void * >
release_streamsstd::array< std::atomic< void * >, kMaximumFanoutReleaseStreams >
join_streamcudaStream_t
release_eventsstd::array< cudaEvent_t, kMaximumFanoutReleaseStreams >
sync_resources_initializedbool