Commit 98edd40c authored by Hejing Li's avatar Hejing Li
Browse files

add pre_tar

parent f8a439be
......@@ -120,22 +120,22 @@ class ExperimentBaseRunner(abc.ABC):
async def prepare(self) -> None:
# generate config tars
copies = []
# TODO: FIXME
for host in self.exp.hosts:
path = self.env.cfgtar_path(host)
if self._verbose:
print('preparing config tar:', path)
# TODO: FIXME
host.node_config.make_tar(self.env, path)
executor = self.sim_executor(host)
task = asyncio.create_task(executor.send_file(path, self._verbose))
copies.append(task)
await asyncio.gather(*copies)
# copies = []
# for host in self.exp.hosts:
# path = self.env.cfgtar_path(host)
# if self._verbose:
# print('preparing config tar:', path)
# # TODO: FIXME
# host.node_config.make_tar(self.env, path)
# executor = self.sim_executor(host)
# task = asyncio.create_task(executor.send_file(path, self._verbose))
# copies.append(task)
# await asyncio.gather(*copies)
# prepare all simulators in parallel
sims = []
for sim in self._simulation.all_simulators():
sim.prep_tar(self._instantiation)
prep_cmds = list(sim.prep_cmds(inst=self._instantiation))
executor = self.sim_executor(sim)
task = asyncio.create_task(
......
......@@ -117,6 +117,9 @@ class Simulator(utils_base.IdObj):
"""Full name of the simulator."""
return ""
def prep_tar(self, inst) -> None:
pass
# pylint: disable=unused-argument
def prep_cmds(self, inst: inst_base.Instantiation) -> list[str]:
"""Commands to prepare execution of this simulator."""
......
......@@ -95,7 +95,7 @@ class Gem5Sim(HostSim):
def __init__(self, e: sim_base.Simulation):
super().__init__(e)
self.name: str = ''
self.name = super().full_name()
self.cpu_type_cp = 'X86KvmCPU'
self.cpu_type = 'TimingSimpleCPU'
self.extra_main_args: list[str] = []
......@@ -110,6 +110,7 @@ class Gem5Sim(HostSim):
def resreq_mem(self) -> int:
return 4096
# TODO: remove it
def config_str(self) -> str:
cp_es = [] if self.nockp else ['m5 checkpoint']
exit_es = ['m5 exit']
......@@ -119,10 +120,19 @@ class Gem5Sim(HostSim):
host.run_cmds() + host.cleanup_cmds() + exit_es
return '\n'.join(es)
def prep_tar(self, inst: inst_base.Instantiation) -> None:
path = inst.cfgtar_path(self)
print(self.name, ' preparing config tar:', path)
for c in self._components:
for d in c.disks:
d.prepare_image_path(inst, path)
def prep_cmds(self, inst: inst_base.Instantiation) -> tp.List[str]:
def prep_cmds(self, env: ExpEnv) -> tp.List[str]:
cmds = [f'mkdir -p {env.gem5_cpdir(self)}']
if env.restore_cp and self.modify_checkpoint_tick:
if inst.env.restore_cp and self.modify_checkpoint_tick:
cmds.append(
f'python3 {env.utilsdir}/modify_gem5_cp_tick.py --tick 0 '
f'--cpdir {env.gem5_cpdir(self)}'
......
......@@ -89,14 +89,12 @@ class LinuxConfigDiskImage(DiskImage):
def available_formats(self) -> list[str]:
return ["raw"]
async def prepare_image_path(self, env: expenv.ExpEnv, format: str) -> str:
# TODO: build tar from host path parameters and then return path
path = env.dynamic_img_path(self, format)
def prepare_image_path(self, inst, path) -> str:
with tarfile.open(path, 'w:') as tar:
# add main run script
cfg_i = tarfile.TarInfo('guest/run.sh')
cfg_i.mode = 0o777
cfg_f = self.host.strfile(self.host.config_str())
cfg_f = self.host.strfile(self.host._config_str(inst))
cfg_f.seek(0, io.SEEK_END)
cfg_i.size = cfg_f.tell()
cfg_f.seek(0, io.SEEK_SET)
......@@ -104,7 +102,7 @@ class LinuxConfigDiskImage(DiskImage):
cfg_f.close()
# add additional config files
for (n, f) in self.host.config_files(env).items():
for (n, f) in self.host.config_files(inst).items():
f_i = tarfile.TarInfo('guest/' + n)
f_i.mode = 0o777
f.seek(0, io.SEEK_END)
......
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