From 90b087171b048aa226be96dc32d73624f957b793 Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Wed, 26 Oct 2016 14:50:54 -0400 Subject: config: Break out base options for usage with NULL ISA This patch breaks out the most basic configuration options into a set of base options, to allow them to be used also by scripts that do not involve any ISA, and thus no actual CPUs or devices. The patch also fixes a few modules so that they can be imported in a NULL build, and avoid dragging in FSConfig every time Options is imported. --- configs/common/CpuConfig.py | 2 +- configs/common/FSConfig.py | 2 +- configs/common/Options.py | 117 ++++++++++++++++++++++----------------- configs/common/PlatformConfig.py | 2 +- configs/common/Simulation.py | 4 +- 5 files changed, 70 insertions(+), 57 deletions(-) (limited to 'configs/common') diff --git a/configs/common/CpuConfig.py b/configs/common/CpuConfig.py index 3220acecd..757ec2d08 100644 --- a/configs/common/CpuConfig.py +++ b/configs/common/CpuConfig.py @@ -70,7 +70,7 @@ def is_cpu_class(cls): return issubclass(cls, m5.objects.BaseCPU) and \ not cls.abstract and \ not issubclass(cls, m5.objects.CheckerCPU) - except TypeError: + except (TypeError, AttributeError): return False def get(name): diff --git a/configs/common/FSConfig.py b/configs/common/FSConfig.py index c1d8f6fe0..3a169a4bb 100644 --- a/configs/common/FSConfig.py +++ b/configs/common/FSConfig.py @@ -42,7 +42,7 @@ from m5.objects import * from Benchmarks import * from m5.util import * -import PlatformConfig +from common import PlatformConfig # Populate to reflect supported os types per target ISA os_types = { 'alpha' : [ 'linux' ], diff --git a/configs/common/Options.py b/configs/common/Options.py index 5bed98aca..16d817f59 100644 --- a/configs/common/Options.py +++ b/configs/common/Options.py @@ -41,13 +41,11 @@ import m5 from m5.defines import buildEnv from m5.objects import * -from Benchmarks import * +from common.Benchmarks import * -import CpuConfig -import MemConfig -import PlatformConfig - -from FSConfig import os_types +from common import CpuConfig +from common import MemConfig +from common import PlatformConfig def _listCpuTypes(option, opt, value, parser): CpuConfig.print_cpu_list() @@ -61,15 +59,10 @@ def _listPlatformTypes(option, opt, value, parser): PlatformConfig.print_platform_list() sys.exit(0) -def addCommonOptions(parser): - # system options - parser.add_option("--list-cpu-types", - action="callback", callback=_listCpuTypes, - help="List available CPU types") - parser.add_option("--cpu-type", type="choice", default="atomic", - choices=CpuConfig.cpu_names(), - help = "type of cpu to run with") - parser.add_option("--checker", action="store_true"); +# Add the very basic options that work also in the case of the no ISA +# being used, and consequently no CPUs, but rather various types of +# testers and traffic generators. +def addNoISAOptions(parser): parser.add_option("-n", "--num-cpus", type="int", default=1) parser.add_option("--sys-voltage", action="store", type="string", default='1.0V', @@ -79,27 +72,6 @@ def addCommonOptions(parser): default='1GHz', help = """Top-level clock for blocks running at system speed""") - parser.add_option("--cpu-clock", action="store", type="string", - default='2GHz', - help="Clock for blocks running at CPU speed") - parser.add_option("--smt", action="store_true", default=False, - help = """ - Only used if multiple programs are specified. If true, - then the number of threads per cpu is same as the - number of programs.""") - parser.add_option("--elastic-trace-en", action="store_true", - help="""Enable capture of data dependency and instruction - fetch traces using elastic trace probe.""") - # Trace file paths input to trace probe in a capture simulation and input - # to Trace CPU in a replay simulation - parser.add_option("--inst-trace-file", action="store", type="string", - help="""Instruction fetch trace file input to - Elastic Trace probe in a capture simulation and - Trace CPU in a replay simulation""", default="") - parser.add_option("--data-trace-file", action="store", type="string", - help="""Data dependency trace file input to - Elastic Trace probe in a capture simulation and - Trace CPU in a replay simulation""", default="") # Memory Options parser.add_option("--list-mem-types", @@ -116,8 +88,6 @@ def addCommonOptions(parser): default="512MB", help="Specify the physical memory size (single memory)") - parser.add_option("-l", "--lpae", action="store_true") - parser.add_option("-V", "--virtualisation", action="store_true") parser.add_option("--memchecker", action="store_true") @@ -128,7 +98,6 @@ def addCommonOptions(parser): help="use external port for SystemC TLM cosimulation") parser.add_option("--caches", action="store_true") parser.add_option("--l2cache", action="store_true") - parser.add_option("--fastmem", action="store_true") parser.add_option("--num-dirs", type="int", default=1) parser.add_option("--num-l2caches", type="int", default=1) parser.add_option("--num-l3caches", type="int", default=1) @@ -142,6 +111,61 @@ def addCommonOptions(parser): parser.add_option("--l3_assoc", type="int", default=16) parser.add_option("--cacheline_size", type="int", default=64) + # Enable Ruby + parser.add_option("--ruby", action="store_true") + + # Run duration options + parser.add_option("-m", "--abs-max-tick", type="int", default=m5.MaxTick, + metavar="TICKS", help="Run to absolute simulated tick " + "specified including ticks from a restored checkpoint") + parser.add_option("--rel-max-tick", type="int", default=None, + metavar="TICKS", help="Simulate for specified number of" + " ticks relative to the simulation start tick (e.g. if " + "restoring a checkpoint)") + parser.add_option("--maxtime", type="float", default=None, + help="Run to the specified absolute simulated time in " + "seconds") + +# Add common options that assume a non-NULL ISA. +def addCommonOptions(parser): + # start by adding the base options that do not assume an ISA + addNoISAOptions(parser) + + # system options + parser.add_option("--list-cpu-types", + action="callback", callback=_listCpuTypes, + help="List available CPU types") + parser.add_option("--cpu-type", type="choice", default="atomic", + choices=CpuConfig.cpu_names(), + help = "type of cpu to run with") + parser.add_option("--checker", action="store_true"); + parser.add_option("--cpu-clock", action="store", type="string", + default='2GHz', + help="Clock for blocks running at CPU speed") + parser.add_option("--smt", action="store_true", default=False, + help = """ + Only used if multiple programs are specified. If true, + then the number of threads per cpu is same as the + number of programs.""") + parser.add_option("--elastic-trace-en", action="store_true", + help="""Enable capture of data dependency and instruction + fetch traces using elastic trace probe.""") + # Trace file paths input to trace probe in a capture simulation and input + # to Trace CPU in a replay simulation + parser.add_option("--inst-trace-file", action="store", type="string", + help="""Instruction fetch trace file input to + Elastic Trace probe in a capture simulation and + Trace CPU in a replay simulation""", default="") + parser.add_option("--data-trace-file", action="store", type="string", + help="""Data dependency trace file input to + Elastic Trace probe in a capture simulation and + Trace CPU in a replay simulation""", default="") + + parser.add_option("-l", "--lpae", action="store_true") + parser.add_option("-V", "--virtualisation", action="store_true") + + parser.add_option("--fastmem", action="store_true") + # dist-gem5 options parser.add_option("--dist", action="store_true", help="Parallel distributed gem5 simulation.") @@ -175,20 +199,7 @@ def addCommonOptions(parser): action="store", type="string", help="Link delay in seconds\nDEFAULT: 10us") - # Enable Ruby - parser.add_option("--ruby", action="store_true") - # Run duration options - parser.add_option("-m", "--abs-max-tick", type="int", default=m5.MaxTick, - metavar="TICKS", help="Run to absolute simulated tick " \ - "specified including ticks from a restored checkpoint") - parser.add_option("--rel-max-tick", type="int", default=None, - metavar="TICKS", help="Simulate for specified number of" \ - " ticks relative to the simulation start tick (e.g. if " \ - "restoring a checkpoint)") - parser.add_option("--maxtime", type="float", default=None, - help="Run to the specified absolute simulated time in " \ - "seconds") parser.add_option("-I", "--maxinsts", action="store", type="int", default=None, help="""Total number of instructions to simulate (default: run forever)""") @@ -297,6 +308,8 @@ def addSEOptions(parser): help="Redirect stderr to a file.") def addFSOptions(parser): + from FSConfig import os_types + # Simulation options parser.add_option("--timesync", action="store_true", help="Prevent simulated time from getting ahead of real time") diff --git a/configs/common/PlatformConfig.py b/configs/common/PlatformConfig.py index 1d047b118..3541c07fb 100644 --- a/configs/common/PlatformConfig.py +++ b/configs/common/PlatformConfig.py @@ -63,7 +63,7 @@ def is_platform_class(cls): try: return issubclass(cls, m5.objects.Platform) and \ not cls.abstract - except TypeError: + except (TypeError, AttributeError): return False def get(name): diff --git a/configs/common/Simulation.py b/configs/common/Simulation.py index b18d65cbc..c4d5c9644 100644 --- a/configs/common/Simulation.py +++ b/configs/common/Simulation.py @@ -43,8 +43,8 @@ import sys from os import getcwd from os.path import join as joinpath -import CpuConfig -import MemConfig +from common import CpuConfig +from common import MemConfig import m5 from m5.defines import buildEnv -- cgit v1.2.3