Unverified Commit 1de5e7ce authored by Jakob Görgen's avatar Jakob Görgen
Browse files

support for kernel command append + fixed checkpoint restore logic

parent a0494ee3
...@@ -338,10 +338,7 @@ def main(): ...@@ -338,10 +338,7 @@ def main():
# if this is an experiment with a checkpoint we might have to create # if this is an experiment with a checkpoint we might have to create
# it # it
prereq = None prereq = None
if ( if inst.create_checkpoint and inst.simulation.any_supports_checkpointing():
inst.create_checkpoint
and inst.simulation.any_supports_checkpointing()
):
checkpointing_inst = inst.copy() checkpointing_inst = inst.copy()
checkpointing_inst.restore_checkpoint = False checkpointing_inst.restore_checkpoint = False
checkpointing_inst.create_checkpoint = True checkpointing_inst.create_checkpoint = True
...@@ -353,6 +350,8 @@ def main(): ...@@ -353,6 +350,8 @@ def main():
for index in range(args.firstrun, args.firstrun + args.runs): for index in range(args.firstrun, args.firstrun + args.runs):
inst_copy = inst.copy() inst_copy = inst.copy()
inst_copy.preserve_tmp_folder = False inst_copy.preserve_tmp_folder = False
inst_copy.create_checkpoint = inst.create_checkpoint
inst_copy.restore_checkpoint = inst.restore_checkpoint
if index == args.firstrun + args.runs - 1: if index == args.firstrun + args.runs - 1:
inst_copy._preserve_checkpoints = False inst_copy._preserve_checkpoints = False
add_exp(instantiation=inst_copy, rt=rt, prereq=prereq) add_exp(instantiation=inst_copy, rt=rt, prereq=prereq)
......
...@@ -102,9 +102,10 @@ class Gem5Sim(HostSim): ...@@ -102,9 +102,10 @@ class Gem5Sim(HostSim):
if inst.create_checkpoint: if inst.create_checkpoint:
cpu_type = self.cpu_type_cp cpu_type = self.cpu_type_cp
full_sys_hosts = self.filter_components_by_type(ty=sys_host.FullSystemHost) full_sys_hosts = self.filter_components_by_type(ty=sys_host.BaseLinuxHost)
if len(full_sys_hosts) != 1: if len(full_sys_hosts) != 1:
raise Exception("Gem5Sim only supports simulating 1 FullSystemHost") raise Exception("Gem5Sim only supports simulating 1 FullSystemHost")
host_spec = full_sys_hosts[0]
cmd = f"{inst.join_repo_base(f'{self._executable}.{self._variant}')} --outdir={inst.get_simmulator_output_dir(sim=self)} " cmd = f"{inst.join_repo_base(f'{self._executable}.{self._variant}')} --outdir={inst.get_simmulator_output_dir(sim=self)} "
cmd += " ".join(self.extra_main_args) cmd += " ".join(self.extra_main_args)
...@@ -112,22 +113,21 @@ class Gem5Sim(HostSim): ...@@ -112,22 +113,21 @@ class Gem5Sim(HostSim):
f" {inst.join_repo_base('sims/external/gem5/configs/simbricks/simbricks.py')} --caches --l2cache " f" {inst.join_repo_base('sims/external/gem5/configs/simbricks/simbricks.py')} --caches --l2cache "
"--l1d_size=32kB --l1i_size=32kB --l2_size=32MB " "--l1d_size=32kB --l1i_size=32kB --l2_size=32MB "
"--l1d_assoc=8 --l1i_assoc=8 --l2_assoc=16 " "--l1d_assoc=8 --l1i_assoc=8 --l2_assoc=16 "
f"--cacheline_size=64 --cpu-clock={full_sys_hosts[0].cpu_freq}" f"--cacheline_size=64 --cpu-clock={host_spec.cpu_freq}"
f" --sys-clock={self._sys_clock} " f" --sys-clock={self._sys_clock} "
f"--checkpoint-dir={inst.cpdir_subdir(sim=self)} " f"--checkpoint-dir={inst.cpdir_subdir(sim=self)} "
f"--kernel={inst.join_repo_base('images/vmlinux')} " f"--kernel={inst.join_repo_base('images/vmlinux')} "
) )
for disk in full_sys_hosts[0].disks: for disk in host_spec.disks:
cmd += f"--disk-image={disk.path(inst=inst, format='raw')} " cmd += f"--disk-image={disk.path(inst=inst, format='raw')} "
cmd += ( cmd += (
f"--cpu-type={cpu_type} --mem-size={full_sys_hosts[0].memory}MB " f"--cpu-type={cpu_type} --mem-size={host_spec.memory}MB "
f"--num-cpus={full_sys_hosts[0].cores} " f"--num-cpus={host_spec.cores} "
"--mem-type=DDR4_2400_16x4 " "--mem-type=DDR4_2400_16x4 "
) )
# TODO if host_spec.kcmd_append is not None:
# if self.node_config.kcmd_append: cmd += f'--command-line-append="{host_spec.kcmd_append}" '
# cmd += f'--command-line-append="{self.node_config.kcmd_append}" '
if inst.create_checkpoint: if inst.create_checkpoint:
cmd += "--max-checkpoints=1 " cmd += "--max-checkpoints=1 "
...@@ -141,7 +141,7 @@ class Gem5Sim(HostSim): ...@@ -141,7 +141,7 @@ class Gem5Sim(HostSim):
) )
) )
fsh_interfaces = full_sys_hosts[0].interfaces() fsh_interfaces = host_spec.interfaces()
pci_interfaces = system.Interface.filter_by_type( pci_interfaces = system.Interface.filter_by_type(
interfaces=fsh_interfaces, ty=sys_pcie.PCIeHostInterface interfaces=fsh_interfaces, ty=sys_pcie.PCIeHostInterface
...@@ -250,12 +250,7 @@ class QemuSim(HostSim): ...@@ -250,12 +250,7 @@ class QemuSim(HostSim):
latency, period, sync = sim_base.Simulator.get_unique_latency_period_sync( latency, period, sync = sim_base.Simulator.get_unique_latency_period_sync(
channels=self.get_channels() channels=self.get_channels()
) )
accel = ",accel=kvm:tcg" if not sync else "" accel = ",accel=kvm:tcg" if not sync else ""
# if self.node_config.kcmd_append: # TODO: FIXME
# kcmd_append = " " + self.node_config.kcmd_append
# else:
# kcmd_append = ""
cmd = ( cmd = (
f"{inst.join_repo_base(relative_path=self._executable)} -machine q35{accel} -serial mon:stdio " f"{inst.join_repo_base(relative_path=self._executable)} -machine q35{accel} -serial mon:stdio "
...@@ -263,33 +258,37 @@ class QemuSim(HostSim): ...@@ -263,33 +258,37 @@ class QemuSim(HostSim):
f"-kernel {inst.join_repo_base('images/bzImage')} " f"-kernel {inst.join_repo_base('images/bzImage')} "
) )
full_sys_hosts = self.filter_components_by_type(ty=sys_host.FullSystemHost) full_sys_hosts = self.filter_components_by_type(ty=sys_host.BaseLinuxHost)
if len(full_sys_hosts) != 1: if len(full_sys_hosts) != 1:
raise Exception("QEMU only supports simulating 1 FullSystemHost") raise Exception("QEMU only supports simulating 1 FullSystemHost")
host_spec = full_sys_hosts[0]
kcmd_append = ""
if host_spec.kcmd_append is not None:
kcmd_append = " " + host_spec.kcmd_append
for index, disk in enumerate(self._disks): for index, disk in enumerate(self._disks):
cmd += f"-drive file={disk[0]},if=ide,index={index},media=disk,driver={disk[1]} " cmd += f"-drive file={disk[0]},if=ide,index={index},media=disk,driver={disk[1]} "
cmd += ( cmd += (
'-append "earlyprintk=ttyS0 console=ttyS0 root=/dev/sda1 ' '-append "earlyprintk=ttyS0 console=ttyS0 root=/dev/sda1 '
# f'init=/home/ubuntu/guestinit.sh rw{kcmd_append}" ' # TODO: FIXME f'init=/home/ubuntu/guestinit.sh rw{kcmd_append}" '
f'init=/home/ubuntu/guestinit.sh rw" ' f"-m {host_spec.memory} -smp {host_spec.cores} "
f"-m {full_sys_hosts[0].memory} -smp {full_sys_hosts[0].cores} "
) )
if sync: if sync:
unit = full_sys_hosts[0].cpu_freq[-3:] unit = host_spec.cpu_freq[-3:]
if unit.lower() == "ghz": if unit.lower() == "ghz":
base = 0 base = 0
elif unit.lower() == "mhz": elif unit.lower() == "mhz":
base = 3 base = 3
else: else:
raise ValueError("cpu frequency specified in unsupported unit") raise ValueError("cpu frequency specified in unsupported unit")
num = float(full_sys_hosts[0].cpu_freq[:-3]) num = float(host_spec.cpu_freq[:-3])
shift = base - int(math.ceil(math.log(num, 2))) shift = base - int(math.ceil(math.log(num, 2)))
cmd += f" -icount shift={shift},sleep=off " cmd += f" -icount shift={shift},sleep=off "
fsh_interfaces = full_sys_hosts[0].interfaces() fsh_interfaces = host_spec.interfaces()
pci_interfaces = system.Interface.filter_by_type( pci_interfaces = system.Interface.filter_by_type(
interfaces=fsh_interfaces, ty=sys_pcie.PCIeHostInterface interfaces=fsh_interfaces, ty=sys_pcie.PCIeHostInterface
) )
......
...@@ -73,7 +73,7 @@ class BaseLinuxHost(FullSystemHost): ...@@ -73,7 +73,7 @@ class BaseLinuxHost(FullSystemHost):
super().__init__(s) super().__init__(s)
self.applications: list[app.BaseLinuxApplication] = [] self.applications: list[app.BaseLinuxApplication] = []
self.load_modules = [] self.load_modules = []
self.kcmd_append = "" self.kcmd_append: str | None = None
def add_app(self, a: app.BaseLinuxApplication) -> None: def add_app(self, a: app.BaseLinuxApplication) -> None:
self.applications.append(a) self.applications.append(a)
......
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