Bobby R. Bruce has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/52086 )
Change subject: tests,python,configs: Replace Resource override download
......................................................................
tests,python,configs: Replace Resource override download
The override parameter in the constructor has been renamed to to
'download_md5_mismatch'. This makes the purpose of this parameter
clearer.
The default value has been changed from False to True. We found in most
cases we want to re-download files if the md5 values have changes. Not
wanting to do so is the corner case. This allows us to remove a lot of
parameters from test and example scripts, included in this patch.
Change-Id: I99fc7743f5adf78bf6f4f8efc6222e6df83ac6da
---
M tests/gem5/x86-boot-tests/test_linux_boot.py
M tests/gem5/riscv-boot-tests/test_linux_boot.py
M configs/example/gem5_library/arm-hello.py
M src/python/gem5/resources/downloader.py
M tests/gem5/configs/boot_kvm_fork_run.py
M tests/gem5/configs/parsec_disk_run.py
M src/python/gem5/resources/resource.py
M tests/gem5/configs/boot_kvm_switch_exit.py
M tests/gem5/hello_se/test_hello_se.py
M tests/gem5/stats/test_hdf5.py
M configs/example/gem5_library/x86-ubuntu-run.py
M tests/gem5/parsec-benchmarks/test_parsec.py
M tests/gem5/kvm-fork-tests/test_kvm_fork_run.py
M tests/gem5/configs/riscv_boot_exit_run.py
M tests/gem5/configs/simple_binary_run.py
M tests/gem5/m5_util/test_exit.py
M tests/gem5/configs/x86_boot_exit_run.py
M tests/gem5/kvm-switch-tests/test_kvm_cpu_switch.py
18 files changed, 42 insertions(+), 95 deletions(-)
diff --git a/configs/example/gem5_library/arm-hello.py
b/configs/example/gem5_library/arm-hello.py
index 7dbc8a2..067c867 100644
--- a/configs/example/gem5_library/arm-hello.py
+++ b/configs/example/gem5_library/arm-hello.py
@@ -84,20 +84,13 @@
# download the binary from the gem5 Resources cloud bucket if it's not
already
# present.
board.set_workload(
- Resource(
- # The `Resource` class reads the `resources.json` file from the
gem5
- # resources repository:
- # https://gem5.googlesource.com/public/gem5-resource.
- # Any resource specified in this file will be automatically
retrieved.
- # At the time of writing, this file is a WIP and does not contain
all
- # resources. Jira ticket:
https://gem5.atlassian.net/browse/GEM5-1096
- "arm-hello64-static",
- # `override=True` means the if the binary already exists locally
within
- # the resource directory, and the hash's differ to that in the
cloud
- # bucket, the local copy will be overwritten. If this were set to
false
- # an exception would be thrown in this case.
- override=True,
- )
+ # The `Resource` class reads the `resources.json` file from the gem5
+ # resources repository:
+ # https://gem5.googlesource.com/public/gem5-resource.
+ # Any resource specified in this file will be automatically retrieved.
+ # At the time of writing, this file is a WIP and does not contain all
+ # resources. Jira ticket: https://gem5.atlassian.net/browse/GEM5-1096
+ Resource("arm-hello64-static")
)
# Lastly we setup the root, instantiate the design, and run the simulation.
diff --git a/configs/example/gem5_library/x86-ubuntu-run.py
b/configs/example/gem5_library/x86-ubuntu-run.py
index d43b010..ea6bad4 100644
--- a/configs/example/gem5_library/x86-ubuntu-run.py
+++ b/configs/example/gem5_library/x86-ubuntu-run.py
@@ -122,20 +122,13 @@
board.set_workload(
# The x86 linux kernel will be automatically downloaded to the
# `tests/gem5/resources` directory if not already present.
- kernel=Resource(
- "x86-linux-kernel-5.4.49",
- override=True,
- ),
+ kernel=Resource("x86-linux-kernel-5.4.49"),
# The x86 ubuntu image will be automatically downloaded to the
# `tests/gem5/resources` directory if not already present.
- disk_image=Resource(
- "x86-ubuntu-img",
- override=True,
- ),
+ disk_image=Resource("x86-ubuntu-img"),
readfile_contents=command,
)
-
root = Root(full_system=True, system=board)
root.sim_quantum = int(1e9) # sim_quantum must be st if KVM cores are
used.
diff --git a/src/python/gem5/resources/downloader.py
b/src/python/gem5/resources/downloader.py
index f05d9d0..490d773 100644
--- a/src/python/gem5/resources/downloader.py
+++ b/src/python/gem5/resources/downloader.py
@@ -198,7 +198,7 @@
resource_name: str,
to_path: str,
unzip: Optional[bool] = True,
- override: Optional[bool] = False,
+ download_md5_mismatch: Optional[bool] = True,
) -> None:
"""
Obtains a gem5 resource and stored it to a specified location. If the
@@ -212,10 +212,10 @@
:param unzip: If true, gzipped resources will be unzipped prior to
saving
to `to_path`. True by default.
- :param override: If a resource is present with an incorrect hash (e.g.,
- an outdated version of the resource is present), `get_resource` will
delete
- this local resource and re-download it if this parameter is True.
False by
- default.
+ :param download_md5_mismatch: If a resource is present with an
incorrect
+ hash (e.g., an outdated version of the resource is present),
`get_resource`
+ will delete this local resource and re-download it if this parameter is
+ True. True by default.
:raises Exception: An exception is thrown if a file is already present
at
`to_path` but it does not have the correct md5 sum. An exception will
also
@@ -242,7 +242,7 @@
# In this case, the file has already been download, no
need to
# do so again.
return
- elif override:
+ elif download_md5_mismatch:
os.remove(to_path)
else:
raise Exception(
diff --git a/src/python/gem5/resources/resource.py
b/src/python/gem5/resources/resource.py
index e984227..bb87c31 100644
--- a/src/python/gem5/resources/resource.py
+++ b/src/python/gem5/resources/resource.py
@@ -95,7 +95,7 @@
self,
resource_name: str,
resource_directory: Optional[str] = None,
- override: Optional[bool] = False,
+ download_md5_mismatch: Optional[bool] = True,
):
"""
:param resource_name: The name of the gem5 resource.
@@ -103,10 +103,10 @@
resource is to be stored. If this parameter is not set, it will
set to
the environment variable `GEM5_RESOURCE_DIR`. If the environment
is not
set it will default to `~/.cache/gem5`.
- :param override: If the resource is present, but does not have the
- correct md5 value, the resoruce will be deleted and re-downloaded
if
- this value is True. Otherwise an exception will be thrown. False by
- default.
+ :param download_md5_mismatch: If the resource is present, but does
not
+ have the correct md5 value, the resoruce will be deleted and
+ re-downloaded if this value is True. Otherwise an exception will be
+ thrown. True by default.
"""
if resource_directory == None:
@@ -131,7 +131,9 @@
local_path=to_path,
metadata=get_resources_json_obj(resource_name))
get_resource(
- resource_name=resource_name, to_path=to_path, override=override
+ resource_name=resource_name,
+ to_path=to_path,
+ download_md5_mismatch=download_md5_mismatch
)
diff --git a/tests/gem5/configs/boot_kvm_fork_run.py
b/tests/gem5/configs/boot_kvm_fork_run.py
index e9f0172..327822c 100644
--- a/tests/gem5/configs/boot_kvm_fork_run.py
+++ b/tests/gem5/configs/boot_kvm_fork_run.py
@@ -92,12 +92,6 @@
help="The directory in which resources will be downloaded or exist.",
)
parser.add_argument(
- "-o",
- "--override-download",
- action="store_true",
- help="Override a local resource if the hashes do not match.",
-)
-parser.add_argument(
"-k",
"--kernel-args",
type=str,
@@ -207,12 +201,10 @@
motherboard.set_workload(
kernel=Resource(
"x86-linux-kernel-5.4.49",
- override=args.override_download,
resource_directory=args.resource_directory,
),
disk_image=Resource(
"x86-ubuntu-img",
- override=args.override_download,
resource_directory=args.resource_directory,
),
command=dedent(
diff --git a/tests/gem5/configs/boot_kvm_switch_exit.py
b/tests/gem5/configs/boot_kvm_switch_exit.py
index 91f8423..c200af9 100644
--- a/tests/gem5/configs/boot_kvm_switch_exit.py
+++ b/tests/gem5/configs/boot_kvm_switch_exit.py
@@ -83,12 +83,6 @@
help="The directory in which resources will be downloaded or exist.",
)
parser.add_argument(
- "-o",
- "--override-download",
- action="store_true",
- help="Override a local resource if the hashes do not match.",
-)
-parser.add_argument(
"-k",
"--kernel-args",
type=str,
@@ -192,12 +186,10 @@
motherboard.set_workload(
kernel=Resource(
"x86-linux-kernel-5.4.49",
- override=args.override_download,
resource_directory=args.resource_directory,
),
disk_image=Resource(
"x86-ubuntu-img",
- override=args.override_download,
resource_directory=args.resource_directory,
),
# The first exit signals to switch processors.
diff --git a/tests/gem5/configs/parsec_disk_run.py
b/tests/gem5/configs/parsec_disk_run.py
index d68d4f2..cb35c2d 100644
--- a/tests/gem5/configs/parsec_disk_run.py
+++ b/tests/gem5/configs/parsec_disk_run.py
@@ -143,13 +143,6 @@
help="The directory in which resources will be downloaded or exist.",
)
-parser.add_argument(
- "-o",
- "--override-download",
- action="store_true",
- help="Override a local resource if the hashes do not match.",
-)
-
args = parser.parse_args()
# Setup the cachie hierarchy.
@@ -238,12 +231,10 @@
kernel=Resource(
"x86-linux-kernel-5.4.49",
resource_directory=args.resource_directory,
- override=args.override_download,
),
disk_image=Resource(
"x86-parsec",
resource_directory=args.resource_directory,
- override=args.override_download,
),
readfile_contents=command,
)
diff --git a/tests/gem5/configs/riscv_boot_exit_run.py
b/tests/gem5/configs/riscv_boot_exit_run.py
index 97ba04c..57be8aa 100644
--- a/tests/gem5/configs/riscv_boot_exit_run.py
+++ b/tests/gem5/configs/riscv_boot_exit_run.py
@@ -92,13 +92,6 @@
help="The directory in which resources will be downloaded or exist.",
)
-parser.add_argument(
- "-o",
- "--override-download",
- action="store_true",
- help="Override a local resource if the hashes do not match.",
-)
-
args = parser.parse_args()
# Run a check to ensure the right version of gem5 is being used.
@@ -156,12 +149,10 @@
board.set_workload(
kernel=Resource(
"riscv-bootloader-vmlinux-5.10",
- override=args.override_download,
resource_directory=args.resource_directory,
),
disk_image=Resource(
"riscv-disk-img",
- override=args.override_download,
resource_directory=args.resource_directory,
),
)
diff --git a/tests/gem5/configs/simple_binary_run.py
b/tests/gem5/configs/simple_binary_run.py
index 229cebd..370bf5b 100644
--- a/tests/gem5/configs/simple_binary_run.py
+++ b/tests/gem5/configs/simple_binary_run.py
@@ -67,13 +67,6 @@
help="The directory in which resources will be downloaded or exist.",
)
-parser.add_argument(
- "-o",
- "--override-download",
- action="store_true",
- help="Override a local resource if the hashes do not match.",
-)
-
args = parser.parse_args()
def input_to_cputype(input: str) -> CPUTypes:
@@ -104,8 +97,7 @@
# Set the workload
binary = Resource(args.resource,
- resource_directory=args.resource_directory,
- override=args.override_download)
+ resource_directory=args.resource_directory)
motherboard.set_workload(binary)
root = Root(full_system=False, system=motherboard)
diff --git a/tests/gem5/configs/x86_boot_exit_run.py
b/tests/gem5/configs/x86_boot_exit_run.py
index 622b88d..3e79b20 100644
--- a/tests/gem5/configs/x86_boot_exit_run.py
+++ b/tests/gem5/configs/x86_boot_exit_run.py
@@ -100,13 +100,6 @@
help="The directory in which resources will be downloaded or exist.",
)
-parser.add_argument(
- "-o",
- "--override-download",
- action="store_true",
- help="Override a local resource if the hashes do not match.",
-)
-
args = parser.parse_args()
coherence_protocol_required = None
@@ -202,12 +195,10 @@
motherboard.set_workload(
kernel=Resource(
"x86-linux-kernel-5.4.49",
- override=args.override_download,
resource_directory=args.resource_directory,
),
disk_image=Resource(
"x86-ubuntu-img",
- override=args.override_download,
resource_directory=args.resource_directory,
),
kernel_args=kernal_args,
diff --git a/tests/gem5/hello_se/test_hello_se.py
b/tests/gem5/hello_se/test_hello_se.py
index 03ffd49..ea1f987 100644
--- a/tests/gem5/hello_se/test_hello_se.py
+++ b/tests/gem5/hello_se/test_hello_se.py
@@ -107,7 +107,6 @@
config_args=[
binary,
cpu,
- "--override-download",
"--resource-directory",
resource_path,
],
diff --git a/tests/gem5/kvm-fork-tests/test_kvm_fork_run.py
b/tests/gem5/kvm-fork-tests/test_kvm_fork_run.py
index d12f104..9f49873 100644
--- a/tests/gem5/kvm-fork-tests/test_kvm_fork_run.py
+++ b/tests/gem5/kvm-fork-tests/test_kvm_fork_run.py
@@ -81,7 +81,6 @@
"4",
"--mem-system",
mem_system,
- "--override-download",
"--resource-directory",
resource_path,
"--kernel-args=''",
diff --git a/tests/gem5/kvm-switch-tests/test_kvm_cpu_switch.py
b/tests/gem5/kvm-switch-tests/test_kvm_cpu_switch.py
index 19e83e5..da8f631 100644
--- a/tests/gem5/kvm-switch-tests/test_kvm_cpu_switch.py
+++ b/tests/gem5/kvm-switch-tests/test_kvm_cpu_switch.py
@@ -79,7 +79,6 @@
str(num_cpus),
"--mem-system",
mem_system,
- "--override-download",
"--resource-directory",
resource_path,
"--kernel-args=''",
diff --git a/tests/gem5/m5_util/test_exit.py
b/tests/gem5/m5_util/test_exit.py
index 8a8ffc7..48d9645 100644
--- a/tests/gem5/m5_util/test_exit.py
+++ b/tests/gem5/m5_util/test_exit.py
@@ -66,7 +66,6 @@
config_args=[
"x86-m5-exit",
"atomic",
- "--override-download",
"--resource-directory",
resource_path,
],
diff --git a/tests/gem5/parsec-benchmarks/test_parsec.py
b/tests/gem5/parsec-benchmarks/test_parsec.py
index 66b3687..b886e4c 100644
--- a/tests/gem5/parsec-benchmarks/test_parsec.py
+++ b/tests/gem5/parsec-benchmarks/test_parsec.py
@@ -88,7 +88,6 @@
benchmark,
"--size",
size,
- "--override-download",
"--resource-directory",
resource_path,
],
diff --git a/tests/gem5/riscv-boot-tests/test_linux_boot.py
b/tests/gem5/riscv-boot-tests/test_linux_boot.py
index 940702a..8cced2d 100644
--- a/tests/gem5/riscv-boot-tests/test_linux_boot.py
+++ b/tests/gem5/riscv-boot-tests/test_linux_boot.py
@@ -72,7 +72,6 @@
cache_type,
"--tick-exit",
str(to_tick),
- "--override-download",
"--resource-directory",
resource_path,
],
diff --git a/tests/gem5/stats/test_hdf5.py b/tests/gem5/stats/test_hdf5.py
index 545ef58..bf35f70 100644
--- a/tests/gem5/stats/test_hdf5.py
+++ b/tests/gem5/stats/test_hdf5.py
@@ -92,7 +92,6 @@
config_args=[
"arm-hello64-static",
"atomic",
- "--override-download",
"--resource-directory",
resource_path,
],
diff --git a/tests/gem5/x86-boot-tests/test_linux_boot.py
b/tests/gem5/x86-boot-tests/test_linux_boot.py
index 124ea8e..0f05d11 100644
--- a/tests/gem5/x86-boot-tests/test_linux_boot.py
+++ b/tests/gem5/x86-boot-tests/test_linux_boot.py
@@ -91,7 +91,6 @@
mem_system,
"--boot-type",
boot_type,
- "--override-download",
"--resource-directory",
resource_path,
]
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/52086
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I99fc7743f5adf78bf6f4f8efc6222e6df83ac6da
Gerrit-Change-Number: 52086
Gerrit-PatchSet: 1
Gerrit-Owner: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s