Unverified Commit af34751b authored by Jakob Görgen's avatar Jakob Görgen
Browse files

experiments/simbricks/orchestration/simulation : added new simulation class as...

experiments/simbricks/orchestration/simulation : added new simulation class as type to network simulators
parent 77a9f1a8
...@@ -28,16 +28,24 @@ from simbricks.orchestration.experiment import experiment_environment_new as exp ...@@ -28,16 +28,24 @@ from simbricks.orchestration.experiment import experiment_environment_new as exp
from simbricks.orchestration.instantiation import base as inst_base from simbricks.orchestration.instantiation import base as inst_base
if tp.TYPE_CHECKING: if tp.TYPE_CHECKING:
from simbricks.orchestration.simulation import Channel, HostSim, PCIDevSim, NetSim from simbricks.orchestration.simulation import (
Channel,
HostSim,
PCIDevSim,
NetSim,
base as sim_base,
)
class Simulator(abc.ABC): class Simulator(abc.ABC):
"""Base class for all simulators.""" """Base class for all simulators."""
def __init__(self, e: Simulation, relative_executable_path: str = "") -> None: def __init__(
self, simulation: sim_base.Simulation, relative_executable_path: str = ""
) -> None:
self.extra_deps: list[Simulator] = [] self.extra_deps: list[Simulator] = []
self.name = "" self.name: str = ""
self.experiment = e self.experiment: sim_base.Simulation = simulation
self._components: set[sys_conf.Component] = [] self._components: set[sys_conf.Component] = []
self._relative_executable_path: str = relative_executable_path self._relative_executable_path: str = relative_executable_path
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
import abc import abc
import sys import sys
from simbricks.orchestration import experiments
from simbricks.orchestration.simulation import base from simbricks.orchestration.simulation import base
from simbricks.orchestration.system import eth from simbricks.orchestration.system import eth
from simbricks.orchestration.instantiation import base as inst_base from simbricks.orchestration.instantiation import base as inst_base
...@@ -31,8 +30,10 @@ from simbricks.orchestration.instantiation import base as inst_base ...@@ -31,8 +30,10 @@ from simbricks.orchestration.instantiation import base as inst_base
class NetSim(base.Simulator): class NetSim(base.Simulator):
"""Base class for network simulators.""" """Base class for network simulators."""
def __init__(self, e: exp.Experiment, relative_executable_path: str = "") -> None: def __init__(
super().__init__(e, relative_executable_path=relative_executable_path) self, simulation: base.Simulation, relative_executable_path: str = ""
) -> None:
super().__init__(simulation, relative_executable_path=relative_executable_path)
# TODO: do we want them here? # TODO: do we want them here?
self._switch_specs = [] self._switch_specs = []
self._host_specs = [] self._host_specs = []
...@@ -70,8 +71,10 @@ class NetSim(base.Simulator): ...@@ -70,8 +71,10 @@ class NetSim(base.Simulator):
class WireNet(NetSim): class WireNet(NetSim):
def __init__(self, e: exp.Experiment) -> None: def __init__(self, simulation: base.Simulation) -> None:
super().__init__(e, relative_executable_path="/sims/net/wire/net_wire") super().__init__(
simulation=simulation, relative_executable_path="/sims/net/wire/net_wire"
)
# TODO: probably we want to store these in a common base class... # TODO: probably we want to store these in a common base class...
self._wire_comp: eth.EthWire | None = None self._wire_comp: eth.EthWire | None = None
...@@ -111,9 +114,13 @@ class WireNet(NetSim): ...@@ -111,9 +114,13 @@ class WireNet(NetSim):
class SwitchNet(NetSim): class SwitchNet(NetSim):
def __init__( def __init__(
self, e: exp.Experiment, relative_executable_path="/sims/net/switch/net_switch" self,
simulation: base.Simulation,
relative_executable_path="/sims/net/switch/net_switch",
) -> None: ) -> None:
super().__init__(e, relative_executable_path=relative_executable_path) super().__init__(
simulation=simulation, relative_executable_path=relative_executable_path
)
# TODO: probably we want to store these in a common base class... # TODO: probably we want to store these in a common base class...
self._switch_spec: eth.EthSwitch | None = None self._switch_spec: eth.EthSwitch | None = None
...@@ -175,9 +182,11 @@ class SwitchNet(NetSim): ...@@ -175,9 +182,11 @@ class SwitchNet(NetSim):
class MemSwitchNet(SwitchNet): class MemSwitchNet(SwitchNet):
def __init__(self, e: exp.Experiment) -> None: def __init__(self, simulation: base.Simulation) -> None:
super().__init__(e, relative_executable_path="/sims/mem/memswitch/memswitch") super().__init__(
self.sync = True simulation=simulation,
relative_executable_path="/sims/mem/memswitch/memswitch",
)
"""AS_ID,VADDR_START,VADDR_END,MEMNODE_MAC,PHYS_START.""" """AS_ID,VADDR_START,VADDR_END,MEMNODE_MAC,PHYS_START."""
self.mem_map = [] self.mem_map = []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment