6#include "dawn/prog/vecsplit.hxx"
11#include "dawn/debug.hxx"
12#include "dawn/io/common.hxx"
26CProgVecSplit::~CProgVecSplit()
37 output.data =
nullptr;
39 outputs.push_back(output);
44int CProgVecSplit::configureDesc(
const CDescObject &desc)
50 for (
size_t i = 0; i < desc.
getSize(); i++)
54 if (item->
cfgid.
s.
cls != CProgCommon::PROG_CLASS_VECSPLIT)
56 DAWNERR(
"vecsplit: unsupported cfg class 0x%" PRIx32
"\n", item->
cfgid.
v);
62 case PROG_VECSPLIT_CFG_SOURCE:
66 DAWNERR(
"vecsplit: SOURCE must have one item\n");
76 case PROG_VECSPLIT_CFG_OUTPUTS:
80 DAWNERR(
"vecsplit: OUTPUTS must not be empty\n");
85 for (
size_t j = 0; j < item->
cfgid.
s.
size; j++)
87 int ret = allocOutput(ids[j].v);
99 DAWNERR(
"vecsplit: unsupported cfg id %u\n", item->
cfgid.
s.
id);
105 if (sourceId == 0 || outputs.empty())
107 DAWNERR(
"vecsplit: source and outputs are required\n");
116 return configureDesc(
getDesc());
124 source =
getIO(sourceId);
125 if (source ==
nullptr || !source->
isRead())
127 DAWNERR(
"vecsplit: source 0x%" PRIx32
" not readable\n", sourceId);
131 for (
auto &output : outputs)
133 output.io =
getIO(output.ioId);
134 if (output.io ==
nullptr)
136 DAWNERR(
"vecsplit: output IO 0x%" PRIx32
" not found\n", output.ioId);
140 if (output.io->getDataDim() == 0)
142 ret = prepareWritableTarget(output.io, 1,
true);
145 DAWNERR(
"vecsplit: output prepare failed %d\n", ret);
150 if (output.io->getDtype() != source->
getDtype())
152 DAWNERR(
"vecsplit: output 0x%" PRIx32
" dtype mismatch\n", output.ioId);
157 dim += output.io->getDataDim();
158 output.data = output.io->ddata_alloc(1);
159 if (output.data ==
nullptr)
167 DAWNERR(
"vecsplit: outputs need %zu elements, source has %zu\n", dim, source->
getDataDim());
172 if (sourceData ==
nullptr)
185 sourceData =
nullptr;
186 for (
auto &output : outputs)
189 output.data =
nullptr;
199int CProgVecSplit::ioNotifierCb(
void *priv,
io_ddata_t *data)
203 if (self !=
nullptr && self->active)
205 self->updateOutputs(data);
215 if (!registered && source->
isNotify())
217 ret = source->setNotifier(ioNotifierCb, 0,
this);
220 DAWNERR(
"vecsplit: setNotifier failed %d\n", ret);
228 updateOutputs(
nullptr);
234 if (registered && source !=
nullptr && source->
isNotify())
236 source->setNotifier(
nullptr, 0,
nullptr);
249void CProgVecSplit::updateOutputs(
io_ddata_t *data)
253 if (source ==
nullptr || sourceData ==
nullptr)
262 else if (source->
getData(*sourceData, 1) != OK)
267 for (
auto &output : outputs)
269 std::memcpy(output.data->getDataPtr(),
270 static_cast<uint8_t *
>(sourceData->
getDataPtr()) +
272 output.data->getDataSize());
273 ret = output.io->setData(*output.data);
276 DAWNERR(
"vecsplit: output setData failed %d\n", ret);
CIOCommon * getIO(SObjectId::ObjectId id)
Get an I/O object by ID.
void setObjectMapItem(SObjectId::ObjectId id, CObject *obj)
Set an item in the object map.
Descriptor wrapper for individual object configuration.
size_t getSize() const
Get number of configuration items for this object.
SObjectCfg::SObjectCfgItem * objectCfgItemNext(size_t &offset) const
Get config item at current offset and advance past it.
int getData(IODataCmn &data, size_t len, size_t offset=0)
Get data from I/O (public interface with stats tracking).
virtual bool isNotify() const =0
Check if IO supports notifications.
virtual size_t getDataDim() const =0
Get data vector dimension.
io_ddata_t * ddata_alloc(size_t batch, size_t chunk_size=0)
Allocate data buffer for this I/O.
virtual bool isRead() const =0
Check if IO supports read operations.
CDescObject & getDesc()
Get descriptor object for this object.
size_t getDtypeSize() const
Get size of this object's data type.
uint8_t getDtype() const
Get data type field.
Base class for all PROG (processing) objects.
Vector splitter: splits one vector IO into multiple outputs.
int configure()
Configure object from descriptor data.
int init()
One-time initialize object after bindings are resolved.
int doStart()
Start implementation hook.
int doStop()
Stop implementation hook.
int deinit()
De-initialize object.
bool hasThread() const
Check if a background thread is active.
Out-of-tree user-extension hooks for Dawn.
Single configuration item within object.
ObjectCfgData_t data[]
Configuration data array (flexible, size from cfgid.s.size).
UObjectCfgId cfgid
Configuration ID header (type, class, id, size, rw, dtype).
uint32_t ObjectId
ObjectID type - single 32-bit value.
Heap-allocated dynamic I/O data buffer.
size_t getDataSize()
Get data size in bytes.
void * getDataPtr(size_t batch=0)
Get pointer to data only (skips timestamp if present).
ObjectCfgId v
Raw 32-bit ConfigID value (for storage, comparison).
uint32_t cls
Object class (bits 21-29, max 511).
uint32_t id
Configuration identifier (bits 0-4, max 31).
uint32_t size
Configuration data size in 32-bit words (bits 5-14, max 1023).
struct dawn::SObjectCfg::UObjectCfgId::@10 s
Bit-field structure for named member access.
32-bit encoded object identifier (union with bit field).
ObjectId v
Raw 32-bit ObjectID value (for comparison, hashing, storage).