6#include "dawn/prog/manytoone.hxx"
10#include "dawn/debug.hxx"
11#include "dawn/io/common.hxx"
25CProgManyToOne::~CProgManyToOne()
37 inputs.push_back(input);
42int CProgManyToOne::configureDesc(
const CDescObject &desc)
48 for (
size_t i = 0; i < desc.
getSize(); i++)
52 if (item->
cfgid.
s.
cls != CProgCommon::PROG_CLASS_MANYTOONE)
54 DAWNERR(
"manytoone: unsupported cfg class 0x%" PRIx32
"\n", item->
cfgid.
v);
60 case PROG_MANYTOONE_CFG_INPUTS:
64 DAWNERR(
"manytoone: INPUTS must not be empty\n");
69 for (
size_t j = 0; j < item->
cfgid.
s.
size; j++)
71 int ret = allocInput(ids[j].v);
80 case PROG_MANYTOONE_CFG_OUTPUT:
84 DAWNERR(
"manytoone: OUTPUT must have one item\n");
95 DAWNERR(
"manytoone: unsupported cfg id %u\n", item->
cfgid.
s.
id);
100 if (inputs.empty() || outputId == 0)
102 DAWNERR(
"manytoone: inputs and output are required\n");
111 return configureDesc(
getDesc());
114int CProgManyToOne::validateShape(
CIOCommon *io)
const
116 if (io ==
nullptr || output ==
nullptr)
133 output =
getIO(outputId);
134 if (output ==
nullptr)
136 DAWNERR(
"manytoone: output IO 0x%" PRIx32
" not found\n", outputId);
140 for (
auto &input : inputs)
142 input.io =
getIO(input.ioId);
143 if (input.io ==
nullptr)
145 DAWNERR(
"manytoone: input IO 0x%" PRIx32
" not found\n", input.ioId);
150 int ret = prepareWritableTarget(output, inputs[0].io->
getDataDim(),
true);
153 DAWNERR(
"manytoone: output prepare failed %d\n", ret);
157 for (
auto &input : inputs)
159 ret = validateShape(input.io);
162 DAWNERR(
"manytoone: input 0x%" PRIx32
" incompatible\n", input.ioId);
168 if (dataBuf ==
nullptr)
170 DAWNERR(
"manytoone: data allocation failed\n");
188int CProgManyToOne::ioNotifierCb(
void *priv,
io_ddata_t *data)
190 SInput *input =
static_cast<SInput *
>(priv);
192 if (input ==
nullptr || input->owner ==
nullptr || !input->owner->active || data ==
nullptr)
197 int ret = input->owner->output->setData(*data);
200 DAWNERR(
"manytoone: output setData failed %d\n", ret);
211 for (
auto &input : inputs)
213 int ret = input.io->setNotifier(ioNotifierCb, 0, &input);
216 DAWNERR(
"manytoone: setNotifier failed for 0x%" PRIx32
": %d\n", input.ioId, ret);
232 for (
auto &input : inputs)
234 if (input.io !=
nullptr)
236 input.io->setNotifier(
nullptr, 0,
nullptr);
251void CProgManyToOne::writeInput(
size_t index)
253 if (index >= inputs.size() || dataBuf ==
nullptr || output ==
nullptr)
258 if (inputs[index].io->
getData(*dataBuf, 1) != OK)
263 int ret = output->
setData(*dataBuf);
266 DAWNERR(
"manytoone: 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.
Base class for all I/O objects.
int setData(IODataCmn &data, size_t offset=0)
Set data for I/O (public interface with stats tracking).
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.
bool isTimestamp() const
Check if I/O supports timestamp.
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 size_t getDataSize() const =0
Get data size in bytes.
virtual bool isRead() const =0
Check if IO supports read operations.
CDescObject & getDesc()
Get descriptor object for this object.
uint8_t getDtype() const
Get data type field.
Base class for all PROG (processing) objects.
bool hasThread() const
Check if a background thread is active.
int doStart()
Start implementation hook.
int init()
One-time initialize object after bindings are resolved.
int deinit()
De-initialize object.
int doStop()
Stop implementation hook.
int configure()
Configure object from descriptor data.
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.
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).