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

LocalParallelRuntime fixes

parent 1de5e7ce
...@@ -280,7 +280,7 @@ def main(): ...@@ -280,7 +280,7 @@ def main():
executors = load_executors(args.hosts) executors = load_executors(args.hosts)
# initialize runtime # initialize runtime
if args.runtime == "parallel": # TODO: FIXME if args.runtime == "parallel":
warn_multi_exec(executors) warn_multi_exec(executors)
rt = rt_local.LocalParallelRuntime( rt = rt_local.LocalParallelRuntime(
cores=args.cores, mem=args.mem, verbose=args.verbose, executor=executors[0] cores=args.cores, mem=args.mem, verbose=args.verbose, executor=executors[0]
......
...@@ -26,6 +26,8 @@ import enum ...@@ -26,6 +26,8 @@ import enum
import pathlib import pathlib
import shutil import shutil
import typing import typing
import itertools
import copy
from simbricks.orchestration.utils import base as util_base from simbricks.orchestration.utils import base as util_base
from simbricks.orchestration.system import base as sys_base from simbricks.orchestration.system import base as sys_base
from simbricks.orchestration.system import pcie as sys_pcie from simbricks.orchestration.system import pcie as sys_pcie
...@@ -74,7 +76,9 @@ class InstantiationEnvironment(util_base.IdObj): ...@@ -74,7 +76,9 @@ class InstantiationEnvironment(util_base.IdObj):
).resolve() ).resolve()
class Instantiation(util_base.IdObj): class Instantiation():
__id_iter = itertools.count()
def __init__( def __init__(
self, self,
...@@ -82,6 +86,7 @@ class Instantiation(util_base.IdObj): ...@@ -82,6 +86,7 @@ class Instantiation(util_base.IdObj):
env: InstantiationEnvironment = InstantiationEnvironment(), env: InstantiationEnvironment = InstantiationEnvironment(),
): ):
super().__init__() super().__init__()
self._id = next(self.__id_iter)
self.simulation: sim_base.Simulation = sim self.simulation: sim_base.Simulation = sim
self.env: InstantiationEnvironment = env self.env: InstantiationEnvironment = env
self._executor: command_executor.Executor | None = None self._executor: command_executor.Executor | None = None
...@@ -330,32 +335,33 @@ class Instantiation(util_base.IdObj): ...@@ -330,32 +335,33 @@ class Instantiation(util_base.IdObj):
self._restore_checkpoint = restore_checkpoint self._restore_checkpoint = restore_checkpoint
def copy(self) -> Instantiation: def copy(self) -> Instantiation:
copy = Instantiation(sim=self.simulation, env=self.env) cop = Instantiation(sim=self.simulation, env=self.env)
return copy cop.simulation = copy.deepcopy(self.simulation) # maybe there is a smarter way of achieving this...
return cop
def out_base_dir(self) -> str: def out_base_dir(self) -> str:
return pathlib.Path( return pathlib.Path(
f"{self.env._output_base}/{self.simulation.name}" # /{self.run._run_nr}" f"{self.env._output_base}/{self.simulation.name}/{self._id}"
).resolve() ).resolve()
def shm_base_dir(self) -> str: def shm_base_dir(self) -> str:
return pathlib.Path( return pathlib.Path(
f"{self.env._shm_base}/{self.simulation.name}" # /{self.run._run_nr}" f"{self.env._shm_base}/{self.simulation.name}/{self._id}"
).resolve() ).resolve()
def imgs_dir(self) -> str: def imgs_dir(self) -> str:
return pathlib.Path( return pathlib.Path(
f"{self.env._imgdir}/{self.simulation.name}" # /{self.run._run_nr}" f"{self.env._imgdir}/{self.simulation.name}/{self._id}"
).resolve() ).resolve()
def cpdir(self) -> str: def cpdir(self) -> str:
return pathlib.Path( return pathlib.Path(
f"{self.env._cpdir}/{self.simulation.name}" # /{self.run._run_nr}" f"{self.env._cpdir}/{self.simulation.name}" # /{self._id}"
).resolve() ).resolve()
def wrkdir(self) -> str: def wrkdir(self) -> str:
return pathlib.Path( return pathlib.Path(
f"{self.env._workdir}/{self.simulation.name}" # /{self.run._run_nr}" f"{self.env._workdir}/{self.simulation.name}" # /{self._id}"
).resolve() ).resolve()
async def prepare(self) -> None: async def prepare(self) -> None:
...@@ -461,10 +467,10 @@ class Instantiation(util_base.IdObj): ...@@ -461,10 +467,10 @@ class Instantiation(util_base.IdObj):
relative_path=f"{sim.full_name()}-shm-pool-{sim._id}", relative_path=f"{sim.full_name()}-shm-pool-{sim._id}",
) )
def get_simulation_output_path(self, run_nr: int) -> str: def get_simulation_output_path(self) -> str:
return self._join_paths( return self._join_paths(
base=self.out_base_dir(), base=self.out_base_dir(),
relative_path=f"{run_nr}/out.json", relative_path=f"out.json",
) )
def find_sim_by_interface( def find_sim_by_interface(
......
...@@ -69,9 +69,7 @@ class LocalSimpleRuntime(run_base.Runtime): ...@@ -69,9 +69,7 @@ class LocalSimpleRuntime(run_base.Runtime):
if self._verbose: if self._verbose:
print(f"Writing collected output of run {run.name()} to JSON file ...") print(f"Writing collected output of run {run.name()} to JSON file ...")
output_path = run.instantiation.get_simulation_output_path( output_path = run.instantiation.get_simulation_output_path()
run_nr=run._run_nr
)
run._output.dump(outpath=output_path) run._output.dump(outpath=output_path)
await runner.cleanup() await runner.cleanup()
...@@ -150,9 +148,7 @@ class LocalParallelRuntime(run_base.Runtime): ...@@ -150,9 +148,7 @@ class LocalParallelRuntime(run_base.Runtime):
if self._verbose: if self._verbose:
print(f"Writing collected output of run {run.name()} to JSON file ...") print(f"Writing collected output of run {run.name()} to JSON file ...")
output_path = run.instantiation.get_simulation_output_path( output_path = run.instantiation.get_simulation_output_path()
run_number=run._run_nr
)
run._output.dump(outpath=output_path) run._output.dump(outpath=output_path)
await runner.cleanup() await runner.cleanup()
......
...@@ -65,8 +65,8 @@ class Gem5Sim(HostSim): ...@@ -65,8 +65,8 @@ class Gem5Sim(HostSim):
self.name = f"Gem5Sim-{self._id}" self.name = f"Gem5Sim-{self._id}"
self.cpu_type_cp = "X86KvmCPU" self.cpu_type_cp = "X86KvmCPU"
self.cpu_type = "TimingSimpleCPU" self.cpu_type = "TimingSimpleCPU"
self.extra_main_args: list[str] = [] # TODO self.extra_main_args: list[str] = []
self.extra_config_args: list[str] = [] # TODO self.extra_config_args: list[str] = []
self._variant: str = "fast" self._variant: str = "fast"
self._sys_clock: str = "1GHz" # TODO: move to system module self._sys_clock: str = "1GHz" # TODO: move to system module
......
...@@ -180,6 +180,7 @@ class SimpleNS3Sim(NetSim): ...@@ -180,6 +180,7 @@ class SimpleNS3Sim(NetSim):
name=name, name=name,
) )
self._ns3_run_script: str = ns3_run_script self._ns3_run_script: str = ns3_run_script
self.opt: str | None = None
def run_cmd(self, inst: inst_base.Instantiation) -> str: def run_cmd(self, inst: inst_base.Instantiation) -> str:
return f"{inst.join_repo_base(self._executable)} {self._ns3_run_script} " return f"{inst.join_repo_base(self._executable)} {self._ns3_run_script} "
...@@ -225,7 +226,9 @@ class NS3DumbbellNet(SimpleNS3Sim): ...@@ -225,7 +226,9 @@ class NS3DumbbellNet(SimpleNS3Sim):
assert sock._type == inst_base.SockType.CONNECT assert sock._type == inst_base.SockType.CONNECT
cmd += f"--SimbricksPortRight={sock._path} " cmd += f"--SimbricksPortRight={sock._path} "
# TODO cmd += f"{self.opt}" if self.opt is not None:
cmd += f"{self.opt}"
return cmd return cmd
...@@ -251,5 +254,7 @@ class NS3BridgeNet(SimpleNS3Sim): ...@@ -251,5 +254,7 @@ class NS3BridgeNet(SimpleNS3Sim):
for sock in sockets: for sock in sockets:
cmd += f"--SimbricksPort={sock._path} " cmd += f"--SimbricksPort={sock._path} "
# TODO cmd += f"{self.opt}" if self.opt is not None:
cmd += f"{self.opt}"
return cmd return cmd
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