diff options
author | Martin Braun <martin.braun@ettus.com> | 2019-06-03 23:28:19 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 11:49:24 -0800 |
commit | 01f08d3fa5ae0cd8a2fc3c6e1112117a1f7f9768 (patch) | |
tree | 7fb49f7e0ab5329c29c292df001cd61390eae5f0 /host/lib/rfnoc/graph.cpp | |
parent | 802afa6eecee368ec8e28044ce22fd39c0f93ae8 (diff) | |
download | uhd-01f08d3fa5ae0cd8a2fc3c6e1112117a1f7f9768.tar.gz uhd-01f08d3fa5ae0cd8a2fc3c6e1112117a1f7f9768.tar.bz2 uhd-01f08d3fa5ae0cd8a2fc3c6e1112117a1f7f9768.zip |
rfnoc: Add check_topology() API to nodes
This API lets blocks decide if their current topology is OK for them,
and make decisions based on their topology.
Diffstat (limited to 'host/lib/rfnoc/graph.cpp')
-rw-r--r-- | host/lib/rfnoc/graph.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/host/lib/rfnoc/graph.cpp b/host/lib/rfnoc/graph.cpp index f687e8984..cbb7ab140 100644 --- a/host/lib/rfnoc/graph.cpp +++ b/host/lib/rfnoc/graph.cpp @@ -177,6 +177,7 @@ void graph_t::commit() { if (_release_count) { _release_count--; + _check_topology(); } UHD_LOG_TRACE(LOG_ID, "graph::commit() => " << _release_count.load()); resolve_all_properties(); @@ -524,6 +525,41 @@ bool graph_t::_assert_edge_props_consistent(rfnoc_graph_t::edge_descriptor edge) return props_match; } +void graph_t::_check_topology() +{ + node_accessor_t node_accessor{}; + bool topo_ok = true; + auto v_iterators = boost::vertices(_graph); + for (auto it = v_iterators.first; it != v_iterators.second; ++it) { + node_ref_t node = boost::get(vertex_property_t(), _graph, *it); + std::vector<size_t> connected_inputs; + std::vector<size_t> connected_outputs; + auto ie_iters = boost::in_edges(*it, _graph); + for (auto it = ie_iters.first; it != ie_iters.second; ++it) { + graph_edge_t edge_info = boost::get(edge_property_t(), _graph, *it); + connected_inputs.push_back(edge_info.dst_port); + } + auto oe_iters = boost::out_edges(*it, _graph); + for (auto it = oe_iters.first; it != oe_iters.second; ++it) { + graph_edge_t edge_info = boost::get(edge_property_t(), _graph, *it); + connected_outputs.push_back(edge_info.src_port); + } + + if (!node_accessor.check_topology(node, connected_inputs, connected_outputs)) { + UHD_LOG_ERROR(LOG_ID, + "Node " << node->get_unique_id() + << "cannot handle its current topology! (" + << connected_inputs.size() << "inputs, " + << connected_outputs.size() << " outputs)"); + topo_ok = false; + } + } + + if (!topo_ok) { + throw uhd::runtime_error("Graph topology is not valid!"); + } +} + std::pair<graph_t::node_ref_t, graph_t::graph_edge_t> graph_t::_find_neighbour( rfnoc_graph_t::vertex_descriptor origin, res_source_info port_info) { |