Fix fanout naming for debug graph
Some checks failed
🧪 Test / test (push) Failing after 2m38s

This commit is contained in:
Duncan Tourolle 2026-05-09 09:54:40 +02:00
parent da8f4d9926
commit 9acc42b2e9
3 changed files with 35 additions and 8 deletions

View File

@ -51,9 +51,10 @@ public:
using return_tuple = detail::repeat_tuple_t<T, N>;
using return_raw = return_tuple;
static constexpr std::size_t input_count = 1;
static constexpr std::size_t output_count = N;
static constexpr std::size_t unique_tag = Id;
static constexpr std::size_t input_count = 1;
static constexpr std::size_t output_count = N;
static constexpr std::size_t unique_tag = Id;
static constexpr bool is_fanout_node = true;
explicit FanoutNode(std::size_t fifo_capacity = 5)
: fifo_capacity_(fifo_capacity)

View File

@ -101,9 +101,9 @@ public:
}
template<std::size_t I>
InputPort<MainThreadNode, I> input() {
InputPort<Derived, I> input() {
static_assert(I < input_count, "input index out of range");
return {*this};
return {static_cast<Derived&>(*this)};
}
template<fixed_string Name>

View File

@ -72,6 +72,8 @@ std::string node_display_name() {
constexpr std::string_view lbl = node_label_v<NodeT>;
if constexpr (!lbl.empty()) {
return std::string(lbl);
} else if constexpr (requires { NodeT::is_fanout_node; NodeT::unique_tag; }) {
return "fanout[" + std::to_string(NodeT::unique_tag) + "]";
} else if constexpr (requires { NodeT::unique_tag; }) {
return "node[" + std::to_string(NodeT::unique_tag) + "]";
} else {
@ -261,6 +263,29 @@ auto make_network(Edges&&... edges) {
return ptr;
};
// Pre-pass: build fanout_id → source display name map so fanout nodes
// can be named after the node feeding them (e.g. "capture_fanout").
std::map<std::size_t, std::string> fanout_src_name;
[&]<typename... SEs>(tmp::TypeList<SEs...>) {
([&]<typename SE>(SE) {
using DstNode = typename SE::dst_node_t;
using SrcNode = typename SE::src_node_t;
if constexpr (requires { DstNode::is_fanout_node; })
fanout_src_name.emplace(DstNode::unique_tag, node_display_name<SrcNode>());
}(SEs{}), ...);
}(ExpandedEdges{});
// Helper: display name for any node type, resolving fanouts to "src_fanout".
auto node_name = [&]<typename NodeT>() -> std::string {
if constexpr (requires { NodeT::is_fanout_node; }) {
auto it = fanout_src_name.find(NodeT::unique_tag);
return it != fanout_src_name.end() ? it->second + "_fanout"
: node_display_name<NodeT>();
} else {
return node_display_name<NodeT>();
}
};
std::vector<std::unique_ptr<IChannelProbe>> channel_probes;
auto wire_one = [&]<typename SE>(SE) {
@ -275,9 +300,9 @@ auto make_network(Edges&&... edges) {
if (src && dst) {
auto& ch = dst->template input_channel<DstIdx>();
src->template set_output_channel<SrcIdx>(&ch);
std::string ch_name = node_display_name<SrcNode>() + ":" + std::to_string(SrcIdx)
std::string ch_name = node_name.template operator()<SrcNode>() + ":" + std::to_string(SrcIdx)
+ " \xe2\x86\x92 " // UTF-8 →
+ node_display_name<DstNode>() + ":" + std::to_string(DstIdx);
+ node_name.template operator()<DstNode>() + ":" + std::to_string(DstIdx);
channel_probes.push_back(std::make_unique<ChannelProbe<out_t>>(ch, ch_name));
}
};
@ -291,8 +316,9 @@ auto make_network(Edges&&... edges) {
std::vector<std::string> fanout_node_names;
std::apply([&](auto&... fn) {
([&](auto& node) {
using NodeT = std::decay_t<decltype(node)>;
fanout_ptrs.push_back(static_cast<INode*>(&node));
fanout_node_names.push_back(node_display_name<std::decay_t<decltype(node)>>());
fanout_node_names.push_back(node_name.template operator()<NodeT>());
}(fn), ...);
}, *fanout_storage);