13#include "dawn/io/idata.hxx"
14#include "dawn/porting/config.hxx"
36 return (size + word_size - 1) & ~(word_size - 1);
49 explicit io_ddata_t(
size_t t,
size_t n = 1,
size_t m = 1, uint8_t dt = 0,
bool ts =
false)
52 size_t tsSize = ts ?
sizeof(
io_ts_t) : 0;
54 assert(t == 1 || t == 2 || t == 4 || t == 8);
62 this->len = this->off * m;
66 this->data =
new (std::nothrow) uint8_t[this->len]();
79 bool isAllocated()
const
81 return data !=
nullptr;
93 constexpr T &
get(
size_t index,
size_t batch = 0)
95 size_t tsOff = this->hasTs ?
sizeof(
io_ts_t) : 0;
97 assert(index < this->N);
98 assert(batch < this->M);
100 size_t i = this->off * batch + index *
sizeof(T) + tsOff;
101 T *ptr =
reinterpret_cast<T *
>(&data[i]);
115 assert(batch < this->M);
116 return this->
getTs(batch);
155 return this->T * this->N;
168 constexpr void *
getPtr(
size_t batch = 0)
override
170 return (
void *)&data[this->off * batch];
182 size_t tsOff = this->hasTs ?
sizeof(
io_ts_t) : 0;
183 return (
void *)&data[this->off * batch + tsOff];
210 size_t i = this->off * batch;
Out-of-tree user-extension hooks for Dawn.
uint64_t io_ts_t
Timestamp data type (uint64_t, typically microseconds since boot).
Heap-allocated dynamic I/O data buffer.
uint8_t getDtype() const
Get data type enum for introspection.
size_t getBufferSize() const
Get total buffer size in bytes.
size_t getBatch() const
Get number of batches.
io_ts_t & operator[](size_t batch)
Get timestamp reference via bracket operator.
size_t getDataSize()
Get data size in bytes.
void * getDataPtr(size_t batch=0)
Get pointer to data only (skips timestamp if present).
bool hasTimestamp()
Check if this buffer has per-batch timestamp storage.
size_t getSize() const
Get element size in bytes.
size_t getItems()
Get number of items per batch.
T & get(size_t index, size_t batch=0)
Get data element by index and batch (type-safe).
~io_ddata_t()
Destructor - deallocate heap buffer.
size_t ALIGN_TO_WORD_SIZE(size_t size, size_t word_size)
Align size to word boundary.
io_ddata_t(size_t t, size_t n=1, size_t m=1, uint8_t dt=0, bool ts=false)
Constructor - allocate heap buffer with M batches.
io_ts_t & getTs(size_t batch=0)
Get timestamp reference for batch.
void * getPtr(size_t batch=0)
Get pointer to batch.