Skip to content

Commit 18399d4

Browse files
committed
fixing makefile, add ember test file
1 parent a8da77c commit 18399d4

File tree

4 files changed

+167
-4
lines changed

4 files changed

+167
-4
lines changed

src/sst/elements/merlin/Makefile.am

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ libmerlin_la_SOURCES = \
3838
test/simple_patterns/shift.cc \
3939
test/simple_patterns/incast.h \
4040
test/simple_patterns/incast.cc \
41+
topology/anytopo.h\
42+
topology/anytopo.cc\
4143
topology/torus.h \
4244
topology/torus.cc \
4345
topology/mesh.h \
@@ -75,6 +77,11 @@ libmerlin_la_SOURCES = \
7577
interfaces/reorderLinkControl.cc \
7678
interfaces/output_arb_basic.h \
7779
interfaces/output_arb_qos_multi.h \
80+
interfaces/endpointNIC/endpointNIC.h \
81+
interfaces/endpointNIC/endpointNIC.cc \
82+
interfaces/endpointNIC/NICPlugin.h \
83+
interfaces/endpointNIC/SourceRouting.h \
84+
interfaces/endpointNIC/SourceRouting.cc \
7885
arbitration/single_arb.h \
7986
arbitration/single_arb_lru.h \
8087
arbitration/single_arb_rr.h \
@@ -86,6 +93,7 @@ libmerlin_la_SOURCES = \
8693
pymerlin-router.py \
8794
interfaces/pymerlin-interface.py \
8895
target_generator/pymerlin-targetgen.py \
96+
topology/pymerlin-topo-any.py \
8997
topology/pymerlin-topo-dragonfly.py \
9098
topology/pymerlin-topo-polarfly.py \
9199
topology/pymerlin-topo-polarstar.py \
@@ -139,6 +147,7 @@ BUILT_SOURCES = \
139147
interfaces/pymerlin-interface.inc \
140148
target_generator/pymerlin-targetgen.inc \
141149
topology/pymerlin-topo-dragonfly.inc \
150+
topology/pymerlin-topo-any.inc \
142151
topology/pymerlin-topo-polarfly.inc \
143152
topology/pymerlin-topo-polarstar.inc \
144153
topology/pymerlin-topo-hyperx.inc \
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
2+
import os
3+
import sys
4+
import sst
5+
from sst.merlin.base import *
6+
from sst.merlin.endpoint import *
7+
from sst.merlin.interface import *
8+
from sst.merlin.topology import *
9+
from sst.ember import *
10+
11+
try:
12+
import networkx as nx
13+
except ImportError:
14+
print("NetworkX is required. Please install NetworkX and try again.")
15+
sys.exit(1)
16+
17+
18+
def prepare_complete_4(write_to_file: bool = False):
19+
'''
20+
Prepare a complete graph with 4 vertices.\n
21+
If write_to_file is True, write the graph to a GraphML file.\n
22+
Returns the graph (or file path) and topology name.
23+
'''
24+
# Create a complete graph with 4 vertices
25+
G = nx.complete_graph(4)
26+
# Add endpoint attributes to each vertex
27+
# For this test, we'll assign 2 endpoints per vertex
28+
for node in G.nodes():
29+
G.nodes[node]['endpoints'] = 2
30+
31+
if write_to_file:
32+
# Write the graph to a GraphML file
33+
graph_file = "test_complete_4.graphml"
34+
nx.write_graphml(G, graph_file)
35+
print(f"Generated complete graph with 4 vertices and saved to {graph_file}")
36+
return graph_file, "complete_4"
37+
else:
38+
return G, "complete_4"
39+
40+
def prepare_cubical_graph(write_to_file: bool = False):
41+
'''
42+
Prepare a cubical graph with 8 vertices and 12 edges.\n
43+
If write_to_file is True, write the graph to a GraphML file.\n
44+
Returns the graph (or file path) and topology name.
45+
'''
46+
# Create a cubical graph with 8 vertices
47+
G = nx.cubical_graph()
48+
# Add endpoint attributes to each vertex
49+
# For this test, we'll assign 2 endpoints per vertex
50+
for node in G.nodes():
51+
G.nodes[node]['endpoints'] = 2
52+
53+
if write_to_file:
54+
# Write the graph to a GraphML file
55+
graph_file = "test_cubical.graphml"
56+
nx.write_graphml(G, graph_file)
57+
print(f"Generated cubical graph with 8 vertices and saved to {graph_file}")
58+
return graph_file, "cubical"
59+
else:
60+
return G, "cubical"
61+
62+
def run_sst(input_graph: str | nx.Graph, topo_name: str, SR_routing_table: dict = None):
63+
64+
UNIFIED_ROUTER_LINK_BW=UNIFIED_ROUTER_LINK_BW=16
65+
66+
BENCH="FFT3D"
67+
BENCH_PARAMS=" nx=100 ny=100 nz=100 npRow=2"
68+
CPE=1
69+
EPR = input_graph.nodes[0]['endpoints'] # Endpoints per router
70+
71+
### Setup the topology, read graph from file
72+
topo = topoAny()
73+
topo.routing_mode = "source_routing"
74+
topo.topo_name = topo_name
75+
topo.import_graph(input_graph)
76+
# topo.set_verbose_level(16) # Set verbose level for debugging
77+
78+
defaults_z = PlatformDefinition.compose("firefly-defaults-Z",[("firefly-defaults","ALL")])
79+
defaults_z.addParamSet("nic",{
80+
"num_vNics": CPE,
81+
})
82+
PlatformDefinition.setCurrentPlatform("firefly-defaults-Z")
83+
# PlatformDefinition.setCurrentPlatform("firefly-defaults")
84+
85+
86+
# Set up the routers
87+
router = hr_router()
88+
router.link_bw = f"{UNIFIED_ROUTER_LINK_BW}Gb/s"
89+
router.flit_size = "32B"
90+
router.xbar_bw = f"{UNIFIED_ROUTER_LINK_BW*2}Gb/s" # 2x crossbar speedup
91+
router.input_latency = "20ns"
92+
router.output_latency = "20ns"
93+
router.input_buf_size = "32kB"
94+
router.output_buf_size = "32kB"
95+
router.num_vns = 2
96+
router.xbar_arb = "merlin.xbar_arb_rr"
97+
98+
topo.router = router
99+
topo.link_latency = "20ns"
100+
topo.host_link_latency = "10ns"
101+
102+
_SR_routing_table: dict
103+
104+
if SR_routing_table is not None:
105+
# The source routing table can be passed from input arg
106+
_SR_routing_table = SR_routing_table
107+
else:
108+
# Otherwise, the source routing tables can be calculated here from the topology class method
109+
# by default, use All Shortest Paths (ASP) will be calculated
110+
_SR_routing_table = topo.calculate_routing_table()
111+
112+
### use endpointNIC
113+
endpointNIC = EndpointNIC(use_reorderLinkControl=True, topo=topo)
114+
115+
# source routing table is passed to the plugin here
116+
endpointNIC.addPlugin("sourceRoutingPlugin", routing_table=_SR_routing_table)
117+
#### the following parameters will be passed down to linkcontrol via callback
118+
endpointNIC.link_bw = f"{UNIFIED_ROUTER_LINK_BW}Gb/s"
119+
endpointNIC.input_buf_size = "32kB"
120+
endpointNIC.output_buf_size = "32kB"
121+
endpointNIC.vn_remap = [0]
122+
123+
# Set up VN remapping
124+
endpointNIC.vn_remap = [0]
125+
126+
ep = EmberMPIJob(0,topo.getNumNodes(), numCores = CPE*EPR)
127+
ep.setEndpointNIC(endpointNIC)
128+
ep.addMotif("Init")
129+
ep.addMotif(BENCH+BENCH_PARAMS)
130+
ep.addMotif("Fini")
131+
ep.nic.nic2host_lat= "10ns"
132+
133+
system = System()
134+
system.setTopology(topo)
135+
system.allocateNodes(ep,"linear")
136+
137+
system.build()
138+
139+
if __name__ == "__main__":
140+
run_sst(*prepare_complete_4())

src/sst/elements/merlin/topology/anytopo_ultility/tests/test_anytopo.py renamed to src/sst/elements/merlin/topology/anytopo_ultility/tests/Merlin_test_anytopo.py

File renamed without changes.

src/sst/elements/merlin/topology/pymerlin-topo-any.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
#!/usr/bin/env python
2-
# TODO: copyright goes here?
2+
#
3+
# Copyright 2009-2025 NTESS. Under the terms
4+
# of Contract DE-NA0003525 with NTESS, the U.S.
5+
# Government retains certain rights in this software.
6+
#
7+
# Copyright (c) 2009-2025, NTESS
8+
# All rights reserved.
9+
#
10+
# Portions are copyright of other developers:
11+
# See the file CONTRIBUTORS.TXT in the top level directory
12+
# of the distribution for more information.
13+
#
14+
# This file is part of the SST software package. For license
15+
# information, see the LICENSE file in the top level directory of the
16+
# distribution.
317

418
"""
519
SST Merlin Any Topology Module
@@ -12,7 +26,7 @@
1226
- Calculate routing table: routing_table = topo.calculate_routing_table()
1327
- Pass to SourceRoutingPlugin via EndpointNIC.addPlugin()
1428
15-
See pymerlin-interface.py for SourceRoutingPlugin usage and routing table serialization.
29+
See pymerlin-interface.py for SourceRoutingPlugin usage with EndpointNIC and routing table serialization.
1630
"""
1731

1832
import sst
@@ -23,8 +37,8 @@
2337

2438
try:
2539
import networkx as nx
26-
except ImportError:
27-
raise ImportError("NetworkX is required for the 'topo_any' python module. Please install NetworkX and try again.")
40+
except:
41+
pass
2842

2943
def _networkx_Dijkstra_shortest_path(input_nx_graph) -> dict:
3044
"""

0 commit comments

Comments
 (0)