simbricks-memnet-base-sim-py 0.4.2__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- simbricks/components/memnet/simulation/base/__init__.py +25 -0
- simbricks/components/memnet/simulation/base/memnet.py +105 -0
- simbricks_memnet_base_sim_py-0.4.2.dist-info/METADATA +23 -0
- simbricks_memnet_base_sim_py-0.4.2.dist-info/RECORD +5 -0
- simbricks_memnet_base_sim_py-0.4.2.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Copyright 2026 Max Planck Institute for Software Systems,
|
|
2
|
+
# National University of Singapore, and SimBricks UG (haftungsbeschränkt)
|
|
3
|
+
#
|
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
|
+
# a copy of this software and associated documentation files (the
|
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
|
10
|
+
# the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be
|
|
13
|
+
# included in all copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
18
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
19
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
20
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
21
|
+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
|
|
23
|
+
from .memnet import MemSwitchNet
|
|
24
|
+
|
|
25
|
+
__all__ = ["MemSwitchNet"]
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Copyright 2026 Max Planck Institute for Software Systems,
|
|
2
|
+
# National University of Singapore, and SimBricks UG (haftungsbeschränkt)
|
|
3
|
+
#
|
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
|
+
# a copy of this software and associated documentation files (the
|
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
|
10
|
+
# the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be
|
|
13
|
+
# included in all copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
18
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
19
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
20
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
21
|
+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
|
|
23
|
+
from __future__ import annotations
|
|
24
|
+
|
|
25
|
+
import typing_extensions as tpe
|
|
26
|
+
|
|
27
|
+
from simbricks.orchestration.instantiation import base as inst_base
|
|
28
|
+
from simbricks.orchestration.simulation import base as sim_base
|
|
29
|
+
from simbricks.orchestration.simulation import net as sim_net
|
|
30
|
+
from simbricks.orchestration.system import eth as sys_eth
|
|
31
|
+
from simbricks.utils import base as utils_base
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class MemSwitchNet(sim_net.NetSim):
|
|
35
|
+
|
|
36
|
+
def __init__(
|
|
37
|
+
self,
|
|
38
|
+
simulation: sim_base.Simulation,
|
|
39
|
+
executable: str = "simb_net_memswitch",
|
|
40
|
+
relative_pcap_filepath: str | None = None,
|
|
41
|
+
) -> None:
|
|
42
|
+
super().__init__(
|
|
43
|
+
simulation=simulation,
|
|
44
|
+
executable=executable,
|
|
45
|
+
)
|
|
46
|
+
self.name = f"MemSwitchNet-{self._id}"
|
|
47
|
+
self._relative_pcap_file_path: str | None = relative_pcap_filepath
|
|
48
|
+
"""AS_ID,VADDR_START,VADDR_END,MEMNODE_MAC,PHYS_START."""
|
|
49
|
+
self.mem_map = []
|
|
50
|
+
|
|
51
|
+
def add(self, switch_spec: sys_eth.EthSwitch):
|
|
52
|
+
utils_base.has_expected_type(switch_spec, sys_eth.EthSwitch)
|
|
53
|
+
if len(self._components) > 1:
|
|
54
|
+
raise Exception("can only add a single switch component to the SwitchNet")
|
|
55
|
+
super().add(switch_spec)
|
|
56
|
+
|
|
57
|
+
def toJSON(self) -> dict:
|
|
58
|
+
json_obj = super().toJSON()
|
|
59
|
+
json_obj["relative_pcap_file_path"] = self._relative_pcap_file_path
|
|
60
|
+
json_obj["mem_map"] = utils_base.list_tuple_to_json(self.mem_map)
|
|
61
|
+
return json_obj
|
|
62
|
+
|
|
63
|
+
@classmethod
|
|
64
|
+
def fromJSON(cls, simulation: sim_base.Simulation, json_obj: dict) -> tpe.Self:
|
|
65
|
+
instance = super().fromJSON(simulation, json_obj)
|
|
66
|
+
instance._relative_pcap_file_path = utils_base.get_json_attr_top(
|
|
67
|
+
json_obj, "relative_pcap_file_path"
|
|
68
|
+
)
|
|
69
|
+
instance.mem_map = utils_base.json_array_to_list(
|
|
70
|
+
utils_base.get_json_attr_top(json_obj, "mem_map")
|
|
71
|
+
)
|
|
72
|
+
return instance
|
|
73
|
+
|
|
74
|
+
def run_cmd(self, inst: inst_base.Instantiation) -> str:
|
|
75
|
+
channels = self.get_channels()
|
|
76
|
+
eth_latency, sync_period, run_sync = (
|
|
77
|
+
sim_base.Simulator.get_unique_latency_period_sync(channels=channels)
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
cmd = f"{self._executable} -S {sync_period} -E {eth_latency}"
|
|
81
|
+
|
|
82
|
+
if not run_sync:
|
|
83
|
+
cmd += " -u"
|
|
84
|
+
|
|
85
|
+
if self._relative_pcap_file_path is not None:
|
|
86
|
+
pcap_file = inst.env.output_base(
|
|
87
|
+
relative_path=self._relative_pcap_file_path
|
|
88
|
+
)
|
|
89
|
+
cmd += " -p " + pcap_file
|
|
90
|
+
|
|
91
|
+
sockets = self._get_socks_by_all_comp(inst=inst)
|
|
92
|
+
listen, connect = sim_base.Simulator.split_sockets_by_type(sockets)
|
|
93
|
+
|
|
94
|
+
for sock in connect:
|
|
95
|
+
cmd += " -s " + sock._path
|
|
96
|
+
|
|
97
|
+
for sock in listen:
|
|
98
|
+
cmd += " -h " + sock._path
|
|
99
|
+
|
|
100
|
+
for m in self.mem_map:
|
|
101
|
+
cmd += " -m " + f" {m[0]},{m[1]},{m[2]},"
|
|
102
|
+
cmd += "".join(reversed(m[3].split(":")))
|
|
103
|
+
cmd += f",{m[4]}"
|
|
104
|
+
|
|
105
|
+
return cmd
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: simbricks-memnet-base-sim-py
|
|
3
|
+
Version: 0.4.2
|
|
4
|
+
Summary: Basic memory-network device models integration into SimBricks
|
|
5
|
+
Author: Team SimBricks
|
|
6
|
+
Author-email: team@simbricks.io
|
|
7
|
+
Classifier: Programming Language :: Python :: 2
|
|
8
|
+
Classifier: Programming Language :: Python :: 2.7
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.4
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.5
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Requires-Dist: simbricks-orchestration (>=0.4.2)
|
|
22
|
+
Requires-Dist: simbricks-utils (>=0.4.2)
|
|
23
|
+
Project-URL: Homepage, https://www.simbricks.io/
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
simbricks/components/memnet/simulation/base/__init__.py,sha256=PwoyBx1F7pz-O0iMibRr1jUkf65CtqHsMIm6-yr84fM,1255
|
|
2
|
+
simbricks/components/memnet/simulation/base/memnet.py,sha256=LavCeTnPLkqTaXYk_m89bljUqJnJAX2REm_ATlKuhqg,4110
|
|
3
|
+
simbricks_memnet_base_sim_py-0.4.2.dist-info/METADATA,sha256=zfOUtqas3lv0fmVD2lmzQwCCSVXnGSbDMdP20FaQ6Yk,1038
|
|
4
|
+
simbricks_memnet_base_sim_py-0.4.2.dist-info/WHEEL,sha256=1oQCyGWpCQRMLaeEMGZpAmCFXca8Y4z2JkEkZAboWXw,92
|
|
5
|
+
simbricks_memnet_base_sim_py-0.4.2.dist-info/RECORD,,
|