python: Apply Black formatter to Python files

The command executed was `black src configs tests util`.

Change-Id: I8dfaa6ab04658fea37618127d6ac19270028d771
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/47024
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Bobby R. Bruce
2022-07-05 11:02:25 -07:00
committed by Giacomo Travaglini
parent 1cfaa8da83
commit 787204c92d
980 changed files with 35668 additions and 22233 deletions

View File

@@ -54,7 +54,7 @@ from m5.objects import Root
from gem5.utils.requires import requires
from gem5.components.boards.x86_board import X86Board
from gem5.components.memory import DualChannelDDR4_2400
from gem5.components.processors.simple_switchable_processor import(
from gem5.components.processors.simple_switchable_processor import (
SimpleSwitchableProcessor,
)
from gem5.components.processors.cpu_types import CPUTypes
@@ -66,7 +66,7 @@ from m5.stats.gem5stats import get_simstat
from m5.util import warn
requires(
isa_required = ISA.X86,
isa_required=ISA.X86,
coherence_protocol_required=CoherenceProtocol.MESI_TWO_LEVEL,
kvm_required=True,
)
@@ -93,25 +93,25 @@ parser = argparse.ArgumentParser(
parser.add_argument(
"--benchmark",
type = str,
type=str,
required=True,
help = "Input the benchmark program to execute.",
choices = benchmark_choices,
help="Input the benchmark program to execute.",
choices=benchmark_choices,
)
parser.add_argument(
"--size",
type = str,
type=str,
required=True,
help = "Input the class of the program to simulate.",
choices = size_choices,
help="Input the class of the program to simulate.",
choices=size_choices,
)
parser.add_argument(
"--ticks",
type = int,
help = "Optionally put the maximum number of ticks to execute during the "\
"ROI. It accepts an integer value."
type=int,
help="Optionally put the maximum number of ticks to execute during the "
"ROI. It accepts an integer value.",
)
args = parser.parse_args()
@@ -121,28 +121,31 @@ args = parser.parse_args()
# We warn the user here.
if args.benchmark == "mg" and args.size == "C":
warn("mg.C uses 3.3 GB of memory. Currently we are simulating 3 GB\
of main memory in the system.")
warn(
"mg.C uses 3.3 GB of memory. Currently we are simulating 3 GB\
of main memory in the system."
)
# The simulation will fail in the case of `ft` with class C. We warn the user
# here.
elif args.benchmark == "ft" and args.size == "C":
warn("There is not enough memory for ft.C. Currently we are\
simulating 3 GB of main memory in the system.")
warn(
"There is not enough memory for ft.C. Currently we are\
simulating 3 GB of main memory in the system."
)
# Checking for the maximum number of instructions, if provided by the user.
# Setting up all the fixed system parameters here
# Caches: MESI Two Level Cache Hierarchy
from gem5.components.cachehierarchies.ruby.\
mesi_two_level_cache_hierarchy import(
from gem5.components.cachehierarchies.ruby.mesi_two_level_cache_hierarchy import (
MESITwoLevelCacheHierarchy,
)
cache_hierarchy = MESITwoLevelCacheHierarchy(
l1d_size = "32kB",
l1d_assoc = 8,
l1d_size="32kB",
l1d_assoc=8,
l1i_size="32kB",
l1i_assoc=8,
l2_size="256kB",
@@ -152,7 +155,7 @@ cache_hierarchy = MESITwoLevelCacheHierarchy(
# Memory: Dual Channel DDR4 2400 DRAM device.
# The X86 board only supports 3 GB of main memory.
memory = DualChannelDDR4_2400(size = "3GB")
memory = DualChannelDDR4_2400(size="3GB")
# Here we setup the processor. This is a special switchable processor in which
# a starting core type and a switch core type must be specified. Once a
@@ -189,29 +192,27 @@ board = X86Board(
# Also, we sleep the system for some time so that the output is printed
# properly.
command="/home/gem5/NPB3.3-OMP/bin/{}.{}.x;".format(args.benchmark,args.size)\
+ "sleep 5;" \
command = (
"/home/gem5/NPB3.3-OMP/bin/{}.{}.x;".format(args.benchmark, args.size)
+ "sleep 5;"
+ "m5 exit;"
)
board.set_kernel_disk_workload(
# The x86 linux kernel will be automatically downloaded to the
# `~/.cache/gem5` directory if not already present.
# npb benchamarks was tested with kernel version 4.19.83
kernel=Resource(
"x86-linux-kernel-4.19.83",
),
kernel=Resource("x86-linux-kernel-4.19.83"),
# The x86-npb image will be automatically downloaded to the
# `~/.cache/gem5` directory if not already present.
disk_image=Resource(
"x86-npb",
),
disk_image=Resource("x86-npb"),
readfile_contents=command,
)
# We need this for long running processes.
m5.disableAllListeners()
root = Root(full_system = True, system = board)
root = Root(full_system=True, system=board)
# sim_quantum must be set when KVM cores are used.
@@ -251,8 +252,7 @@ else:
print("Unexpected termination of simulation before ROI was reached!")
print(
"Exiting @ tick {} because {}.".format(
m5.curTick(),
exit_event.getCause()
m5.curTick(), exit_event.getCause()
)
)
exit(-1)
@@ -279,8 +279,10 @@ if exit_event.getCause() == "workend":
m5.stats.dump()
end_tick = m5.curTick()
elif exit_event.getCause() == "simulate() limit reached" and \
args.ticks is not None:
elif (
exit_event.getCause() == "simulate() limit reached"
and args.ticks is not None
):
print("Dump stats at the end of {} ticks in the ROI".format(args.ticks))
m5.stats.dump()
@@ -289,8 +291,7 @@ else:
print("Unexpected termination of simulation while ROI was being executed!")
print(
"Exiting @ tick {} because {}.".format(
m5.curTick(),
exit_event.getCause()
m5.curTick(), exit_event.getCause()
)
)
exit(-1)
@@ -307,14 +308,14 @@ gem5stats = get_simstat(root)
# We get the number of committed instructions from the timing
# cores. We then sum and print them at the end.
roi_insts = float(\
gem5stats.to_json()\
["system"]["processor"]["cores2"]["core"]["exec_context.thread_0"]\
["numInsts"]["value"]
) + float(\
gem5stats.to_json()\
["system"]["processor"]["cores3"]["core"]["exec_context.thread_0"]\
["numInsts"]["value"]\
roi_insts = float(
gem5stats.to_json()["system"]["processor"]["cores2"]["core"][
"exec_context.thread_0"
]["numInsts"]["value"]
) + float(
gem5stats.to_json()["system"]["processor"]["cores3"]["core"][
"exec_context.thread_0"
]["numInsts"]["value"]
)
# Simulation is over at this point. We acknowledge that all the simulation
@@ -326,8 +327,10 @@ print("Done with the simulation")
print()
print("Performance statistics:")
print("Simulated time in ROI: %.2fs" % ((end_tick-start_tick)/1e12))
print("Simulated time in ROI: %.2fs" % ((end_tick - start_tick) / 1e12))
print("Instructions executed in ROI: %d" % ((roi_insts)))
print("Ran a total of", m5.curTick()/1e12, "simulated seconds")
print("Total wallclock time: %.2fs, %.2f min" % \
(time.time()-globalStart, (time.time()-globalStart)/60))
print("Ran a total of", m5.curTick() / 1e12, "simulated seconds")
print(
"Total wallclock time: %.2fs, %.2f min"
% (time.time() - globalStart, (time.time() - globalStart) / 60)
)