From f59eb936604939f454f572cef41d36f606f50b08 Mon Sep 17 00:00:00 2001 From: "Bobby R. Bruce" Date: Mon, 3 Oct 2022 13:11:43 -0700 Subject: [PATCH] tests: Add 'checkpoint-path' to simpoints stdlib example The 'configs/example/gem5_library_checkpoints/simpoints-se-checkpoint.py' example would dump the savepoint in the CWD. This is fine when running as an example, but we also run this script as a test. In this case the checkpoint litters the repository. To fix this, an optional 'checkpoint-path' argument is added to this example which specifies where the checkpoint is to be saved. In the tests, the checkpoint is saved to 'tests/gem5/resources'. This is our default location for resources needed/produced by tests and is ignored by git. Change-Id: I3dccc574b9e64d32386fd822ed7248ee365a0a08 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/64092 Maintainer: Jason Lowe-Power Reviewed-by: Jason Lowe-Power Tested-by: kokoro --- .../checkpoints/simpoints-se-checkpoint.py | 15 ++++++++++++++- .../test_gem5_library_examples.py | 5 ++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py b/configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py index 6094f09de1..e3b3c4c272 100644 --- a/configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py +++ b/configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py @@ -52,6 +52,7 @@ scons build/X86/gem5.opt ``` """ +import argparse from gem5.simulate.exit_event import ExitEvent from gem5.simulate.simulator import Simulator from gem5.utils.requires import requires @@ -68,6 +69,18 @@ from gem5.simulate.exit_event_generators import ( save_checkpoint_generator, ) +parser = argparse.ArgumentParser() + +parser.add_argument( + "--checkpoint-path", + type=str, + required=False, + default="se_checkpoint_folder/", + help="The directory to store the checkpoint.", +) + +args = parser.parse_args() + requires(isa_required=ISA.X86) # When taking a checkpoint, the cache state is not saved, so the cache @@ -109,7 +122,7 @@ board.set_se_binary_workload( simpoint=simpoint, ) -dir = Path("se_checkpoint_folder/") +dir = Path(args.checkpoint_path) dir.mkdir(exist_ok=True) simulator = Simulator( diff --git a/tests/gem5/gem5_library_example_tests/test_gem5_library_examples.py b/tests/gem5/gem5_library_example_tests/test_gem5_library_examples.py index d60fbb33a5..d8bcf6be8f 100644 --- a/tests/gem5/gem5_library_example_tests/test_gem5_library_examples.py +++ b/tests/gem5/gem5_library_example_tests/test_gem5_library_examples.py @@ -106,7 +106,10 @@ gem5_verify_config( "checkpoints", "simpoints-se-checkpoint.py", ), - config_args=[], + config_args=[ + "--checkpoint-path", + joinpath(resource_path, "se_checkpoint_folder-save"), + ], valid_isas=(constants.all_compiled_tag,), valid_hosts=constants.supported_hosts, length=constants.quick_tag,