Skip to content

Commit

Permalink
DFCxx: kernel instantiation was added (ver. 4).
Browse files Browse the repository at this point in the history
  • Loading branch information
Litvinov Mikhail committed Nov 19, 2024
1 parent a087161 commit 8f9118a
Showing 1 changed file with 11 additions and 28 deletions.
39 changes: 11 additions & 28 deletions src/model/dfcxx/lib/dfcxx/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,45 +233,28 @@ bool Kernel::simulate(const std::string &inDataPath,
}

bool Kernel::check() const {
std::cout << "[UTOPIA] Checking whether constructed nodes are valid..." << std::endl;
if (!checkValidNodes()) {
std::cout << "[UTOPIA] Error: found invalid nodes. Abort." << std::endl;
return false;
}
return true;
}

bool Kernel::checkValidNodes() const {
const auto &nodes = meta.graph.getNodes();
const auto &startNodes = meta.graph.getStartNodes();
const auto &inputs = meta.graph.getInputs();
const auto &outputs = meta.graph.getOutputs();
const auto &connections = meta.graph.getConnections();
std::cout << "[UTOPIA] Kernel: " << getName() << std::endl;
std::cout << "[UTOPIA] Nodes: " << nodes.size() << std::endl;
std::cout << "[UTOPIA] Start nodes: " << startNodes.size() << std::endl;
std::cout << "[UTOPIA] Connections: " << connections.size() << std::endl;

return checkValidNodes();
}

bool Kernel::checkValidNodes() const {
std::cout << "[UTOPIA] Checking whether constructed nodes are valid: ";

const auto &nodes = meta.graph.getNodes();
for (const Node &node: nodes) {
std::cout << "[UTOPIA] -----" << std::endl;
std::cout << "[UTOPIA] Node type: " << uint32_t(node.type) << std::endl;
std::cout << "[UTOPIA] Node var: " << node.var << std::endl;
auto &ins = inputs.at(node);
std::cout << "[UTOPIA] Inputs count: " << inputs.at(node).size() << std::endl;
for (int i = 0; i < ins.size(); ++i) {
std::cout << "[UTOPIA] Input #" << (i + 1) << ": " << ins[i].source.var << std::endl;
}
auto &outs = outputs.at(node);
std::cout << "[UTOPIA] Outputs count: " << outputs.at(node).size() << std::endl;
for (int i = 0; i < outs.size(); ++i) {
std::cout << "[UTOPIA] Output #" << (i + 1) << ": " << outs[i].target.var << std::endl;
}
if (connections.find(node) != connections.end()) {
std::cout << "[UTOPIA] Connect: " << connections.at(node).source.var << std::endl;
}
if (node.type == OpType::NONE) {
std::cout << "[UTOPIA] Error: NONE-type node found." << std::endl;
std::cout << "found invalid node(s). Abort." << std::endl;
return false;
}
}
std::cout << "finished." << std::endl;
return true;
}

Expand Down

0 comments on commit 8f9118a

Please sign in to comment.