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