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 356 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 366 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 368 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 372 of file TensorCore.h.

372 Mapping(Mapping&& other) noexcept {
373 *this = std::move(other);
374 }

Public Destructor

~Mapping()

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

Destructor; runs unmap if set, releasing the mapping.

Definition at line 392 of file TensorCore.h.

393 if (unmap)
394 unmap();
395 }

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

376 Mapping& operator=(Mapping&& other) noexcept {
377 if (this != &other) {
378 if (unmap)
379 unmap();
380 data = other.data;
381 size_bytes = other.size_bytes;
382 unmap = std::move(other.unmap);
383 keepalive = std::move(other.keepalive);
384 other.data = nullptr;
385 other.size_bytes = 0;
386 other.unmap = nullptr;
387 other.keepalive.reset();
388 }
389 return *this;
390 }

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

357 void* data =

keepalive

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

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

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

359 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 361 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.