Hello Gabor Dozsa,
I'd like you to do a code review. Please visit
https://gem5-review.googlesource.com/3944
to review the following change.
Change subject: config: Clean up core timing model discovery
......................................................................
config: Clean up core timing model discovery
Instead of hard-coding timing models in CpuConfig.py, use
introspection to find them in the cores.arm model package.
Change-Id: I6642dc9cbc3f5beeeec748e716c9426c233d51ea
Signed-off-by: Andreas Sandberg <[email protected]>
Reviewed-by: Gabor Dozsa <[email protected]>
---
M configs/common/CpuConfig.py
M configs/common/cores/arm/__init__.py
2 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/configs/common/CpuConfig.py b/configs/common/CpuConfig.py
index 4def9fd..731ba4f 100644
--- a/configs/common/CpuConfig.py
+++ b/configs/common/CpuConfig.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2012 ARM Limited
+# Copyright (c) 2012, 2017 ARM Limited
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
@@ -110,28 +110,11 @@
fatal("%s does not support data dependency tracing. Use a CPU
model of"
" type or inherited from DerivO3CPU.", cpu_cls)
-# The ARM detailed CPU is special in the sense that it doesn't exist
-# in the normal object hierarchy, so we have to add it manually.
-try:
- from cores.arm.O3_ARM_v7a import O3_ARM_v7a_3
- _cpu_classes["O3_ARM_v7a_3"] = O3_ARM_v7a_3
-except:
- pass
-
-# The calibrated ex5-model cores
-try:
- from cores.arm.ex5_LITTLE import ex5_LITTLE
- _cpu_classes["ex5_LITTLE"] = ex5_LITTLE
-except:
- pass
-
-try:
- from cores.arm.ex5_big import ex5_big
- _cpu_classes["ex5_big"] = ex5_big
-except:
- pass
-
-
# Add all CPUs in the object hierarchy.
for name, cls in inspect.getmembers(m5.objects, is_cpu_class):
_cpu_classes[name] = cls
+
+import cores.arm
+for mod_name, module in inspect.getmembers(cores.arm, inspect.ismodule):
+ for name, cls in inspect.getmembers(module, is_cpu_class):
+ _cpu_classes[name] = cls
diff --git a/configs/common/cores/arm/__init__.py
b/configs/common/cores/arm/__init__.py
index 7a2173e..5c803dd 100644
--- a/configs/common/cores/arm/__init__.py
+++ b/configs/common/cores/arm/__init__.py
@@ -34,3 +34,22 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Authors: Andreas Sandberg
+
+_cpu_modules = [
+ "O3_ARM_v7a",
+ "ex5_big",
+ "ex5_LITTLE",
+]
+
+from importlib import import_module as _import
+for c in _cpu_modules:
+ try:
+ _import("." + c, package=__package__)
+ except:
+ # We sometimes can't import modules if they miss
+ # dependencies. For example, OoO models won't be available if
+ # gem5's O3 model hasn't been selected at compile time.
+ pass
+
+__all__ = _cpu_modules
+
--
To view, visit https://gem5-review.googlesource.com/3944
To unsubscribe, visit https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6642dc9cbc3f5beeeec748e716c9426c233d51ea
Gerrit-Change-Number: 3944
Gerrit-PatchSet: 1
Gerrit-Owner: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Gabor Dozsa <[email protected]>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev