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