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

symphony/orchestration: allow simulation.NICSim to pass pci ant eth latencies separately

parent 313bcc7e
...@@ -253,6 +253,11 @@ class Simulator(utils_base.IdObj, abc.ABC): ...@@ -253,6 +253,11 @@ class Simulator(utils_base.IdObj, abc.ABC):
channels.append(channel) channels.append(channel)
return channels return channels
@staticmethod
def filter_channels_by_sys_type(channels: list[sim_chan.Channel], ty: type[T]) -> list[T]:
filtered = list(filter(lambda chan: isinstance(chan.sys_channel, ty), channels))
return filtered
# pylint: disable=unused-argument # pylint: disable=unused-argument
@abc.abstractmethod @abc.abstractmethod
def run_cmd(self, inst: inst_base.Instantiation) -> str: def run_cmd(self, inst: inst_base.Instantiation) -> str:
......
...@@ -34,26 +34,20 @@ from simbricks.orchestration.simulation import base as sim_base ...@@ -34,26 +34,20 @@ from simbricks.orchestration.simulation import base as sim_base
class PCIDevSim(sim_base.Simulator): class PCIDevSim(sim_base.Simulator):
"""Base class for PCIe device simulators.""" """Base class for PCIe device simulators."""
def __init__( def __init__(self, simulation: sim_base.Simulation, executable: str, name: str) -> None:
self, simulation: sim_base.Simulation, executable: str, name: str
) -> None:
super().__init__(simulation=simulation, executable=executable, name=name) super().__init__(simulation=simulation, executable=executable, name=name)
def full_name(self) -> str: def full_name(self) -> str:
return "dev." + self.name return "dev." + self.name
def supported_socket_types( def supported_socket_types(self, interface: sys_base.Interface) -> set[inst_socket.SockType]:
self, interface: sys_base.Interface
) -> set[inst_socket.SockType]:
return {inst_socket.SockType.LISTEN} return {inst_socket.SockType.LISTEN}
class NICSim(PCIDevSim): class NICSim(PCIDevSim):
"""Base class for NIC simulators.""" """Base class for NIC simulators."""
def __init__( def __init__(self, simulation: sim_base.Simulation, executable: str, name: str = "") -> None:
self, simulation: sim_base.Simulation, executable: str, name: str = ""
) -> None:
super().__init__(simulation=simulation, executable=executable, name=name) super().__init__(simulation=simulation, executable=executable, name=name)
def full_name(self) -> str: def full_name(self) -> str:
...@@ -65,10 +59,26 @@ class NICSim(PCIDevSim): ...@@ -65,10 +59,26 @@ class NICSim(PCIDevSim):
def run_cmd(self, inst: inst_base.Instantiation) -> str: def run_cmd(self, inst: inst_base.Instantiation) -> str:
channels = self.get_channels() channels = self.get_channels()
latency, sync_period, run_sync = (
sim_base.Simulator.get_unique_latency_period_sync(channels=channels) pci_channels = sim_base.Simulator.filter_channels_by_sys_type(
channels, sys_pcie.PCIeChannel
)
pci_latency, pci_sync_period, pci_run_sync = (
sim_base.Simulator.get_unique_latency_period_sync(pci_channels)
) )
eth_channels = sim_base.Simulator.filter_channels_by_sys_type(channels, sys_eth.EthChannel)
eth_latency, eth_sync_period, eth_run_sync = (
sim_base.Simulator.get_unique_latency_period_sync(eth_channels)
)
if eth_run_sync != pci_run_sync:
raise Exception(
"currently using different synchronization values for pci and eth is not supported"
)
run_sync = eth_run_sync
sync_period = min(pci_sync_period, eth_sync_period)
cmd = f"{inst.join_repo_base(relative_path=self._executable)} " cmd = f"{inst.join_repo_base(relative_path=self._executable)} "
nic_devices = self.filter_components_by_type(ty=sys_nic.SimplePCIeNIC) nic_devices = self.filter_components_by_type(ty=sys_nic.SimplePCIeNIC)
...@@ -85,7 +95,7 @@ class NICSim(PCIDevSim): ...@@ -85,7 +95,7 @@ class NICSim(PCIDevSim):
cmd += ( cmd += (
f" {inst.get_simulator_shm_pool_path(sim=self)} {int(run_sync)} {self._start_tick}" f" {inst.get_simulator_shm_pool_path(sim=self)} {int(run_sync)} {self._start_tick}"
f" {sync_period} {latency} {latency}" f" {sync_period} {pci_latency} {eth_latency}"
) )
# if self.mac is not None: # TODO: FIXME # if self.mac is not None: # TODO: FIXME
...@@ -131,9 +141,7 @@ class CorundumBMNICSim(NICSim): ...@@ -131,9 +141,7 @@ class CorundumBMNICSim(NICSim):
return json_obj return json_obj
@classmethod @classmethod
def fromJSON( def fromJSON(cls, simulation: sim_base.Simulation, json_obj: dict) -> CorundumBMNICSim:
cls, simulation: sim_base.Simulation, json_obj: dict
) -> CorundumBMNICSim:
return super().fromJSON(simulation, json_obj) return super().fromJSON(simulation, json_obj)
def run_cmd(self, inst: inst_base.Instantiation) -> str: def run_cmd(self, inst: inst_base.Instantiation) -> str:
...@@ -161,9 +169,7 @@ class CorundumVerilatorNICSim(NICSim): ...@@ -161,9 +169,7 @@ class CorundumVerilatorNICSim(NICSim):
return json_obj return json_obj
@classmethod @classmethod
def fromJSON( def fromJSON(cls, simulation: sim_base.Simulation, json_obj: dict) -> CorundumVerilatorNICSim:
cls, simulation: sim_base.Simulation, json_obj: dict
) -> CorundumVerilatorNICSim:
return super().fromJSON(simulation, json_obj) return super().fromJSON(simulation, json_obj)
def run_cmd(self, inst: inst_base.Instantiation) -> str: def run_cmd(self, inst: inst_base.Instantiation) -> str:
......
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