Skip to main content

Mapping Struct

Scoped read/write window into a TensorBuffer. More...

Declaration

struct simaai::neat::Mapping { ... }

Included Headers

#include <TensorCore.h>

Public Constructors Index

Mapping ()=default

Construct an empty (unmapped) Mapping; assignable from a real mapping later. More...

Mapping (const Mapping &)=delete

Mappings are non-copyable: each Mapping uniquely owns its scope. More...

Mapping (Mapping &&other) noexcept

Move-construct from another Mapping; the source becomes empty. More...

Public Destructor Index

~Mapping ()

Destructor; runs unmap if set, releasing the mapping. More...

Public Operators Index

Mapping &operator= (const Mapping &)=delete

Mappings are non-copy-assignable: each Mapping uniquely owns its scope. More...

Mapping &operator= (Mapping &&other) noexcept

Move-assign from another Mapping; runs unmap on the prior contents first. More...

Public Member Attributes Index

void *data = ...

Pointer to mapped memory (CPU-readable for the duration of the Mapping). More...

std::size_tsize_bytes = 0

Size of the mapped region in bytes. More...

std::function< void()>unmap

Cleanup callback invoked on destructor (cache flush, refcount decrement). More...

std::shared_ptr< void >keepalive

Optional lifetime guard; ensures the underlying storage outlives the Mapping. More...

Description

Scoped read/write window into a TensorBuffer.

RAII: the destructor calls unmap (handling cache flush/sync). Move-only — a Mapping uniquely owns its mapping. Created by TensorBuffer::map(MapMode). Hold the Mapping while you read/write data; let it go out of scope to release.

 auto m = tensor.storage->map(MapMode::Read);
 const uint8_t* bytes = static_cast<const uint8_t*>(m.data);
 // ... read m.size_bytes from bytes ...

Definition at line 350 of file TensorCore.h.

Public Constructors

Mapping()

simaai::neat::Mapping::Mapping ()
default

Construct an empty (unmapped) Mapping; assignable from a real mapping later.

Definition at line 360 of file TensorCore.h.

Mapping()

simaai::neat::Mapping::Mapping (const Mapping &)
delete

Mappings are non-copyable: each Mapping uniquely owns its scope.

Definition at line 362 of file TensorCore.h.

Mapping()

simaai::neat::Mapping::Mapping (Mapping && other)
inline noexcept

Move-construct from another Mapping; the source becomes empty.

Definition at line 366 of file TensorCore.h.

366 Mapping(Mapping&& other) noexcept {
367 *this = std::move(other);
368 }

Public Destructor

~Mapping()

simaai::neat::Mapping::~Mapping ()
inline

Destructor; runs unmap if set, releasing the mapping.

Definition at line 386 of file TensorCore.h.

387 if (unmap)
388 unmap();
389 }

Public Operators

operator=()

Mapping & simaai::neat::Mapping::operator= (const Mapping &)
delete

Mappings are non-copy-assignable: each Mapping uniquely owns its scope.

Definition at line 364 of file TensorCore.h.

operator=()

Mapping & simaai::neat::Mapping::operator= (Mapping && other)
inline noexcept

Move-assign from another Mapping; runs unmap on the prior contents first.

Definition at line 370 of file TensorCore.h.

370 Mapping& operator=(Mapping&& other) noexcept {
371 if (this != &other) {
372 if (unmap)
373 unmap();
374 data = other.data;
375 size_bytes = other.size_bytes;
376 unmap = std::move(other.unmap);
377 keepalive = std::move(other.keepalive);
378 other.data = nullptr;
379 other.size_bytes = 0;
380 other.unmap = nullptr;
381 other.keepalive.reset();
382 }
383 return *this;
384 }

Public Member Attributes

data

void* simaai::neat::Mapping::data

Pointer to mapped memory (CPU-readable for the duration of the Mapping).

Initialiser
= nullptr

Definition at line 351 of file TensorCore.h.

351 void* data =

keepalive

std::shared_ptr<void> simaai::neat::Mapping::keepalive

Optional lifetime guard; ensures the underlying storage outlives the Mapping.

Definition at line 357 of file TensorCore.h.

size_bytes

std::size_t simaai::neat::Mapping::size_bytes = 0

Size of the mapped region in bytes.

Definition at line 353 of file TensorCore.h.

353 std::size_t size_bytes = 0;

unmap

std::function<void()> simaai::neat::Mapping::unmap

Cleanup callback invoked on destructor (cache flush, refcount decrement).

Definition at line 355 of file TensorCore.h.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.