Commit 025d7d0f authored by Jonas Kaufmann's avatar Jonas Kaufmann
Browse files

Revert "orchestration/simulators.py: speed up simulations using gem5 checkpoints"

The solution here was quite hacky in that we modified gem5's checkpoint file to have a timestamp of 0. This actually breaks when simulating a Linux host and conducting time measurements. The numbers you get will end up all over the place.
parent db2a01d9
...@@ -40,9 +40,6 @@ class ExpEnv(object): ...@@ -40,9 +40,6 @@ class ExpEnv(object):
self.workdir = os.path.abspath(workdir) self.workdir = os.path.abspath(workdir)
self.cpdir = os.path.abspath(cpdir) self.cpdir = os.path.abspath(cpdir)
self.shm_base = self.workdir self.shm_base = self.workdir
self.utilsdir = f'{self.repodir}/experiments/simbricks/utils'
"""Directory containing some utility scripts/binaries."""
self.qemu_img_path = f'{self.repodir}/sims/external/qemu/build/qemu-img' self.qemu_img_path = f'{self.repodir}/sims/external/qemu/build/qemu-img'
self.qemu_path = ( self.qemu_path = (
f'{self.repodir}/sims/external/qemu/build/' f'{self.repodir}/sims/external/qemu/build/'
......
...@@ -458,17 +458,6 @@ class Gem5Host(HostSim): ...@@ -458,17 +458,6 @@ class Gem5Host(HostSim):
self.extra_main_args = [] self.extra_main_args = []
self.extra_config_args = [] self.extra_config_args = []
self.variant = 'fast' self.variant = 'fast'
self.modify_checkpoint_tick = True
"""
Whether to modify the event queue tick before restoring a checkpoint.
When this is enabled, the restored checkpoint will start at event queue
tick 0. This is a performance optimization since now, connected
simulators don't have to simulate and synchronize until the restored
tick before the actual workload can be executed. Disable this if you
need to retain the differences in virtual time between multiple gem5
instances.
"""
def resreq_cores(self) -> int: def resreq_cores(self) -> int:
return 1 return 1
...@@ -477,13 +466,7 @@ class Gem5Host(HostSim): ...@@ -477,13 +466,7 @@ class Gem5Host(HostSim):
return 4096 return 4096
def prep_cmds(self, env: ExpEnv) -> tp.List[str]: def prep_cmds(self, env: ExpEnv) -> tp.List[str]:
cmds = [f'mkdir -p {env.gem5_cpdir(self)}'] return [f'mkdir -p {env.gem5_cpdir(self)}']
if 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)}'
)
return cmds
def run_cmd(self, env: ExpEnv) -> str: def run_cmd(self, env: ExpEnv) -> str:
cpu_type = self.cpu_type cpu_type = self.cpu_type
......
# Copyright 2023 Max Planck Institute for Software Systems, and
# National University of Singapore
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Copyright 2023 Max Planck Institute for Software Systems, and
# National University of Singapore
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""Script to modify the tick of a gem5 checkpoint."""
import argparse
import os
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
'--cpdir', help='Path to gem5 checkpoint directory', required=True
)
parser.add_argument(
'--tick',
help='The new value for the checkpoint\'s tick',
type=int,
required=True
)
args = parser.parse_args()
# Modify tick of all checkpoints in gem5 checkpoint directory to new_tick
for cp in filter(
lambda file: file.startswith('cpt.'), os.listdir(args.cpdir)
):
cp_file = f'{args.cpdir}/{cp}/m5.cpt'
if not os.path.exists(cp_file):
print(
f'WARN {os.path.basename(__file__)}: checkpoint '
f'{args.cpdir}/{cp} doesn\'t have a m5.cpt'
)
continue
with open(cp_file, 'r', encoding='utf-8') as f:
data: str = f.read()
curtick = int(cp.split('.')[1])
newdata = data.replace(f'curTick={curtick}', f'curTick={args.tick}', 1)
with open(cp_file, 'w', encoding='utf-8') as f:
f.write(newdata)
print(
f'INFO {os.path.basename(__file__)}: successfully set tick of '
f'{args.cpdir}/{cp} to {args.tick}'
)
if __name__ == '__main__':
main()
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