From c273614e87b3bb3f5099e0b4eb035b9fcdf2fa17 Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Fri, 4 Oct 2024 05:27:43 +0000 Subject: [PATCH] merlin/bridge: load user subcomponent for networkIF pymerlin expects to override a SimpleNetwork subcomponent with its own network subcomponent (e.g., LinkControl). When using a Bridge, this subcomponent is ignored and link initialization crashes on SST::Link::sendUntimedData when trying to access a null rtr object. This patch extends the Bridge component to use the user subcomponent if the subcomponent slot is populated and if not then fall back to using an anonymous subcomponent as before. --- src/sst/elements/merlin/bridge.h | 40 ++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/sst/elements/merlin/bridge.h b/src/sst/elements/merlin/bridge.h index f2217804f6..3ba45cd0ee 100644 --- a/src/sst/elements/merlin/bridge.h +++ b/src/sst/elements/merlin/bridge.h @@ -204,25 +204,29 @@ class Bridge : public SST::Component { dbg.debug(CALL_INFO, 2, 0, "Initializing network interface %d\n", id); Nic_t &nic = interfaces[id]; - Params if_params; - - if_params.insert("link_bw",params.find("network_bw","80GiB/s")); - if_params.insert("input_buf_size",params.find("network_input_buffer_size", "1KiB")); - if_params.insert("output_buf_size",params.find("network_output_buffer_size", "1KiB")); - if_params.insert("port_name","network" + std::to_string(id)); - - nic.nic = loadAnonymousSubComponent - ("merlin.linkcontrol", "networkIF", id, - ComponentInfo::SHARE_PORTS | ComponentInfo::INSERT_STATS, if_params, 1 /* vns */); - + SubComponentSlotInfo *info = getSubComponentSlotInfo("networkIF"); + if (info) { + int maxSlot = info->getMaxPopulatedSlotNumber(); + if (maxSlot > 1) { + dbg.fatal(CALL_INFO, 1, + "May only specify slots 0 and 1 for 'networkIF'; maximum slot given: %d.\n", + maxSlot); + } + } + if (!info || !info->isPopulated(id)) { + Params if_params; + if_params.insert("link_bw",params.find("network_bw","80GiB/s")); + if_params.insert("input_buf_size",params.find("network_input_buffer_size", "1KiB")); + if_params.insert("output_buf_size",params.find("network_output_buffer_size", "1KiB")); + if_params.insert("port_name","network" + std::to_string(id)); + + nic.nic = loadAnonymousSubComponent + ("merlin.linkcontrol", "networkIF", id, + ComponentInfo::SHARE_PORTS | ComponentInfo::INSERT_STATS, if_params, 1 /* vns */); + } else { + nic.nic = info->create(id, ComponentInfo::SHARE_PORTS, 1 /* vns */); + } - // nic.nic = (SimpleNetwork*)loadSubComponent("merlin.linkcontrol", this, params); - // nic.nic->initialize( "network" + std::to_string(id), - // params.find("network_bw", SST::UnitAlgebra("80GiB/s")), - // 1, /* should be num VN */ - // params.find("network_input_buffer_size", SST::UnitAlgebra("1KiB")), - // params.find("network_output_buffer_size", SST::UnitAlgebra("1KiB"))); - nic.nic->setNotifyOnReceive(new SimpleNetwork::Handler(this, &Bridge::handleIncoming, id)); sendNotify[id] = new SimpleNetwork::Handler(this, &Bridge::spaceAvailable, id);