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

some imports

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