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:
committed by
Giacomo Travaglini
parent
1cfaa8da83
commit
787204c92d
@@ -56,11 +56,12 @@ from m5.objects.Platform import Platform
|
||||
|
||||
default_tracer = ExeTracer()
|
||||
|
||||
|
||||
class BaseCPU(ClockedObject):
|
||||
type = 'BaseCPU'
|
||||
type = "BaseCPU"
|
||||
abstract = True
|
||||
cxx_header = "cpu/base.hh"
|
||||
cxx_class = 'gem5::BaseCPU'
|
||||
cxx_class = "gem5::BaseCPU"
|
||||
|
||||
cxx_exports = [
|
||||
PyBindMethod("switchOut"),
|
||||
@@ -75,7 +76,7 @@ class BaseCPU(ClockedObject):
|
||||
@classmethod
|
||||
def memory_mode(cls):
|
||||
"""Which memory mode does this CPU require?"""
|
||||
return 'invalid'
|
||||
return "invalid"
|
||||
|
||||
@classmethod
|
||||
def require_caches(cls):
|
||||
@@ -94,17 +95,21 @@ class BaseCPU(ClockedObject):
|
||||
def takeOverFrom(self, old_cpu):
|
||||
self._ccObject.takeOverFrom(old_cpu._ccObject)
|
||||
|
||||
|
||||
system = Param.System(Parent.any, "system object")
|
||||
cpu_id = Param.Int(-1, "CPU identifier")
|
||||
socket_id = Param.Unsigned(0, "Physical Socket identifier")
|
||||
numThreads = Param.Unsigned(1, "number of HW thread contexts")
|
||||
pwr_gating_latency = Param.Cycles(300,
|
||||
"Latency to enter power gating state when all contexts are suspended")
|
||||
pwr_gating_latency = Param.Cycles(
|
||||
300,
|
||||
"Latency to enter power gating state when all contexts are suspended",
|
||||
)
|
||||
|
||||
power_gating_on_idle = Param.Bool(False, "Control whether the core goes "\
|
||||
"to the OFF power state after all thread are disabled for "\
|
||||
"pwr_gating_latency cycles")
|
||||
power_gating_on_idle = Param.Bool(
|
||||
False,
|
||||
"Control whether the core goes "
|
||||
"to the OFF power state after all thread are disabled for "
|
||||
"pwr_gating_latency cycles",
|
||||
)
|
||||
|
||||
function_trace = Param.Bool(False, "Enable function trace")
|
||||
function_trace_start = Param.Tick(0, "Tick to start function trace")
|
||||
@@ -113,10 +118,12 @@ class BaseCPU(ClockedObject):
|
||||
|
||||
syscallRetryLatency = Param.Cycles(10000, "Cycles to wait until retry")
|
||||
|
||||
do_checkpoint_insts = Param.Bool(True,
|
||||
"enable checkpoint pseudo instructions")
|
||||
do_statistics_insts = Param.Bool(True,
|
||||
"enable statistics pseudo instructions")
|
||||
do_checkpoint_insts = Param.Bool(
|
||||
True, "enable checkpoint pseudo instructions"
|
||||
)
|
||||
do_statistics_insts = Param.Bool(
|
||||
True, "enable statistics pseudo instructions"
|
||||
)
|
||||
|
||||
workload = VectorParam.Process([], "processes to run")
|
||||
|
||||
@@ -125,93 +132,105 @@ class BaseCPU(ClockedObject):
|
||||
isa = VectorParam.BaseISA([], "ISA instance")
|
||||
decoder = VectorParam.InstDecoder([], "Decoder instance")
|
||||
|
||||
max_insts_all_threads = Param.Counter(0,
|
||||
"terminate when all threads have reached this inst count")
|
||||
max_insts_any_thread = Param.Counter(0,
|
||||
"terminate when any thread reaches this inst count")
|
||||
simpoint_start_insts = VectorParam.Counter([],
|
||||
"starting instruction counts of simpoints")
|
||||
progress_interval = Param.Frequency('0Hz',
|
||||
"frequency to print out the progress message")
|
||||
max_insts_all_threads = Param.Counter(
|
||||
0, "terminate when all threads have reached this inst count"
|
||||
)
|
||||
max_insts_any_thread = Param.Counter(
|
||||
0, "terminate when any thread reaches this inst count"
|
||||
)
|
||||
simpoint_start_insts = VectorParam.Counter(
|
||||
[], "starting instruction counts of simpoints"
|
||||
)
|
||||
progress_interval = Param.Frequency(
|
||||
"0Hz", "frequency to print out the progress message"
|
||||
)
|
||||
|
||||
switched_out = Param.Bool(False,
|
||||
"Leave the CPU switched out after startup (used when switching " \
|
||||
"between CPU models)")
|
||||
switched_out = Param.Bool(
|
||||
False,
|
||||
"Leave the CPU switched out after startup (used when switching "
|
||||
"between CPU models)",
|
||||
)
|
||||
|
||||
tracer = Param.InstTracer(default_tracer, "Instruction tracer")
|
||||
|
||||
icache_port = RequestPort("Instruction Port")
|
||||
dcache_port = RequestPort("Data Port")
|
||||
_cached_ports = ['icache_port', 'dcache_port']
|
||||
_cached_ports = ["icache_port", "dcache_port"]
|
||||
|
||||
_uncached_interrupt_response_ports = []
|
||||
_uncached_interrupt_request_ports = []
|
||||
|
||||
def createInterruptController(self):
|
||||
self.interrupts = [
|
||||
self.ArchInterrupts() for i in range(self.numThreads)]
|
||||
self.ArchInterrupts() for i in range(self.numThreads)
|
||||
]
|
||||
|
||||
def connectCachedPorts(self, in_ports):
|
||||
for p in self._cached_ports:
|
||||
exec('self.%s = in_ports' % p)
|
||||
exec("self.%s = in_ports" % p)
|
||||
|
||||
def connectUncachedPorts(self, in_ports, out_ports):
|
||||
for p in self._uncached_interrupt_response_ports:
|
||||
exec('self.%s = out_ports' % p)
|
||||
exec("self.%s = out_ports" % p)
|
||||
for p in self._uncached_interrupt_request_ports:
|
||||
exec('self.%s = in_ports' % p)
|
||||
exec("self.%s = in_ports" % p)
|
||||
|
||||
def connectAllPorts(self, cached_in, uncached_in, uncached_out):
|
||||
self.connectCachedPorts(cached_in)
|
||||
self.connectUncachedPorts(uncached_in, uncached_out)
|
||||
|
||||
def connectBus(self, bus):
|
||||
self.connectAllPorts(bus.cpu_side_ports,
|
||||
bus.cpu_side_ports, bus.mem_side_ports)
|
||||
self.connectAllPorts(
|
||||
bus.cpu_side_ports, bus.cpu_side_ports, bus.mem_side_ports
|
||||
)
|
||||
|
||||
def addPrivateSplitL1Caches(self, ic, dc, iwc = None, dwc = None):
|
||||
def addPrivateSplitL1Caches(self, ic, dc, iwc=None, dwc=None):
|
||||
self.icache = ic
|
||||
self.dcache = dc
|
||||
self.icache_port = ic.cpu_side
|
||||
self.dcache_port = dc.cpu_side
|
||||
self._cached_ports = ['icache.mem_side', 'dcache.mem_side']
|
||||
self._cached_ports = ["icache.mem_side", "dcache.mem_side"]
|
||||
if iwc and dwc:
|
||||
self.itb_walker_cache = iwc
|
||||
self.dtb_walker_cache = dwc
|
||||
self.mmu.connectWalkerPorts(
|
||||
iwc.cpu_side, dwc.cpu_side)
|
||||
self._cached_ports += ["itb_walker_cache.mem_side", \
|
||||
"dtb_walker_cache.mem_side"]
|
||||
self.mmu.connectWalkerPorts(iwc.cpu_side, dwc.cpu_side)
|
||||
self._cached_ports += [
|
||||
"itb_walker_cache.mem_side",
|
||||
"dtb_walker_cache.mem_side",
|
||||
]
|
||||
else:
|
||||
self._cached_ports += self.ArchMMU.walkerPorts()
|
||||
|
||||
# Checker doesn't need its own tlb caches because it does
|
||||
# functional accesses only
|
||||
if self.checker != NULL:
|
||||
self._cached_ports += [ "checker." + port
|
||||
for port in self.ArchMMU.walkerPorts() ]
|
||||
self._cached_ports += [
|
||||
"checker." + port for port in self.ArchMMU.walkerPorts()
|
||||
]
|
||||
|
||||
def addTwoLevelCacheHierarchy(self, ic, dc, l2c, iwc=None, dwc=None,
|
||||
xbar=None):
|
||||
def addTwoLevelCacheHierarchy(
|
||||
self, ic, dc, l2c, iwc=None, dwc=None, xbar=None
|
||||
):
|
||||
self.addPrivateSplitL1Caches(ic, dc, iwc, dwc)
|
||||
self.toL2Bus = xbar if xbar else L2XBar()
|
||||
self.connectCachedPorts(self.toL2Bus.cpu_side_ports)
|
||||
self.l2cache = l2c
|
||||
self.toL2Bus.mem_side_ports = self.l2cache.cpu_side
|
||||
self._cached_ports = ['l2cache.mem_side']
|
||||
self._cached_ports = ["l2cache.mem_side"]
|
||||
|
||||
def createThreads(self):
|
||||
# If no ISAs have been created, assume that the user wants the
|
||||
# default ISA.
|
||||
if len(self.isa) == 0:
|
||||
self.isa = [ self.ArchISA() for i in range(self.numThreads) ]
|
||||
self.isa = [self.ArchISA() for i in range(self.numThreads)]
|
||||
else:
|
||||
if len(self.isa) != int(self.numThreads):
|
||||
raise RuntimeError("Number of ISA instances doesn't "
|
||||
"match thread count")
|
||||
raise RuntimeError(
|
||||
"Number of ISA instances doesn't " "match thread count"
|
||||
)
|
||||
if len(self.decoder) != 0:
|
||||
raise RuntimeError("Decoders should not be set up manually")
|
||||
self.decoder = list([ self.ArchDecoder(isa=isa) for isa in self.isa ])
|
||||
self.decoder = list([self.ArchDecoder(isa=isa) for isa in self.isa])
|
||||
if self.checker != NULL:
|
||||
self.checker.createThreads()
|
||||
|
||||
@@ -221,9 +240,9 @@ class BaseCPU(ClockedObject):
|
||||
def createPhandleKey(self, thread):
|
||||
# This method creates a unique key for this cpu as a function of a
|
||||
# certain thread
|
||||
return 'CPU-%d-%d-%d' % (self.socket_id, self.cpu_id, thread)
|
||||
return "CPU-%d-%d-%d" % (self.socket_id, self.cpu_id, thread)
|
||||
|
||||
#Generate simple CPU Device Tree structure
|
||||
# Generate simple CPU Device Tree structure
|
||||
def generateDeviceTree(self, state):
|
||||
"""Generate cpu nodes for each thread and the corresponding part of the
|
||||
cpu-map node. Note that this implementation does not support clusters
|
||||
@@ -235,14 +254,14 @@ class BaseCPU(ClockedObject):
|
||||
if bool(self.switched_out):
|
||||
return
|
||||
|
||||
cpus_node = FdtNode('cpus')
|
||||
cpus_node = FdtNode("cpus")
|
||||
cpus_node.append(state.CPUCellsProperty())
|
||||
#Special size override of 0
|
||||
cpus_node.append(FdtPropertyWords('#size-cells', [0]))
|
||||
# Special size override of 0
|
||||
cpus_node.append(FdtPropertyWords("#size-cells", [0]))
|
||||
|
||||
# Generate cpu nodes
|
||||
for i in range(int(self.numThreads)):
|
||||
reg = (int(self.socket_id)<<8) + int(self.cpu_id) + i
|
||||
reg = (int(self.socket_id) << 8) + int(self.cpu_id) + i
|
||||
node = FdtNode("cpu@%x" % reg)
|
||||
node.append(FdtPropertyStrings("device_type", "cpu"))
|
||||
node.appendCompatible(["gem5,arm-cpu"])
|
||||
@@ -251,8 +270,10 @@ class BaseCPU(ClockedObject):
|
||||
if found:
|
||||
platform.annotateCpuDeviceNode(node, state)
|
||||
else:
|
||||
warn("Platform not found for device tree generation; " \
|
||||
"system or multiple CPUs may not start")
|
||||
warn(
|
||||
"Platform not found for device tree generation; "
|
||||
"system or multiple CPUs may not start"
|
||||
)
|
||||
|
||||
freq = int(self.clk_domain.unproxy(self).clock[0].frequency)
|
||||
node.append(FdtPropertyWords("clock-frequency", freq))
|
||||
@@ -272,20 +293,23 @@ class BaseCPU(ClockedObject):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.power_state.possible_states=['ON', 'CLK_GATED', 'OFF']
|
||||
self.power_state.possible_states = ["ON", "CLK_GATED", "OFF"]
|
||||
|
||||
self._cached_ports = self._cached_ports + self.ArchMMU.walkerPorts()
|
||||
|
||||
# Practically speaking, these ports will exist on the x86 interrupt
|
||||
# controller class.
|
||||
if "pio" in self.ArchInterrupts._ports:
|
||||
self._uncached_interrupt_response_ports = \
|
||||
self._uncached_interrupt_response_ports = (
|
||||
self._uncached_interrupt_response_ports + ["interrupts[0].pio"]
|
||||
)
|
||||
if "int_responder" in self.ArchInterrupts._ports:
|
||||
self._uncached_interrupt_response_ports = \
|
||||
self._uncached_interrupt_response_ports + [
|
||||
"interrupts[0].int_responder"]
|
||||
self._uncached_interrupt_response_ports = (
|
||||
self._uncached_interrupt_response_ports
|
||||
+ ["interrupts[0].int_responder"]
|
||||
)
|
||||
if "int_requestor" in self.ArchInterrupts._ports:
|
||||
self._uncached_interrupt_request_ports = \
|
||||
self._uncached_interrupt_request_ports + [
|
||||
"interrupts[0].int_requestor"]
|
||||
self._uncached_interrupt_request_ports = (
|
||||
self._uncached_interrupt_request_ports
|
||||
+ ["interrupts[0].int_requestor"]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user