Commit d8d53650 authored by Hejing Li's avatar Hejing Li
Browse files

some imports

parent 2741f329
...@@ -21,16 +21,13 @@ ...@@ -21,16 +21,13 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import typing as tp import typing as tp
import simbricks.orchestration.simulation.base as sim_base
import simbricks.orchestration.experiments as exp
import simbricks.orchestration.system.base as system_base import simbricks.orchestration.system.base as system_base
import simbricks.orchestration.simulation.base as sim_base
from simbricks.orchestration.experiment.experiment_environment_new import ExpEnv
class Channel(sim_base.Simulator): class Channel(sim_base.Simulator):
def __init__(self, e: exp.Experiment, chan: system_base.Channel): def __init__(self, e: sim_base.Simulation, chan: system_base.Channel):
super().__init__(e) super().__init__(e)
self._synchronized: bool = True self._synchronized: bool = True
self.sync_period: int = 500 # nano second self.sync_period: int = 500 # nano second
......
...@@ -25,18 +25,19 @@ import tarfile ...@@ -25,18 +25,19 @@ import tarfile
import math import math
import typing as tp import typing as tp
import simbricks.orchestration.simulation.base as sim_base import simbricks.orchestration.simulation.base as sim_base
import simbricks.orchestration.system.host.base as system_host
import simbricks.orchestration.system.pcie as system_pcie import simbricks.orchestration.system.pcie as system_pcie
import simbricks.orchestration.system as system import simbricks.orchestration.system as system
import simbricks.orchestration.experiments as exp
from simbricks.orchestration.experiment.experiment_environment_new import ExpEnv from simbricks.orchestration.experiment.experiment_environment_new import ExpEnv
if tp.TYPE_CHECKING:
from simbricks.orchestration.system.host.base import (Host)
class HostSim(sim_base.Simulator): class HostSim(sim_base.Simulator):
def __init__(self, e: exp.Experiment): def __init__(self, e: sim_base.Simulation):
super().__init__(e) super().__init__(e)
self.hosts: system_host.Host = [] self.hosts: tp.List['Host']
self.wait = True self.wait = True
def full_name(self) -> str: def full_name(self) -> str:
...@@ -51,7 +52,7 @@ class HostSim(sim_base.Simulator): ...@@ -51,7 +52,7 @@ class HostSim(sim_base.Simulator):
deps.append(self.experiment.find_sim(dev.component)) deps.append(self.experiment.find_sim(dev.component))
return deps return deps
def add(self, host: system_host.Host): def add(self, host: 'Host'):
self.hosts.append(host) self.hosts.append(host)
self.name = f'{self.hosts.id}' self.name = f'{self.hosts.id}'
self.experiment.add_host(self) self.experiment.add_host(self)
...@@ -94,7 +95,7 @@ class HostSim(sim_base.Simulator): ...@@ -94,7 +95,7 @@ class HostSim(sim_base.Simulator):
class Gem5Sim(HostSim): class Gem5Sim(HostSim):
def __init__(self, e: exp.Experiment): def __init__(self, e: sim_base.Simulation):
super().__init__(e) super().__init__(e)
self.name = '' self.name = ''
...@@ -183,7 +184,7 @@ class Gem5Sim(HostSim): ...@@ -183,7 +184,7 @@ class Gem5Sim(HostSim):
class QemuSim(HostSim): class QemuSim(HostSim):
def __init__(self, e: exp.Experiment): def __init__(self, e: sim_base.Simulation):
super().__init__(e) super().__init__(e)
......
...@@ -18,4 +18,6 @@ ...@@ -18,4 +18,6 @@
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
from simbricks.orchestration.simulation.net.base import *
...@@ -22,16 +22,17 @@ ...@@ -22,16 +22,17 @@
import abc import abc
import sys import sys
from simbricks.orchestration.simulation import base import simbricks.orchestration.simulation.base as sim_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
from simbricks.orchestration.experiment.experiment_environment_new import ExpEnv
class NetSim(base.Simulator): class NetSim(sim_base.Simulator):
"""Base class for network simulators.""" """Base class for network simulators."""
def __init__( def __init__(
self, simulation: base.Simulation, relative_executable_path: str = "" self, simulation: sim_base.Simulation, relative_executable_path: str = ""
) -> None: ) -> None:
super().__init__(simulation, relative_executable_path=relative_executable_path) super().__init__(simulation, relative_executable_path=relative_executable_path)
# TODO: do we want them here? # TODO: do we want them here?
...@@ -41,7 +42,7 @@ class NetSim(base.Simulator): ...@@ -41,7 +42,7 @@ class NetSim(base.Simulator):
def full_name(self) -> str: def full_name(self) -> str:
return "net." + self.name return "net." + self.name
def dependencies(self) -> list[base.Simulator]: def dependencies(self) -> list[sim_base.Simulator]:
# TODO # TODO
deps = [] deps = []
for s in self.switches: for s in self.switches:
...@@ -50,7 +51,7 @@ class NetSim(base.Simulator): ...@@ -50,7 +51,7 @@ class NetSim(base.Simulator):
return deps return deps
# TODO # TODO
def sockets_wait(self, env: exp_env.ExpEnv) -> list[str]: def sockets_wait(self, env: ExpEnv) -> list[str]:
pass pass
def wait_terminate(self) -> bool: def wait_terminate(self) -> bool:
...@@ -60,14 +61,14 @@ class NetSim(base.Simulator): ...@@ -60,14 +61,14 @@ class NetSim(base.Simulator):
def init_network(self) -> None: def init_network(self) -> None:
pass pass
def sockets_cleanup(self, env: exp_env.ExpEnv) -> list[str]: def sockets_cleanup(self, env: ExpEnv) -> list[str]:
# TODO # TODO
return [] return []
class WireNet(NetSim): class WireNet(NetSim):
def __init__(self, simulation: base.Simulation) -> None: def __init__(self, simulation: sim_base.Simulation) -> None:
super().__init__( super().__init__(
simulation=simulation, simulation=simulation,
relative_executable_path="/sims/net/wire/net_wire", relative_executable_path="/sims/net/wire/net_wire",
...@@ -75,7 +76,7 @@ class WireNet(NetSim): ...@@ -75,7 +76,7 @@ class WireNet(NetSim):
) )
# 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
self._relative_pcap_file_path: str | None = relative_pcap_file_path self._relative_pcap_file_path: str | None = 'relative_pcap_file_path'
def add_wire(self, wire: eth.EthWire): def add_wire(self, wire: eth.EthWire):
assert self._wire_comp is None assert self._wire_comp is None
...@@ -118,7 +119,7 @@ class SwitchNet(NetSim): ...@@ -118,7 +119,7 @@ class SwitchNet(NetSim):
def __init__( def __init__(
self, self,
simulation: base.Simulation, simulation: sim_base.Simulation,
relative_executable_path="/sims/net/switch/net_switch", relative_executable_path="/sims/net/switch/net_switch",
relative_pcap_file_path=None, relative_pcap_file_path=None,
) -> None: ) -> None:
...@@ -167,7 +168,7 @@ class SwitchNet(NetSim): ...@@ -167,7 +168,7 @@ class SwitchNet(NetSim):
cmd += " " + pcap_file cmd += " " + pcap_file
sockets = self._get_sockets(inst=inst) sockets = self._get_sockets(inst=inst)
listen, connect = base.Simulator.split_sockets_by_type(sockets) listen, connect = sim_base.Simulator.split_sockets_by_type(sockets)
for sock in connect: for sock in connect:
cmd += " -s " + sock._path cmd += " -s " + sock._path
...@@ -181,7 +182,7 @@ class SwitchNet(NetSim): ...@@ -181,7 +182,7 @@ class SwitchNet(NetSim):
class MemSwitchNet(SwitchNet): class MemSwitchNet(SwitchNet):
def __init__( def __init__(
self, simulation: base.Simulation, relative_pcap_file_path=None self, simulation: sim_base.Simulation, relative_pcap_file_path=None
) -> None: ) -> None:
super().__init__( super().__init__(
simulation=simulation, simulation=simulation,
......
...@@ -20,16 +20,16 @@ ...@@ -20,16 +20,16 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import simbricks.orchestration.simulation as sim_conf
import simbricks.orchestration.system as sys_conf import simbricks.orchestration.system as sys_conf
import typing as tp import typing as tp
from simbricks.orchestration.experiment.experiment_environment_new import ExpEnv from simbricks.orchestration.experiment.experiment_environment_new import ExpEnv
from simbricks.orchestration.simulation import base
class PCIDevSim(sim_conf.Simulator): class PCIDevSim(base.Simulator):
"""Base class for PCIe device simulators.""" """Base class for PCIe device simulators."""
def __init__(self, e: sim_conf.Simulation) -> None: def __init__(self, e: base.Simulation) -> None:
super().__init__(e) super().__init__(e)
self.start_tick = 0 self.start_tick = 0
...@@ -56,13 +56,13 @@ class PCIDevSim(sim_conf.Simulator): ...@@ -56,13 +56,13 @@ class PCIDevSim(sim_conf.Simulator):
class NICSim(PCIDevSim): class NICSim(PCIDevSim):
"""Base class for NIC simulators.""" """Base class for NIC simulators."""
def __init__(self, e: sim_conf.Simulation) -> None: def __init__(self, e: base.Simulation) -> None:
super().__init__(e) super().__init__(e)
self.experiment = e self.experiment = e
self.nics: tp.List[sim_conf.PCIDevSim] = [] self.nics: tp.List[PCIDevSim] = []
self.start_tick = 0 self.start_tick = 0
def add(self, nic: sim_conf.PCIDevSim): def add(self, nic: PCIDevSim):
self.nics.append(nic) self.nics.append(nic)
# nic.sim = self # nic.sim = self
self.experiment.add_nic(self) self.experiment.add_nic(self)
...@@ -102,7 +102,7 @@ class NICSim(PCIDevSim): ...@@ -102,7 +102,7 @@ class NICSim(PCIDevSim):
class I40eNicSim(NICSim): class I40eNicSim(NICSim):
def __init__(self, e: sim_conf.Simulation): def __init__(self, e: 'Simulation'):
super().__init__(e) super().__init__(e)
def run_cmd(self, env: ExpEnv) -> str: def run_cmd(self, env: ExpEnv) -> str:
...@@ -110,7 +110,7 @@ class I40eNicSim(NICSim): ...@@ -110,7 +110,7 @@ class I40eNicSim(NICSim):
class CorundumBMNICSim(NICSim): class CorundumBMNICSim(NICSim):
def __init__(self, e: sim_conf.Simulation): def __init__(self, e: 'Simulation'):
super().__init__(e) super().__init__(e)
def run_cmd(self, env: ExpEnv) -> str: def run_cmd(self, env: ExpEnv) -> str:
...@@ -121,7 +121,7 @@ class CorundumBMNICSim(NICSim): ...@@ -121,7 +121,7 @@ class CorundumBMNICSim(NICSim):
class CorundumVerilatorNICSim(NICSim): class CorundumVerilatorNICSim(NICSim):
def __init__(self, e: sim_conf.Simulation): def __init__(self, e: 'Simulation'):
super().__init__(e) super().__init__(e)
self.clock_freq = 250 # MHz self.clock_freq = 250 # MHz
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
from __future__ import annotations from __future__ import annotations
import abc import abc
from simbricks.orchestration.utils import base from simbricks.orchestration.utils import base as util_base
class System: class System:
...@@ -36,7 +36,7 @@ class System: ...@@ -36,7 +36,7 @@ class System:
self.all_component.append(c) self.all_component.append(c)
class Component(base.IdObj): class Component(util_base.IdObj):
def __init__(self, s: System) -> None: def __init__(self, s: System) -> None:
super().__init__() super().__init__()
...@@ -53,7 +53,7 @@ class Component(base.IdObj): ...@@ -53,7 +53,7 @@ class Component(base.IdObj):
return [i.channel for i in self.interfaces() if i.is_connected()] return [i.channel for i in self.interfaces() if i.is_connected()]
class Interface(base.IdObj): class Interface(util_base.IdObj):
def __init__(self, c: Component) -> None: def __init__(self, c: Component) -> None:
super().__init__() super().__init__()
self.component = c self.component = c
...@@ -70,7 +70,7 @@ class Interface(base.IdObj): ...@@ -70,7 +70,7 @@ class Interface(base.IdObj):
self.channel = c self.channel = c
class Channel(base.IdObj): class Channel(util_base.IdObj):
def __init__(self, a: Interface, b: Interface) -> None: def __init__(self, a: Interface, b: Interface) -> None:
super().__init__() super().__init__()
self.latency = 500 self.latency = 500
......
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