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 377 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 387 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 389 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 393 of file TensorCore.h.

393 Mapping(Mapping&& other) noexcept {
394 *this = std::move(other);
395 }

Public Destructor

~Mapping()

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

Destructor; runs unmap if set, releasing the mapping.

Definition at line 413 of file TensorCore.h.

414 if (unmap)
415 unmap();
416 }

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 391 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 397 of file TensorCore.h.

397 Mapping& operator=(Mapping&& other) noexcept {
398 if (this != &other) {
399 if (unmap)
400 unmap();
401 data = other.data;
402 size_bytes = other.size_bytes;
403 unmap = std::move(other.unmap);
404 keepalive = std::move(other.keepalive);
405 other.data = nullptr;
406 other.size_bytes = 0;
407 other.unmap = nullptr;
408 other.keepalive.reset();
409 }
410 return *this;
411 }

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 378 of file TensorCore.h.

378 void* data =

keepalive

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

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

Definition at line 384 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 380 of file TensorCore.h.

380 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 382 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.