From 5f73a9bbf08751ca04b6486ecae0ccf138d97c78 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Tue, 8 Feb 2022 18:39:27 -0800 Subject: [PATCH 01/22] scons: Use either the "build" or "gem5.build" as build anchor. If gem5.build already exists within a directory, then that build directory can be used without having to worry about variants. If it doesn't exist and we find a build/${VARIANT} style path, then we use that as the anchor. In either case, the variant name is the final component of the build path. The parse_build_path function had been separating that out, but it was just put back onto the path again anyway by the only caller, and then split out again when that path was consumed. We save a step by not splitting it out in parse_build_path. Change-Id: I8705b3dbb7664748f5525869cb188df70319d403 --- SConstruct | 26 ++++--------------------- site_scons/gem5_scons/__init__.py | 32 +++++++++++++++++-------------- 2 files changed, 22 insertions(+), 36 deletions(-) diff --git a/SConstruct b/SConstruct index e7fa4b53b7..69c941a078 100755 --- a/SConstruct +++ b/SConstruct @@ -240,27 +240,9 @@ def makePathListAbsolute(path_list, root=GetLaunchDir()): # doesn't work (obviously!). BUILD_TARGETS[:] = makePathListAbsolute(BUILD_TARGETS) -# Generate a list of the unique build roots and configs that the -# collected targets reference. -variant_paths = set() -build_root = None -for t in BUILD_TARGETS: - this_build_root, variant = parse_build_path(t) - - # Make sure all targets use the same build root. - if not build_root: - build_root = this_build_root - elif this_build_root != build_root: - error("build targets not under same build root\n %s\n %s" % - (build_root, this_build_root)) - - # Collect all the variants into a set. - variant_paths.add(os.path.join('/', build_root, variant)) - -# Make sure build_root exists (might not if this is the first build there) -if not isdir(build_root): - mkdir(build_root) -main['BUILDROOT'] = build_root +# Generate a list of the unique build directories that the collected targets +# reference. +variant_paths = set(map(parse_build_path, BUILD_TARGETS)) ######################################################################## @@ -395,7 +377,7 @@ for variant_path in variant_paths: env = main.Clone() env['BUILDDIR'] = variant_path - gem5_build = os.path.join(build_root, variant_path, 'gem5.build') + gem5_build = os.path.join(variant_path, 'gem5.build') env['GEM5BUILD'] = gem5_build Execute(Mkdir(gem5_build)) diff --git a/site_scons/gem5_scons/__init__.py b/site_scons/gem5_scons/__init__.py index c93a5e29e0..3638d9c561 100644 --- a/site_scons/gem5_scons/__init__.py +++ b/site_scons/gem5_scons/__init__.py @@ -39,6 +39,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import os +import os.path import pickle import sys import tempfile @@ -56,7 +57,7 @@ termcap = get_termcap() def strip_build_path(path, env): path = str(path) build_base = "build/" - variant_base = env["BUILDROOT"] + os.path.sep + variant_base = os.path.dirname(env["BUILDDIR"]) + os.path.sep if path.startswith(variant_base): path = path[len(variant_base) :] elif path.startswith(build_base): @@ -117,7 +118,7 @@ class Transform: source = source[0 : self.max_sources] def strip(f): - return strip_build_path(str(f), env) + return strip_build_path(f, env) if len(source) > 0: srcs = list(map(strip, source)) @@ -255,18 +256,21 @@ def error(*args, **kwargs): def parse_build_path(target): path_dirs = target.split("/") - # Pop off the target file. - path_dirs.pop() - - # Search backwards for the "build" directory. Whatever was just before it - # was the name of the variant. - variant_dir = path_dirs.pop() - while path_dirs and path_dirs[-1] != "build": - variant_dir = path_dirs.pop() - if not path_dirs: - error("No non-leaf 'build' dir found on target path.", target) - - return os.path.join("/", *path_dirs), variant_dir + # Search backwards for a directory with a gem5.build sub-directory, or a + # directory who's parent is called "build". gem5.build identifies an + # existing gem5 build directory. A directory called "build" is an anchor + # for a legacy "build/${VARIANT}/${TARGET}" style build path, where the + # variant selects a default config to use. + while path_dirs: + dot_gem5 = os.path.join("/", *path_dirs, "gem5.build") + if ( + os.path.isdir(dot_gem5) + or len(path_dirs) > 1 + and path_dirs[-2] == "build" + ): + return os.path.join("/", *path_dirs) + path_dirs.pop() + error(f"No existing build directory and no variant for {target}") # The MakeAction wrapper, and a SCons tool to set up the *COMSTR variables. From db3a6e8e84cede09d305fc2d1fc54470bb19ed21 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 16 Feb 2022 04:54:22 -0800 Subject: [PATCH 02/22] scons: Use Kconfig to configure gem5. These are not yet consumed by anything, but convert all the settings from SCons variables to Kconfig variables. If you have existing SConsopts files which need to be converted, you should take a look at KCONFIG.md to learn about how kconfig is used in gem5. You should decide if any variables need to be available to C++ or kconfig itself, and whether those are options which should be detected automatically, or should be up to the user. Options which should be measured automatically should still be in SConsopts files, while user facing options should be added to new or existing Kconfig files. Generally, make sure you're storing c++/kconfig visible options in env['CONF'][...]. Also remove references to sticky_vars since persistent options should now be handled with kconfig, and export_vars since everything in env['CONF'] is now exported automatically. Switch SCons/gem5 to use Kconfig for configuration, except EXTRAS which is still a sticky SCons variable. This is necessary because EXTRAS also controls what config options exist. If it came from Kconfig itself, then there would be a circular dependency. This dependency could theoretically be handled by reparsing the Kconfig when EXTRAS directories were added or removed, but that would be complicated, and isn't supported by kconfiglib. It wouldn't be worth the significant effort it would take to add it, just to use Kconfig more purely. Change-Id: I29ab1940b2d7b0e6635a490452d05befe5b4a2c9 --- SConsopts | 53 -------- SConstruct | 105 +++++----------- build_opts/ALL | 15 +-- build_opts/ARM | 5 +- build_opts/ARM_MESI_Three_Level | 8 +- build_opts/ARM_MESI_Three_Level_HTM | 8 +- build_opts/ARM_MOESI_hammer | 8 +- build_opts/GCN3_X86 | 9 +- build_opts/Garnet_standalone | 5 +- build_opts/MIPS | 5 +- build_opts/NULL | 5 +- build_opts/NULL_MESI_Two_Level | 5 +- build_opts/NULL_MOESI_CMP_directory | 5 +- build_opts/NULL_MOESI_CMP_token | 5 +- build_opts/NULL_MOESI_hammer | 5 +- build_opts/POWER | 5 +- build_opts/RISCV | 5 +- build_opts/SPARC | 5 +- build_opts/VEGA_X86 | 9 +- build_opts/X86 | 7 +- build_opts/X86_MESI_Two_Level | 7 +- build_opts/X86_MI_example | 5 +- build_opts/X86_MOESI_AMD_Base | 5 +- site_scons/gem5_scons/kconfig.py | 116 ++++++++++++++++++ src/Kconfig | 53 ++++++++ src/arch/Kconfig | 37 ++++++ src/arch/{power/SConsopts => amdgpu/Kconfig} | 13 +- src/arch/amdgpu/gcn3/Kconfig | 33 +++++ src/arch/amdgpu/vega/Kconfig | 33 +++++ src/arch/{x86/SConsopts => arm/Kconfig} | 8 +- src/arch/arm/SConscript | 4 +- src/arch/arm/fastmodel/Kconfig | 60 +++++++++ src/arch/arm/fastmodel/SConscript | 4 + src/arch/arm/fastmodel/SConsopts | 27 ++-- src/arch/{arm/SConsopts => mips/Kconfig} | 6 +- src/arch/mips/SConscript | 2 +- src/arch/null/{SConsopts => Kconfig} | 6 +- src/arch/{mips/SConsopts => power/Kconfig} | 6 +- src/arch/power/SConscript | 2 +- src/arch/riscv/Kconfig | 27 ++++ src/arch/riscv/SConscript | 2 +- src/arch/riscv/SConsopts | 28 ----- src/arch/sparc/Kconfig | 27 ++++ src/arch/sparc/SConscript | 2 +- src/arch/sparc/SConsopts | 28 ----- src/arch/x86/Kconfig | 27 ++++ src/arch/x86/SConscript | 2 +- src/{arch/SConsopts => base/Kconfig} | 28 +++-- src/base/SConsopts | 3 - src/base/stats/Kconfig | 27 ++++ src/cpu/kvm/Kconfig | 34 +++++ src/cpu/kvm/SConsopts | 12 +- src/cpu/testers/directedtest/SConscript | 2 +- .../garnet_synthetic_traffic/SConscript | 2 +- src/cpu/testers/gpu_ruby_test/SConscript | 2 +- src/cpu/testers/rubytest/SConscript | 2 +- src/dev/net/Kconfig | 27 ++++ src/gpu-compute/Kconfig | 28 +++++ .../SConsopts => learning_gem5/part3/Kconfig} | 11 +- src/learning_gem5/part3/SConsopts | 3 - src/mem/ruby/Kconfig | 50 ++++++++ src/mem/ruby/SConscript | 4 +- src/mem/ruby/SConsopts | 10 +- src/mem/ruby/common/SConscript | 2 +- src/mem/ruby/network/SConscript | 2 +- src/mem/ruby/network/fault_model/SConscript | 2 +- src/mem/ruby/network/garnet/SConscript | 2 +- src/mem/ruby/network/simple/SConscript | 2 +- src/mem/ruby/profiler/SConscript | 2 +- src/mem/ruby/protocol/Kconfig | 62 ++++++++++ src/mem/ruby/protocol/SConscript | 2 +- src/mem/ruby/protocol/SConsopts | 17 --- src/mem/ruby/protocol/chi/Kconfig | 35 ++++++ src/mem/ruby/protocol/chi/SConsopts | 7 -- src/mem/ruby/slicc_interface/SConscript | 2 +- src/mem/ruby/structures/SConscript | 4 +- src/mem/ruby/system/SConscript | 4 +- src/proto/Kconfig | 27 ++++ src/systemc/Kconfig | 28 +++++ src/systemc/SConsopts | 3 - 80 files changed, 925 insertions(+), 370 deletions(-) delete mode 100644 SConsopts create mode 100644 site_scons/gem5_scons/kconfig.py create mode 100644 src/Kconfig create mode 100644 src/arch/Kconfig rename src/arch/{power/SConsopts => amdgpu/Kconfig} (90%) create mode 100644 src/arch/amdgpu/gcn3/Kconfig create mode 100644 src/arch/amdgpu/vega/Kconfig rename src/arch/{x86/SConsopts => arm/Kconfig} (92%) create mode 100644 src/arch/arm/fastmodel/Kconfig rename src/arch/{arm/SConsopts => mips/Kconfig} (92%) rename src/arch/null/{SConsopts => Kconfig} (92%) rename src/arch/{mips/SConsopts => power/Kconfig} (92%) create mode 100644 src/arch/riscv/Kconfig delete mode 100644 src/arch/riscv/SConsopts create mode 100644 src/arch/sparc/Kconfig delete mode 100644 src/arch/sparc/SConsopts create mode 100644 src/arch/x86/Kconfig rename src/{arch/SConsopts => base/Kconfig} (78%) create mode 100644 src/base/stats/Kconfig create mode 100644 src/cpu/kvm/Kconfig create mode 100644 src/dev/net/Kconfig create mode 100644 src/gpu-compute/Kconfig rename src/{gpu-compute/SConsopts => learning_gem5/part3/Kconfig} (89%) create mode 100644 src/mem/ruby/Kconfig create mode 100644 src/mem/ruby/protocol/Kconfig create mode 100644 src/mem/ruby/protocol/chi/Kconfig create mode 100644 src/proto/Kconfig create mode 100644 src/systemc/Kconfig diff --git a/SConsopts b/SConsopts deleted file mode 100644 index bb2de864b5..0000000000 --- a/SConsopts +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright (c) 2013, 2015-2020 ARM Limited -# All rights reserved. -# -# The license below extends only to copyright in the software and shall -# not be construed as granting a license to any other intellectual -# property including but not limited to intellectual property relating -# to a hardware implementation of the functionality of the software -# licensed hereunder. You may use the software subject to the license -# terms below provided that you ensure that this notice is replicated -# unmodified and in its entirety in all distributions of the software, -# modified or unmodified, in source code or in binary form. -# -# Copyright (c) 2011 Advanced Micro Devices, Inc. -# Copyright (c) 2009 The Hewlett-Packard Development Company -# Copyright (c) 2004-2005 The Regents of The University of Michigan -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer; -# redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution; -# neither the name of the copyright holders nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -import os -import os.path - -from gem5_scons import warning - -Import('*') - -sticky_vars.AddVariables( - ('BATCH', 'Use batch pool for build and tests', False), - ('BATCH_CMD', 'Batch pool submission command name', 'qdo'), - ('M5_BUILD_CACHE', 'Cache built objects in this directory', False), - ('USE_EFENCE', 'Link with Electric Fence malloc debugger', False), - ) diff --git a/SConstruct b/SConstruct index 69c941a078..405adbc080 100755 --- a/SConstruct +++ b/SConstruct @@ -77,6 +77,7 @@ # Global Python imports import atexit +import itertools import os import sys @@ -115,8 +116,6 @@ AddOption('--no-colors', dest='use_colors', action='store_false', help="Don't add color to abbreviated scons output") AddOption('--with-cxx-config', action='store_true', help="Build with support for C++-based configuration") -AddOption('--default', - help='Override which build_opts file to use for defaults') AddOption('--ignore-style', action='store_true', help='Disable style checking hooks') AddOption('--linker', action='store', default=None, choices=linker_options, @@ -162,6 +161,7 @@ sys.path[1:1] = [ Dir('#build_tools').abspath ] # declared above. from gem5_scons import error, warning, summarize_warnings, parse_build_path from gem5_scons import TempFileSpawn, EnvDefaults, MakeAction, MakeActionTool +from gem5_scons import kconfig import gem5_scons from gem5_scons.builders import ConfigFile, AddLocalRPATH, SwitchingHeaders from gem5_scons.builders import Blob @@ -215,13 +215,6 @@ Default(environ.get('M5_DEFAULT_BINARY', 'build/ARM/gem5.debug')) # ######################################################################## -# helper function: find last occurrence of element in list -def rfind(l, elt, offs = -1): - for i in range(len(l)+offs, 0, -1): - if l[i] == elt: - return i - raise ValueError("element not found") - # Take a list of paths (or SCons Nodes) and return a list with all # paths made absolute and ~-expanded. Paths will be interpreted # relative to the launch directory unless a different root is provided @@ -381,6 +374,10 @@ for variant_path in variant_paths: env['GEM5BUILD'] = gem5_build Execute(Mkdir(gem5_build)) + config_file = Dir(gem5_build).File('config') + kconfig_file = Dir(gem5_build).File('Kconfig') + gem5_kconfig_file = Dir('#src').File('Kconfig') + env.SConsignFile(os.path.join(gem5_build, 'sconsign')) # Set up default C++ compiler flags @@ -662,59 +659,13 @@ for variant_path in variant_paths: after_sconsopts_callbacks.append(cb) Export('AfterSConsopts') - # Sticky variables get saved in the variables file so they persist from - # one invocation to the next (unless overridden, in which case the new - # value becomes sticky). - sticky_vars = Variables(args=ARGUMENTS) - Export('sticky_vars') + extras_file = os.path.join(gem5_build, 'extras') + extras_var = Variables(extras_file, args=ARGUMENTS) - # EXTRAS is special since it affects what SConsopts need to be read. - sticky_vars.Add(('EXTRAS', 'Add extra directories to the compilation', '')) - - # Set env variables according to the build directory config. - sticky_vars.files = [] - # Variables for $BUILD_ROOT/$VARIANT_DIR are stored in - # $BUILD_ROOT/$VARIANT_DIR/gem5.build/variables - - gem5_build_vars = os.path.join(gem5_build, 'variables') - build_root_vars = os.path.join(build_root, 'variables', variant_dir) - current_vars_files = [gem5_build_vars, build_root_vars] - existing_vars_files = list(filter(isfile, current_vars_files)) - if existing_vars_files: - sticky_vars.files.extend(existing_vars_files) - if not GetOption('silent'): - print('Using saved variables file(s) %s' % - ', '.join(existing_vars_files)) - else: - # Variant specific variables file doesn't exist. - - # Get default build variables from source tree. Variables are - # normally determined by name of $VARIANT_DIR, but can be - # overridden by '--default=' arg on command line. - default = GetOption('default') - opts_dir = Dir('#build_opts').abspath - if default: - default_vars_files = [ - gem5_build_vars, - build_root_vars, - os.path.join(opts_dir, default) - ] - else: - default_vars_files = [os.path.join(opts_dir, variant_dir)] - existing_default_files = list(filter(isfile, default_vars_files)) - if existing_default_files: - default_vars_file = existing_default_files[0] - sticky_vars.files.append(default_vars_file) - print("Variables file(s) %s not found,\n using defaults in %s" % - (' or '.join(current_vars_files), default_vars_file)) - else: - error("Cannot find variables file(s) %s or default file(s) %s" % - (' or '.join(current_vars_files), - ' or '.join(default_vars_files))) - Exit(1) + extras_var.Add(('EXTRAS', 'Add extra directories to the compilation', '')) # Apply current settings for EXTRAS to env. - sticky_vars.Update(env) + extras_var.Update(env) # Parse EXTRAS variable to build list of all directories where we're # look for sources etc. This list is exported as extras_dir_list. @@ -725,6 +676,17 @@ for variant_path in variant_paths: Export('extras_dir_list') + # Generate a Kconfig that will source the main gem5 one, and any in any + # EXTRAS directories. + kconfig_base_py = Dir('#build_tools').File('kconfig_base.py') + kconfig_base_cmd_parts = [f'"{kconfig_base_py}" "{kconfig_file.abspath}"', + f'"{gem5_kconfig_file.abspath}"'] + for ed in extras_dir_list: + kconfig_base_cmd_parts.append(f'"{ed}"') + kconfig_base_cmd = ' '.join(kconfig_base_cmd_parts) + if env.Execute(kconfig_base_cmd) != 0: + error("Failed to build base Kconfig file") + # Variables which were determined with Configure. env['CONF'] = {} @@ -752,24 +714,15 @@ for variant_path in variant_paths: for cb in after_sconsopts_callbacks: cb() - # Update env for new variables added by the SConsopts. - sticky_vars.Update(env) + # If no config exists yet, see if we know how to make one? + if not isfile(config_file.abspath): + buildopts_file = Dir('#build_opts').File(variant_dir) + if not isfile(buildopts_file.abspath): + error('No config found, and no implicit config recognized') + kconfig.defconfig(env, kconfig_file.abspath, buildopts_file.abspath, + config_file.abspath) - Help(''' -Build variables for {dir}: -{help} -'''.format(dir=variant_dir, help=sticky_vars.GenerateHelpText(env)), - append=True) - - # If the old vars file exists, delete it to avoid confusion/stale values. - if isfile(build_root_vars): - warning(f'Deleting old variant variables file "{build_root_vars}"') - remove(build_root_vars) - # Save sticky variables back to the gem5.build variant variables file. - sticky_vars.Save(gem5_build_vars, env) - - # Pull all the sticky variables into the CONF dict. - env['CONF'].update({key: env[key] for key in sticky_vars.keys()}) + kconfig.update_env(env, kconfig_file.abspath, config_file.abspath) # Do this after we save setting back, or else we'll tack on an # extra 'qdo' every time we run scons. diff --git a/build_opts/ALL b/build_opts/ALL index 6e5ede2d50..7597531c3a 100644 --- a/build_opts/ALL +++ b/build_opts/ALL @@ -1,7 +1,8 @@ -USE_ARM_ISA = True -USE_MIPS_ISA = True -USE_POWER_ISA = True -USE_RISCV_ISA = True -USE_SPARC_ISA = True -USE_X86_ISA = True -PROTOCOL = 'MESI_Two_Level' +RUBY=y +RUBY_PROTOCOL_MESI_TWO_LEVEL=y +USE_ARM_ISA=y +USE_MIPS_ISA=y +USE_POWER_ISA=y +USE_RISCV_ISA=y +USE_SPARC_ISA=y +USE_X86_ISA=y diff --git a/build_opts/ARM b/build_opts/ARM index 8c30c21e5a..998b2cf008 100644 --- a/build_opts/ARM +++ b/build_opts/ARM @@ -1,2 +1,3 @@ -USE_ARM_ISA = True -PROTOCOL = 'CHI' +USE_ARM_ISA=y +RUBY=y +RUBY_PROTOCOL_CHI=y diff --git a/build_opts/ARM_MESI_Three_Level b/build_opts/ARM_MESI_Three_Level index 3057bec0c4..3782efb706 100644 --- a/build_opts/ARM_MESI_Three_Level +++ b/build_opts/ARM_MESI_Three_Level @@ -1,5 +1,3 @@ -# Copyright (c) 2019 ARM Limited -# All rights reserved. - -USE_ARM_ISA = True -PROTOCOL = 'MESI_Three_Level' +USE_ARM_ISA=y +RUBY=y +RUBY_PROTOCOL_MESI_THREE_LEVEL=y diff --git a/build_opts/ARM_MESI_Three_Level_HTM b/build_opts/ARM_MESI_Three_Level_HTM index 7f80c4eee2..04e2a5ebe1 100644 --- a/build_opts/ARM_MESI_Three_Level_HTM +++ b/build_opts/ARM_MESI_Three_Level_HTM @@ -1,5 +1,3 @@ -# Copyright (c) 2019 ARM Limited -# All rights reserved. - -USE_ARM_ISA = True -PROTOCOL = 'MESI_Three_Level_HTM' +USE_ARM_ISA=y +RUBY=y +RUBY_PROTOCOL_MESI_THREE_LEVEL_HTM=y diff --git a/build_opts/ARM_MOESI_hammer b/build_opts/ARM_MOESI_hammer index 5322fd96f2..ce8509280f 100644 --- a/build_opts/ARM_MOESI_hammer +++ b/build_opts/ARM_MOESI_hammer @@ -1,5 +1,3 @@ -# Copyright (c) 2019 ARM Limited -# All rights reserved. - -USE_ARM_ISA = True -PROTOCOL = 'MOESI_hammer' +USE_ARM_ISA=y +RUBY=y +RUBY_PROTOCOL_MOESI_HAMMER=y diff --git a/build_opts/GCN3_X86 b/build_opts/GCN3_X86 index aca2f62878..6e5534caf8 100644 --- a/build_opts/GCN3_X86 +++ b/build_opts/GCN3_X86 @@ -1,4 +1,5 @@ -PROTOCOL = 'GPU_VIPER' -USE_X86_ISA = True -TARGET_GPU_ISA = 'gcn3' -BUILD_GPU = True +RUBY=y +RUBY_PROTOCOL_GPU_VIPER=y +USE_X86_ISA=y +GCN3_GPU_ISA=y +BUILD_GPU=y diff --git a/build_opts/Garnet_standalone b/build_opts/Garnet_standalone index 2351c5221d..7460c9d73a 100644 --- a/build_opts/Garnet_standalone +++ b/build_opts/Garnet_standalone @@ -1,2 +1,3 @@ -USE_NULL_ISA = True -PROTOCOL = 'Garnet_standalone' +RUBY=y +RUBY_PROTOCOL_GARNET_STANDALONE=y +USE_NULL_ISA=y diff --git a/build_opts/MIPS b/build_opts/MIPS index 382e10163a..40955cf999 100644 --- a/build_opts/MIPS +++ b/build_opts/MIPS @@ -1,2 +1,3 @@ -USE_MIPS_ISA = True -PROTOCOL = 'MI_example' +RUBY=y +RUBY_PROTOCOL_MI_EXAMPLE=y +USE_MIPS_ISA=y diff --git a/build_opts/NULL b/build_opts/NULL index 51e287a080..d514ef168f 100644 --- a/build_opts/NULL +++ b/build_opts/NULL @@ -1,2 +1,3 @@ -USE_NULL_ISA = True -PROTOCOL='MI_example' +RUBY=y +RUBY_PROTOCOL_MI_EXAMPLE=y +USE_NULL_ISA=y diff --git a/build_opts/NULL_MESI_Two_Level b/build_opts/NULL_MESI_Two_Level index bafb199592..a6279e6b49 100644 --- a/build_opts/NULL_MESI_Two_Level +++ b/build_opts/NULL_MESI_Two_Level @@ -1,2 +1,3 @@ -USE_NULL_ISA = True -PROTOCOL = 'MESI_Two_Level' +RUBY=y +RUBY_PROTOCOL_MESI_TWO_LEVEL=y +USE_NULL_ISA=y diff --git a/build_opts/NULL_MOESI_CMP_directory b/build_opts/NULL_MOESI_CMP_directory index 3346964a6b..88b1de8dbc 100644 --- a/build_opts/NULL_MOESI_CMP_directory +++ b/build_opts/NULL_MOESI_CMP_directory @@ -1,2 +1,3 @@ -USE_NULL_ISA = True -PROTOCOL='MOESI_CMP_directory' +RUBY=y +RUBY_PROTOCOL_MOESI_CMP_DIRECTORY=y +USE_NULL_ISA=y diff --git a/build_opts/NULL_MOESI_CMP_token b/build_opts/NULL_MOESI_CMP_token index 4ea9e70536..5c3308125e 100644 --- a/build_opts/NULL_MOESI_CMP_token +++ b/build_opts/NULL_MOESI_CMP_token @@ -1,2 +1,3 @@ -USE_NULL_ISA = True -PROTOCOL='MOESI_CMP_token' +RUBY=y +RUBY_PROTOCOL_MOESI_CMP_TOKEN=y +USE_NULL_ISA=y diff --git a/build_opts/NULL_MOESI_hammer b/build_opts/NULL_MOESI_hammer index e91b78dddb..79cc7de4f9 100644 --- a/build_opts/NULL_MOESI_hammer +++ b/build_opts/NULL_MOESI_hammer @@ -1,2 +1,3 @@ -USE_NULL_ISA = True -PROTOCOL='MOESI_hammer' +RUBY=y +RUBY_PROTOCOL_MOESI_HAMMER=y +USE_NULL_ISA=y diff --git a/build_opts/POWER b/build_opts/POWER index 207356c0be..69f5e395cf 100644 --- a/build_opts/POWER +++ b/build_opts/POWER @@ -1,2 +1,3 @@ -USE_POWER_ISA = True -PROTOCOL = 'MI_example' +RUBY=y +RUBY_PROTOCOL_MI_EXAMPLE=y +USE_POWER_ISA=y diff --git a/build_opts/RISCV b/build_opts/RISCV index 22097b0b3e..756c39ec02 100644 --- a/build_opts/RISCV +++ b/build_opts/RISCV @@ -1,2 +1,3 @@ -USE_RISCV_ISA = True -PROTOCOL = 'MI_example' +RUBY=y +RUBY_PROTOCOL_MI_EXAMPLE=y +USE_RISCV_ISA=y diff --git a/build_opts/SPARC b/build_opts/SPARC index 22dec5f867..f2766d5ce4 100644 --- a/build_opts/SPARC +++ b/build_opts/SPARC @@ -1,2 +1,3 @@ -USE_SPARC_ISA = True -PROTOCOL = 'MI_example' +RUBY=y +RUBY_PROTOCOL_MI_EXAMPLE=y +USE_SPARC_ISA=y diff --git a/build_opts/VEGA_X86 b/build_opts/VEGA_X86 index 437b048ce7..58187a355d 100644 --- a/build_opts/VEGA_X86 +++ b/build_opts/VEGA_X86 @@ -1,4 +1,5 @@ -PROTOCOL = 'GPU_VIPER' -USE_X86_ISA = True -TARGET_GPU_ISA = 'vega' -BUILD_GPU = True +RUBY=y +RUBY_PROTOCOL_GPU_VIPER=y +USE_X86_ISA=y +VEGA_GPU_ISA=y +BUILD_GPU=y diff --git a/build_opts/X86 b/build_opts/X86 index 259325b92e..5167bf8c06 100644 --- a/build_opts/X86 +++ b/build_opts/X86 @@ -1,3 +1,4 @@ -USE_X86_ISA = True -PROTOCOL = 'MESI_Two_Level' -NUMBER_BITS_PER_SET = '128' +RUBY=y +NUMBER_BITS_PER_SET=128 +RUBY_PROTOCOL_MESI_TWO_LEVEL=y +USE_X86_ISA=y diff --git a/build_opts/X86_MESI_Two_Level b/build_opts/X86_MESI_Two_Level index 259325b92e..5167bf8c06 100644 --- a/build_opts/X86_MESI_Two_Level +++ b/build_opts/X86_MESI_Two_Level @@ -1,3 +1,4 @@ -USE_X86_ISA = True -PROTOCOL = 'MESI_Two_Level' -NUMBER_BITS_PER_SET = '128' +RUBY=y +NUMBER_BITS_PER_SET=128 +RUBY_PROTOCOL_MESI_TWO_LEVEL=y +USE_X86_ISA=y diff --git a/build_opts/X86_MI_example b/build_opts/X86_MI_example index 71bc9a5f3a..1388769868 100644 --- a/build_opts/X86_MI_example +++ b/build_opts/X86_MI_example @@ -1,2 +1,3 @@ -USE_X86_ISA = True -PROTOCOL = 'MI_example' +RUBY=y +RUBY_PROTOCOL_MI_EXAMPLE=y +USE_X86_ISA=y diff --git a/build_opts/X86_MOESI_AMD_Base b/build_opts/X86_MOESI_AMD_Base index f8f2ce7c8d..09b50b6558 100644 --- a/build_opts/X86_MOESI_AMD_Base +++ b/build_opts/X86_MOESI_AMD_Base @@ -1,2 +1,3 @@ -PROTOCOL = 'MOESI_AMD_Base' -USE_X86_ISA = True +RUBY=y +RUBY_PROTOCOL_MOESI_AMD_BASE=y +USE_X86_ISA=y diff --git a/site_scons/gem5_scons/kconfig.py b/site_scons/gem5_scons/kconfig.py new file mode 100644 index 0000000000..6c2ec81fa3 --- /dev/null +++ b/site_scons/gem5_scons/kconfig.py @@ -0,0 +1,116 @@ +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import os + +from . import error +import kconfiglib + + +def _prep_env(env, base_kconfig, config_path=None): + """ + Prepare the required env vars for Kconfiglib + return the Scons env with Kconfiglib env + + :param env: Scons env + :param base_kconfig: path to the Top-level Kconfig file + :param config_path: path to the configuration file + """ + kconfig_env = env.Clone() + for key, val in kconfig_env["CONF"].items(): + if isinstance(val, bool): + val = "y" if val else "n" + kconfig_env["ENV"][key] = val + kconfig_env["ENV"]["CONFIG_"] = "" + if config_path: + kconfig_env["ENV"]["KCONFIG_CONFIG"] = config_path + + ext = env.Dir("#ext") + kconfiglib_dir = ext.Dir("Kconfiglib") + defconfig_py = kconfiglib_dir.File("defconfig.py") + menuconfig_py = kconfiglib_dir.File("menuconfig.py") + + kconfig_env["DEFCONFIG_PY"] = defconfig_py + kconfig_env["MENUCONFIG_PY"] = menuconfig_py + kconfig_env["BASE_KCONFIG"] = base_kconfig + return kconfig_env + + +def defconfig(env, base_kconfig, config_in, config_out): + """ + Interface of handling defconfig.py of Kconfiglib + """ + kconfig_env = _prep_env(env, base_kconfig, config_out) + kconfig_env["CONFIG_IN"] = config_in + if ( + kconfig_env.Execute( + '"${DEFCONFIG_PY}" --kconfig "${BASE_KCONFIG}" ' '"${CONFIG_IN}"' + ) + != 0 + ): + error("Failed to run defconfig") + + +def update_env(env, base_kconfig, config_path): + """ + Update the Scons' env["CONF"] options from kconfig env + + :param env: Scons env + :param base_kconfig: path to the Top-level Kconfig file + :param config_path: path to the configuration file + """ + kconfig_env = _prep_env(env, base_kconfig, config_path) + + saved_env = os.environ + os.environ.update( + {key: str(val) for key, val in kconfig_env["ENV"].items()} + ) + kconfig = kconfiglib.Kconfig(filename=base_kconfig) + os.environ = saved_env + + kconfig.load_config(config_path) + for sym in kconfig.unique_defined_syms: + val = sym.str_value + if sym.type == kconfiglib.BOOL: + env["CONF"][sym.name] = True if val == "y" else False + elif sym.type == kconfiglib.TRISTATE: + warning("No way to configure modules for now") + env["CONF"][sym.name] = True if val == "y" else False + elif sym.type == kconfiglib.INT: + if not val: + val = "0" + env["CONF"][sym.name] = int(val, 0) + elif sym.type == kconfiglib.HEX: + if not val: + val = "0" + env["CONF"][sym.name] = int(val, 16) + elif sym.type == kconfiglib.STRING: + env["CONF"][sym.name] = val + elif sym.type == kconfiglib.UNKNOWN: + warning(f'Config symbol "{sym.name}" has unknown type') + env["CONF"][sym.name] = val + else: + type_name = kconfiglib.TYPE_TO_STR[sym.type] + error(f"Unrecognized symbol type {type_name}") diff --git a/src/Kconfig b/src/Kconfig new file mode 100644 index 0000000000..02bf90ab86 --- /dev/null +++ b/src/Kconfig @@ -0,0 +1,53 @@ +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +mainmenu "$(MAIN_MENU_TEXT)" + +config BATCH + bool "Use batch pool for build and test" + default n + +config BATCH_CMD + string "Batch pool submission command name" + default "qdo" + depends on BATCH + +config M5_BUILD_CACHE + string "Cache built objects in this directory" + default "" + +config USE_EFENCE + bool "Link with Electric Fence malloc debugger" + default n + +rsource "base/Kconfig" +rsource "mem/ruby/Kconfig" +rsource "learning_gem5/part3/Kconfig" +rsource "proto/Kconfig" +rsource "dev/net/Kconfig" +rsource "arch/Kconfig" +rsource "cpu/kvm/Kconfig" +rsource "systemc/Kconfig" +rsource "gpu-compute/Kconfig" diff --git a/src/arch/Kconfig b/src/arch/Kconfig new file mode 100644 index 0000000000..05d637913e --- /dev/null +++ b/src/arch/Kconfig @@ -0,0 +1,37 @@ +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +config TARGET_GPU_ISA + string + +rsource "amdgpu/Kconfig" + +rsource "arm/Kconfig" +rsource "mips/Kconfig" +rsource "null/Kconfig" +rsource "power/Kconfig" +rsource "riscv/Kconfig" +rsource "sparc/Kconfig" +rsource "x86/Kconfig" diff --git a/src/arch/power/SConsopts b/src/arch/amdgpu/Kconfig similarity index 90% rename from src/arch/power/SConsopts rename to src/arch/amdgpu/Kconfig index 099f37553a..5140f2b103 100644 --- a/src/arch/power/SConsopts +++ b/src/arch/amdgpu/Kconfig @@ -1,4 +1,4 @@ -# Copyright 2021 Google, Inc. +# Copyright 2022 Google LLC # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -23,6 +23,11 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Import('*') -sticky_vars.Add(BoolVariable('USE_POWER_ISA', 'Enable POWER ISA support', - False)) +if BUILD_GPU +choice "TARGET_GPU_ISA" +prompt "GPU ISA" +endchoice +endif + +rsource "gcn3/Kconfig" +rsource "vega/Kconfig" diff --git a/src/arch/amdgpu/gcn3/Kconfig b/src/arch/amdgpu/gcn3/Kconfig new file mode 100644 index 0000000000..2ba21a6521 --- /dev/null +++ b/src/arch/amdgpu/gcn3/Kconfig @@ -0,0 +1,33 @@ +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +config TARGET_GPU_ISA + default "gcn3" if GCN3_GPU_ISA + +cont_choice "TARGET_GPU_ISA" + config GCN3_GPU_ISA + depends on BUILD_GPU + bool "GCN3" +endchoice diff --git a/src/arch/amdgpu/vega/Kconfig b/src/arch/amdgpu/vega/Kconfig new file mode 100644 index 0000000000..81f8be3551 --- /dev/null +++ b/src/arch/amdgpu/vega/Kconfig @@ -0,0 +1,33 @@ +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +config TARGET_GPU_ISA + default 'vega' if VEGA_GPU_ISA + +cont_choice "TARGET_GPU_ISA" + config VEGA_GPU_ISA + depends on BUILD_GPU + bool "VEGA" +endchoice diff --git a/src/arch/x86/SConsopts b/src/arch/arm/Kconfig similarity index 92% rename from src/arch/x86/SConsopts rename to src/arch/arm/Kconfig index 425c92145f..d75a21a267 100644 --- a/src/arch/x86/SConsopts +++ b/src/arch/arm/Kconfig @@ -1,4 +1,4 @@ -# Copyright 2021 Google, Inc. +# Copyright 2022 Google LLC # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -23,5 +23,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Import('*') -sticky_vars.Add(BoolVariable('USE_X86_ISA', 'Enable X86 ISA support', False)) +config USE_ARM_ISA + bool "ARM ISA support" + +rsource "fastmodel/Kconfig" diff --git a/src/arch/arm/SConscript b/src/arch/arm/SConscript index ee5efebf13..0aa4e66659 100644 --- a/src/arch/arm/SConscript +++ b/src/arch/arm/SConscript @@ -40,7 +40,7 @@ Import('*') -if env['USE_ARM_ISA']: +if env['CONF']['USE_ARM_ISA']: env.TagImplies('arm isa', 'gem5 lib') # The GTest function does not have a 'tags' parameter. We therefore apply this @@ -48,7 +48,7 @@ if env['USE_ARM_ISA']: # # Note: This will need reconfigured for multi-isa. E.g., if this is # incorporated: https://gem5-review.googlesource.com/c/public/gem5/+/52491 -if env['USE_ARM_ISA']: +if env['CONF']['USE_ARM_ISA']: GTest('aapcs64.test', 'aapcs64.test.cc', '../../base/debug.cc', '../../cpu/reg_class.cc', diff --git a/src/arch/arm/fastmodel/Kconfig b/src/arch/arm/fastmodel/Kconfig new file mode 100644 index 0000000000..f4eec968f9 --- /dev/null +++ b/src/arch/arm/fastmodel/Kconfig @@ -0,0 +1,60 @@ +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +menu "Fast Model" + + config USE_ARM_FASTMODEL + bool "Fast Model integration" + default n + depends on USE_ARM_ISA + depends on USE_SYSTEMC + + if USE_ARM_FASTMODEL + config PVLIB_HOME + string "Fast Model portfolio directory" + default "$(PVLIB_HOME)" + + config PVLIB_FLAVOR + string "What build flavor of the Fast Model pvlib to use" + default "Linux64_GCC-7.3" + + config MAXCORE_HOME + string "Fast Model tools directory" + default "$(MAXCORE_HOME)" + + config ARMLMD_LICENSE_FILE + string "ARM license file location" + default "$(ARMLMD_LICENSE_FILE)" + + config ARMLMD_LICENSE_COUNT + int "The maximum number of ARM licenses to use concurrently" + default 1 + + config SIMGEN + string "simgen executable (leave unset for MAXCORE_HOME/bin/simgen" + default "" + endif + +endmenu diff --git a/src/arch/arm/fastmodel/SConscript b/src/arch/arm/fastmodel/SConscript index 7c6019e2a8..f8cfd5991c 100644 --- a/src/arch/arm/fastmodel/SConscript +++ b/src/arch/arm/fastmodel/SConscript @@ -302,6 +302,10 @@ for header in common_headers: header_src = examples_common_dir.Dir('include').File(header) Command(header_target, header_src, Copy('${TARGET}', '${SOURCE}')) +if not env['CONF']['SIMGEN']: + env['CONF']['SIMGEN'] = os.path.join( + env['CONF']['MAXCORE_HOME'], 'bin', 'simgen') + class ArmFastModelComponent(object): def __init__(self, project_file, *extra_deps, tags=None): if not tags: diff --git a/src/arch/arm/fastmodel/SConsopts b/src/arch/arm/fastmodel/SConsopts index d3f898004d..e592bdbf55 100644 --- a/src/arch/arm/fastmodel/SConsopts +++ b/src/arch/arm/fastmodel/SConsopts @@ -1,5 +1,4 @@ -# Copyright 2019 Google, Inc. -# All rights reserved. +# Copyright 2019,2022 Google LLC # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -28,20 +27,12 @@ Import('*') import os -default_simgen = os.path.join('${MAXCORE_HOME}', 'bin', 'simgen') +def extract_var(name): + val = os.environ.get(name, None) + if val is not None: + main['CONF'][name] = val -sticky_vars.AddVariables( - BoolVariable('USE_ARM_FASTMODEL', - 'Build support for integrating ARM Fast Models', False), - ('PVLIB_HOME', 'Fast Model portfolio directory', - os.environ.get('PVLIB_HOME', '')), - ('PVLIB_FLAVOR', 'What build flavor of the Fast Model pvlib to use', - 'Linux64_GCC-7.3'), - ('MAXCORE_HOME', 'Fast Model tools directory', - os.environ.get('MAXCORE_HOME', '')), - ('ARMLMD_LICENSE_FILE', 'ARM license file location', - os.environ.get('ARMLMD_LICENSE_FILE', '')), - ('ARMLMD_LICENSE_COUNT', - 'The maximum number of ARM licenses to use concurrently', 1), - ('SIMGEN', 'simgen executable', os.environ.get('SIMGEN', default_simgen)), -) +# Make these environment variables in the host environment available when +# running kconfig tools by putting them in env['CONF']. +for var in 'PVLIB_HOME', 'MAXCORE_HOME', 'ARMLMD_LICENSE_FILE': + extract_var(var) diff --git a/src/arch/arm/SConsopts b/src/arch/mips/Kconfig similarity index 92% rename from src/arch/arm/SConsopts rename to src/arch/mips/Kconfig index f760404957..20d70ded8c 100644 --- a/src/arch/arm/SConsopts +++ b/src/arch/mips/Kconfig @@ -1,4 +1,4 @@ -# Copyright 2021 Google, Inc. +# Copyright 2022 Google LLC # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -23,5 +23,5 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Import('*') -sticky_vars.Add(BoolVariable('USE_ARM_ISA', 'Enable ARM ISA support', False)) +config USE_MIPS_ISA + bool "MIPS ISA support" diff --git a/src/arch/mips/SConscript b/src/arch/mips/SConscript index 3ef9deceee..05573ae74b 100644 --- a/src/arch/mips/SConscript +++ b/src/arch/mips/SConscript @@ -29,7 +29,7 @@ Import('*') -if env['USE_MIPS_ISA']: +if env['CONF']['USE_MIPS_ISA']: env.TagImplies('mips isa', 'gem5 lib') Source('decoder.cc', tags='mips isa') diff --git a/src/arch/null/SConsopts b/src/arch/null/Kconfig similarity index 92% rename from src/arch/null/SConsopts rename to src/arch/null/Kconfig index 2d552a1dc8..64151ecf73 100644 --- a/src/arch/null/SConsopts +++ b/src/arch/null/Kconfig @@ -1,4 +1,4 @@ -# Copyright 2021 Google, Inc. +# Copyright 2022 Google LLC # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -23,5 +23,5 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Import('*') -sticky_vars.Add(BoolVariable('USE_NULL_ISA', 'Enable NULL ISA support', False)) +config USE_NULL_ISA + bool "Null ISA support" diff --git a/src/arch/mips/SConsopts b/src/arch/power/Kconfig similarity index 92% rename from src/arch/mips/SConsopts rename to src/arch/power/Kconfig index 6c5061fd5d..f585a1e023 100644 --- a/src/arch/mips/SConsopts +++ b/src/arch/power/Kconfig @@ -1,4 +1,4 @@ -# Copyright 2021 Google, Inc. +# Copyright 2022 Google LLC # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -23,5 +23,5 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Import('*') -sticky_vars.Add(BoolVariable('USE_MIPS_ISA', 'Enable MIPS ISA support', False)) +config USE_POWER_ISA + bool "POWER ISA support" diff --git a/src/arch/power/SConscript b/src/arch/power/SConscript index 8ddb96694a..ede15cfd22 100644 --- a/src/arch/power/SConscript +++ b/src/arch/power/SConscript @@ -30,7 +30,7 @@ Import('*') -if env['USE_POWER_ISA']: +if env['CONF']['USE_POWER_ISA']: env.TagImplies('power isa', 'gem5 lib') Source('decoder.cc', tags='power isa') diff --git a/src/arch/riscv/Kconfig b/src/arch/riscv/Kconfig new file mode 100644 index 0000000000..7f09731e5e --- /dev/null +++ b/src/arch/riscv/Kconfig @@ -0,0 +1,27 @@ +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +config USE_RISCV_ISA + bool "RISC-V ISA support" diff --git a/src/arch/riscv/SConscript b/src/arch/riscv/SConscript index bf40b6eccd..d3dd1d5970 100644 --- a/src/arch/riscv/SConscript +++ b/src/arch/riscv/SConscript @@ -43,7 +43,7 @@ Import('*') -if env['USE_RISCV_ISA']: +if env['CONF']['USE_RISCV_ISA']: env.TagImplies('riscv isa', 'gem5 lib') Source('decoder.cc', tags='riscv isa') diff --git a/src/arch/riscv/SConsopts b/src/arch/riscv/SConsopts deleted file mode 100644 index 751311de5c..0000000000 --- a/src/arch/riscv/SConsopts +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2021 Google, Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer; -# redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution; -# neither the name of the copyright holders nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -Import('*') -sticky_vars.Add(BoolVariable('USE_RISCV_ISA', 'Enable RISC-V ISA support', - False)) diff --git a/src/arch/sparc/Kconfig b/src/arch/sparc/Kconfig new file mode 100644 index 0000000000..ec2aef7326 --- /dev/null +++ b/src/arch/sparc/Kconfig @@ -0,0 +1,27 @@ +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +config USE_SPARC_ISA + bool "SPARC ISA support" diff --git a/src/arch/sparc/SConscript b/src/arch/sparc/SConscript index a721c4ae56..9291c8a741 100644 --- a/src/arch/sparc/SConscript +++ b/src/arch/sparc/SConscript @@ -28,7 +28,7 @@ Import('*') -if env['USE_SPARC_ISA']: +if env['CONF']['USE_SPARC_ISA']: env.TagImplies('sparc isa', 'gem5 lib') Source('asi.cc', tags='sparc isa') diff --git a/src/arch/sparc/SConsopts b/src/arch/sparc/SConsopts deleted file mode 100644 index 917485af9c..0000000000 --- a/src/arch/sparc/SConsopts +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2021 Google, Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer; -# redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution; -# neither the name of the copyright holders nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -Import('*') -sticky_vars.Add(BoolVariable('USE_SPARC_ISA', 'Enable SPARC ISA support', - False)) diff --git a/src/arch/x86/Kconfig b/src/arch/x86/Kconfig new file mode 100644 index 0000000000..ba10fad55b --- /dev/null +++ b/src/arch/x86/Kconfig @@ -0,0 +1,27 @@ +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +config USE_X86_ISA + bool "X86 ISA support" diff --git a/src/arch/x86/SConscript b/src/arch/x86/SConscript index 97c34f51c3..cbf5356761 100644 --- a/src/arch/x86/SConscript +++ b/src/arch/x86/SConscript @@ -40,7 +40,7 @@ Import('*') -if env['USE_X86_ISA']: +if env['CONF']['USE_X86_ISA']: env.TagImplies('x86 isa', 'gem5 lib') Source('cpuid.cc', tags='x86 isa') diff --git a/src/arch/SConsopts b/src/base/Kconfig similarity index 78% rename from src/arch/SConsopts rename to src/base/Kconfig index f05bdef14b..19d58c865a 100644 --- a/src/arch/SConsopts +++ b/src/base/Kconfig @@ -1,4 +1,4 @@ -# Copyright 2020 Google, Inc. +# Copyright 2022 Google LLC # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -23,11 +23,23 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Import('*') +config HAVE_FENV + def_bool $(HAVE_FENV) -def add_isa_lists(): - sticky_vars.AddVariables( - EnumVariable('TARGET_GPU_ISA', 'Target GPU ISA', 'gcn3', - sorted(set(main.Split('${ALL_GPU_ISAS}')))), - ) -AfterSConsopts(add_isa_lists) +config HAVE_PNG + def_bool $(HAVE_PNG) + +config HAVE_VALGRIND + def_bool $(HAVE_VALGRIND) + +config HAVE_DEPRECATED_NAMESPACE + def_bool $(HAVE_DEPRECATED_NAMESPACE) + +config HAVE_POSIX_CLOCK + def_bool $(HAVE_POSIX_CLOCK) + +config USE_POSIX_CLOCK + depends on HAVE_POSIX_CLOCK + bool "Use POSIX clocks" + +rsource "stats/Kconfig" diff --git a/src/base/SConsopts b/src/base/SConsopts index 68e40587b9..6c438768b2 100644 --- a/src/base/SConsopts +++ b/src/base/SConsopts @@ -81,6 +81,3 @@ with gem5_scons.Configure(werror_env) as conf: warning("Deprecated namespaces are not supported by this compiler.\n" "Please make sure to check the mailing list for deprecation " "announcements.") - -sticky_vars.Add(BoolVariable('USE_POSIX_CLOCK', 'Use POSIX Clocks', - '${CONF["HAVE_POSIX_CLOCK"]}')) diff --git a/src/base/stats/Kconfig b/src/base/stats/Kconfig new file mode 100644 index 0000000000..2b7bb9610d --- /dev/null +++ b/src/base/stats/Kconfig @@ -0,0 +1,27 @@ +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +config HAVE_HDF5 + def_bool $(HAVE_HDF5) diff --git a/src/cpu/kvm/Kconfig b/src/cpu/kvm/Kconfig new file mode 100644 index 0000000000..824a2e3c41 --- /dev/null +++ b/src/cpu/kvm/Kconfig @@ -0,0 +1,34 @@ +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +config KVM_ISA + string + default "$(KVM_ISA)" + +config USE_KVM + depends on KVM_ISA != "" + bool "Enable hardware virtualized (KVM) CPU models" + default y if KVM_ISA != "" + default n diff --git a/src/cpu/kvm/SConsopts b/src/cpu/kvm/SConsopts index 275eedaa54..1363d60951 100644 --- a/src/cpu/kvm/SConsopts +++ b/src/cpu/kvm/SConsopts @@ -61,13 +61,5 @@ with gem5_scons.Configure(main) as conf: warning("perf_event headers lack support for the exclude_host " "attribute. KVM instruction counts will be inaccurate.") - -def create_use_kvm_var(): - if main['CONF']['HAVE_KVM'] and main['CONF']['KVM_ISA']: - sticky_vars.Add(BoolVariable('USE_KVM', - 'Enable hardware virtualized (KVM) CPU models', True)) - else: - main['CONF']['USE_KVM'] = False - warning("Cannot enable KVM, host seems to lack KVM support") - -AfterSConsopts(create_use_kvm_var) +if not main['CONF']['KVM_ISA']: + warning("Can not enable KVM, host seems to lack KVM support") diff --git a/src/cpu/testers/directedtest/SConscript b/src/cpu/testers/directedtest/SConscript index 6787648608..e4e9f10c2b 100644 --- a/src/cpu/testers/directedtest/SConscript +++ b/src/cpu/testers/directedtest/SConscript @@ -35,7 +35,7 @@ Import('*') # When this dependency is removed, the ruby tester should be compiled # independently from Ruby # -if env['CONF']['PROTOCOL'] == 'None': +if not env['CONF']['RUBY']: Return() SimObject('RubyDirectedTester.py', sim_objects=[ diff --git a/src/cpu/testers/garnet_synthetic_traffic/SConscript b/src/cpu/testers/garnet_synthetic_traffic/SConscript index 14f4abdc67..e2eb4cffd6 100644 --- a/src/cpu/testers/garnet_synthetic_traffic/SConscript +++ b/src/cpu/testers/garnet_synthetic_traffic/SConscript @@ -28,7 +28,7 @@ Import('*') -if env['CONF']['PROTOCOL'] == 'None': +if not env['CONF']['RUBY']: Return() SimObject('GarnetSyntheticTraffic.py', sim_objects=['GarnetSyntheticTraffic']) diff --git a/src/cpu/testers/gpu_ruby_test/SConscript b/src/cpu/testers/gpu_ruby_test/SConscript index 0231649043..b56be9448f 100644 --- a/src/cpu/testers/gpu_ruby_test/SConscript +++ b/src/cpu/testers/gpu_ruby_test/SConscript @@ -34,7 +34,7 @@ Import('*') if not env['CONF']['BUILD_GPU']: Return() -if env['CONF']['PROTOCOL'] == 'None': +if not env['CONF']['RUBY']: Return() SimObject('ProtocolTester.py', sim_objects=['ProtocolTester']) diff --git a/src/cpu/testers/rubytest/SConscript b/src/cpu/testers/rubytest/SConscript index cc76d2bdfd..a4eac87499 100644 --- a/src/cpu/testers/rubytest/SConscript +++ b/src/cpu/testers/rubytest/SConscript @@ -35,7 +35,7 @@ Import('*') # When this dependency is removed, the ruby tester should be compiled # independently from Ruby # -if env['CONF']['PROTOCOL'] == 'None': +if not env['CONF']['RUBY']: Return() SimObject('RubyTester.py', sim_objects=['RubyTester']) diff --git a/src/dev/net/Kconfig b/src/dev/net/Kconfig new file mode 100644 index 0000000000..0e2c3eb551 --- /dev/null +++ b/src/dev/net/Kconfig @@ -0,0 +1,27 @@ +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +config HAVE_TUNTAP + def_bool $(HAVE_TUNTAP) diff --git a/src/gpu-compute/Kconfig b/src/gpu-compute/Kconfig new file mode 100644 index 0000000000..574f670833 --- /dev/null +++ b/src/gpu-compute/Kconfig @@ -0,0 +1,28 @@ +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +menuconfig BUILD_GPU + bool "Build the compute-GPU model" + default n diff --git a/src/gpu-compute/SConsopts b/src/learning_gem5/part3/Kconfig similarity index 89% rename from src/gpu-compute/SConsopts rename to src/learning_gem5/part3/Kconfig index 251ac5d8cf..9d06122d2e 100644 --- a/src/gpu-compute/SConsopts +++ b/src/learning_gem5/part3/Kconfig @@ -1,4 +1,4 @@ -# Copyright 2020 Google, Inc. +# Copyright 2022 Google LLC # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -23,7 +23,10 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Import('*') +config PROTOCOL + default "MSI" if RUBY_PROTOCOL_MSI -sticky_vars.Add(BoolVariable('BUILD_GPU', 'Build the compute-GPU model', - False)) +cont_choice "Ruby protocol" + config RUBY_PROTOCOL_MSI + bool "MSI" +endchoice diff --git a/src/learning_gem5/part3/SConsopts b/src/learning_gem5/part3/SConsopts index dabfd1e146..39968d7fdc 100644 --- a/src/learning_gem5/part3/SConsopts +++ b/src/learning_gem5/part3/SConsopts @@ -2,8 +2,5 @@ Import('*') # NOTE: All SLICC setup code found in src/mem/ruby/protocol/SConscript -# Register this protocol with gem5/SCons -main.Append(ALL_PROTOCOLS=['MSI']) - # Add this directory to the search path for SLICC main.Append(PROTOCOL_DIRS=[Dir('.')]) diff --git a/src/mem/ruby/Kconfig b/src/mem/ruby/Kconfig new file mode 100644 index 0000000000..362174d5b7 --- /dev/null +++ b/src/mem/ruby/Kconfig @@ -0,0 +1,50 @@ +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +menu "Ruby" + menuconfig RUBY + bool "Enable" + + if RUBY + config PROTOCOL + string + + config NEED_PARTIAL_FUNC_READS + bool + + choice "Ruby protocol" + prompt "Ruby protocol" + endchoice + + config SLICC_HTML + bool 'Create HTML files' + + config NUMBER_BITS_PER_SET + int 'Max elements in set' + default 64 + endif +endmenu + +rsource "protocol/Kconfig" diff --git a/src/mem/ruby/SConscript b/src/mem/ruby/SConscript index 1e386f922d..2eb46b0f4d 100644 --- a/src/mem/ruby/SConscript +++ b/src/mem/ruby/SConscript @@ -49,7 +49,7 @@ from gem5_scons import Transform Import('*') -if env['CONF']['PROTOCOL'] == 'None': +if not env['CONF']['RUBY']: Return() DebugFlag('ProtocolTrace') @@ -112,7 +112,7 @@ MakeInclude('structures/PerfectCacheMemory.hh') MakeInclude('structures/PersistentTable.hh') MakeInclude('structures/RubyPrefetcher.hh') MakeInclude('structures/TBEStorage.hh') -if env['PROTOCOL'] == 'CHI': +if env['CONF']['PROTOCOL'] == 'CHI': MakeInclude('structures/MN_TBEStorage.hh') MakeInclude('structures/MN_TBETable.hh') MakeInclude('structures/TBETable.hh') diff --git a/src/mem/ruby/SConsopts b/src/mem/ruby/SConsopts index f26b6d05f8..7c4a1a9ea9 100644 --- a/src/mem/ruby/SConsopts +++ b/src/mem/ruby/SConsopts @@ -25,12 +25,4 @@ Import('*') -main.SetDefault(ALL_PROTOCOLS=[], PROTOCOL_DIRS=[], SLICC_INCLUDES=[]) - -def add_protocols_var(): - sticky_vars.Add(EnumVariable('PROTOCOL', 'Coherence protocol for Ruby', - 'None', main['ALL_PROTOCOLS'])) -AfterSConsopts(add_protocols_var) - -sticky_vars.Add(('NUMBER_BITS_PER_SET', 'Max elements in set (default 64)', - 64)) +main.SetDefault(PROTOCOL_DIRS=[], SLICC_INCLUDES=[]) diff --git a/src/mem/ruby/common/SConscript b/src/mem/ruby/common/SConscript index 9f683cbaf1..9c1fc795a6 100644 --- a/src/mem/ruby/common/SConscript +++ b/src/mem/ruby/common/SConscript @@ -28,7 +28,7 @@ Import('*') -if env['CONF']['PROTOCOL'] == 'None': +if not env['CONF']['RUBY']: Return() env.Append(CPPDEFINES={'NUMBER_BITS_PER_SET': diff --git a/src/mem/ruby/network/SConscript b/src/mem/ruby/network/SConscript index b5a4e7950f..e9a79746d7 100644 --- a/src/mem/ruby/network/SConscript +++ b/src/mem/ruby/network/SConscript @@ -28,7 +28,7 @@ Import('*') -if env['CONF']['PROTOCOL'] == 'None': +if not env['CONF']['RUBY']: Return() SimObject('BasicLink.py', sim_objects=[ diff --git a/src/mem/ruby/network/fault_model/SConscript b/src/mem/ruby/network/fault_model/SConscript index bd55947795..e6ff61aed8 100644 --- a/src/mem/ruby/network/fault_model/SConscript +++ b/src/mem/ruby/network/fault_model/SConscript @@ -33,7 +33,7 @@ Import('*') -if env['CONF']['PROTOCOL'] == 'None': +if not env['CONF']['RUBY']: Return() SimObject('FaultModel.py', sim_objects=['FaultModel']) diff --git a/src/mem/ruby/network/garnet/SConscript b/src/mem/ruby/network/garnet/SConscript index 9e6e19e9b6..b0dcfe690c 100644 --- a/src/mem/ruby/network/garnet/SConscript +++ b/src/mem/ruby/network/garnet/SConscript @@ -28,7 +28,7 @@ Import('*') -if env['CONF']['PROTOCOL'] == 'None': +if not env['CONF']['RUBY']: Return() SimObject('GarnetLink.py', enums=['CDCType'], sim_objects=[ diff --git a/src/mem/ruby/network/simple/SConscript b/src/mem/ruby/network/simple/SConscript index 97055f5080..011552afae 100644 --- a/src/mem/ruby/network/simple/SConscript +++ b/src/mem/ruby/network/simple/SConscript @@ -40,7 +40,7 @@ Import('*') -if env['CONF']['PROTOCOL'] == 'None': +if not env['CONF']['RUBY']: Return() SimObject('SimpleLink.py', sim_objects=['SimpleExtLink', 'SimpleIntLink']) diff --git a/src/mem/ruby/profiler/SConscript b/src/mem/ruby/profiler/SConscript index 0c493e9be3..ff9cc099f2 100644 --- a/src/mem/ruby/profiler/SConscript +++ b/src/mem/ruby/profiler/SConscript @@ -28,7 +28,7 @@ Import('*') -if env['CONF']['PROTOCOL'] == 'None': +if not env['CONF']['RUBY']: Return() Source('AccessTraceForAddress.cc') diff --git a/src/mem/ruby/protocol/Kconfig b/src/mem/ruby/protocol/Kconfig new file mode 100644 index 0000000000..bed47a1108 --- /dev/null +++ b/src/mem/ruby/protocol/Kconfig @@ -0,0 +1,62 @@ +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +config PROTOCOL + default "GPU_VIPER" if RUBY_PROTOCOL_GPU_VIPER + default "MOESI_AMD_Base" if RUBY_PROTOCOL_MOESI_AMD_BASE + default "MESI_Two_Level" if RUBY_PROTOCOL_MESI_TWO_LEVEL + default "MESI_Three_Level" if RUBY_PROTOCOL_MESI_THREE_LEVEL + default "MESI_Three_Level_HTM" if RUBY_PROTOCOL_MESI_THREE_LEVEL_HTM + default "MI_example" if RUBY_PROTOCOL_MI_EXAMPLE + default "MOESI_CMP_directory" if RUBY_PROTOCOL_MOESI_CMP_DIRECTORY + default "MOESI_CMP_token" if RUBY_PROTOCOL_MOESI_CMP_TOKEN + default "MOESI_hammer" if RUBY_PROTOCOL_MOESI_HAMMER + default "Garnet_standalone" if RUBY_PROTOCOL_GARNET_STANDALONE + +cont_choice "Ruby protocol" + config RUBY_PROTOCOL_GPU_VIPER + bool "GPU VIPER" + depends on BUILD_GPU + config RUBY_PROTOCOL_MOESI_AMD_BASE + bool "MOESI AMD base" + config RUBY_PROTOCOL_MESI_TWO_LEVEL + bool "MESI two level" + config RUBY_PROTOCOL_MESI_THREE_LEVEL + bool "MESI three level" + config RUBY_PROTOCOL_MESI_THREE_LEVEL_HTM + bool "MESI three level HTM" + config RUBY_PROTOCOL_MI_EXAMPLE + bool "MI example" + config RUBY_PROTOCOL_MOESI_CMP_DIRECTORY + bool "MOESI CMP directory" + config RUBY_PROTOCOL_MOESI_CMP_TOKEN + bool "MOESI CMP token" + config RUBY_PROTOCOL_MOESI_HAMMER + bool "MOESI hammer" + config RUBY_PROTOCOL_GARNET_STANDALONE + bool "Garnet standalone" +endchoice + +rsource "chi/Kconfig" diff --git a/src/mem/ruby/protocol/SConscript b/src/mem/ruby/protocol/SConscript index 07545c3ae0..7369c0c193 100644 --- a/src/mem/ruby/protocol/SConscript +++ b/src/mem/ruby/protocol/SConscript @@ -36,7 +36,7 @@ from gem5_scons import Transform Import('*') -if env['CONF']['PROTOCOL'] == 'None': +if not env['CONF']['RUBY']: Return() output_dir = Dir('.') diff --git a/src/mem/ruby/protocol/SConsopts b/src/mem/ruby/protocol/SConsopts index 2fcc57a5f5..bcbc83ba9b 100644 --- a/src/mem/ruby/protocol/SConsopts +++ b/src/mem/ruby/protocol/SConsopts @@ -30,23 +30,6 @@ import os Import('*') -main.Append(ALL_PROTOCOLS=[ - 'GPU_VIPER', - 'MOESI_AMD_Base', - 'MESI_Two_Level', - 'MESI_Three_Level', - 'MESI_Three_Level_HTM', - 'MI_example', - 'MOESI_CMP_directory', - 'MOESI_CMP_token', - 'MOESI_hammer', - 'Garnet_standalone', - 'None' - ]) - -opt = BoolVariable('SLICC_HTML', 'Create HTML files', False) -sticky_vars.Add(opt) - main.Append(PROTOCOL_DIRS=[Dir('.')]) protocol_base = Dir('.') diff --git a/src/mem/ruby/protocol/chi/Kconfig b/src/mem/ruby/protocol/chi/Kconfig new file mode 100644 index 0000000000..708f162fd7 --- /dev/null +++ b/src/mem/ruby/protocol/chi/Kconfig @@ -0,0 +1,35 @@ +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +config PROTOCOL + default "CHI" if RUBY_PROTOCOL_CHI + +config NEED_PARTIAL_FUNC_READS + default y if RUBY_PROTOCOL_CHI + +cont_choice "Ruby protocol" + config RUBY_PROTOCOL_CHI + bool "CHI" +endchoice diff --git a/src/mem/ruby/protocol/chi/SConsopts b/src/mem/ruby/protocol/chi/SConsopts index 6f686878ef..8551d7325f 100644 --- a/src/mem/ruby/protocol/chi/SConsopts +++ b/src/mem/ruby/protocol/chi/SConsopts @@ -37,11 +37,4 @@ Import('*') -# Register this protocol with gem5/SCons - -main.Append(ALL_PROTOCOLS=['CHI']) - -# CHI requires Ruby's inerface to support partial functional reads -main.Append(NEED_PARTIAL_FUNC_READS=['CHI']) - main.Append(PROTOCOL_DIRS=[Dir('.')]) diff --git a/src/mem/ruby/slicc_interface/SConscript b/src/mem/ruby/slicc_interface/SConscript index 47dd49d42e..7fb84b348c 100644 --- a/src/mem/ruby/slicc_interface/SConscript +++ b/src/mem/ruby/slicc_interface/SConscript @@ -28,7 +28,7 @@ Import('*') -if env['CONF']['PROTOCOL'] == 'None': +if not env['CONF']['RUBY']: Return() SimObject('Controller.py', sim_objects=['RubyController']) diff --git a/src/mem/ruby/structures/SConscript b/src/mem/ruby/structures/SConscript index 7baab6a4c4..242a72e919 100644 --- a/src/mem/ruby/structures/SConscript +++ b/src/mem/ruby/structures/SConscript @@ -40,7 +40,7 @@ Import('*') -if env['CONF']['PROTOCOL'] == 'None': +if not env['CONF']['RUBY']: Return() SimObject('RubyCache.py', sim_objects=['RubyCache']) @@ -57,5 +57,5 @@ Source('TimerTable.cc') Source('BankedArray.cc') Source('ALUFreeListArray.cc') Source('TBEStorage.cc') -if env['PROTOCOL'] == 'CHI': +if env['CONF']['PROTOCOL'] == 'CHI': Source('MN_TBETable.cc') diff --git a/src/mem/ruby/system/SConscript b/src/mem/ruby/system/SConscript index c0b85bb350..77bce7f851 100644 --- a/src/mem/ruby/system/SConscript +++ b/src/mem/ruby/system/SConscript @@ -40,12 +40,12 @@ Import('*') -if env['CONF']['PROTOCOL'] == 'None': +if not env['CONF']['RUBY']: Return() env.Append(CPPDEFINES=['PROTOCOL_' + env['CONF']['PROTOCOL']]) -if env['CONF']['PROTOCOL'] in env['NEED_PARTIAL_FUNC_READS']: +if env['CONF']['NEED_PARTIAL_FUNC_READS']: env.Append(CPPDEFINES=['PARTIAL_FUNC_READS']) if env['CONF']['BUILD_GPU']: diff --git a/src/proto/Kconfig b/src/proto/Kconfig new file mode 100644 index 0000000000..a497d6e2de --- /dev/null +++ b/src/proto/Kconfig @@ -0,0 +1,27 @@ +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +config HAVE_PROTOBUF + def_bool $(HAVE_PROTOBUF) diff --git a/src/systemc/Kconfig b/src/systemc/Kconfig new file mode 100644 index 0000000000..3f3df93f53 --- /dev/null +++ b/src/systemc/Kconfig @@ -0,0 +1,28 @@ +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +config USE_SYSTEMC + bool "Enable SystemC API support" + default $(USE_SYSTEMC) diff --git a/src/systemc/SConsopts b/src/systemc/SConsopts index e8702882e5..20436ec81b 100644 --- a/src/systemc/SConsopts +++ b/src/systemc/SConsopts @@ -45,6 +45,3 @@ def use_systemc_check(env, warn=False): main.AddMethod(use_systemc_check, 'UseSystemcCheck') main['CONF']['USE_SYSTEMC'] = main.UseSystemcCheck() - -sticky_vars.Add(BoolVariable('USE_SYSTEMC', 'Enable SystemC API support', - main.UseSystemcCheck())) From 1cdccd7ac016ef51b72f220d148fd4061bffb499 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 17 Feb 2022 00:36:03 -0800 Subject: [PATCH 03/22] scons: Add a build script for generating a root Kconfig file. This root Kconfig file "source"s (includes) the base gem5 src/Kconfig file, and also any optional Kconfig files found in the base of EXTRAS directories. These will be called out in the menuconfig interface and config files with the name of the EXTRAS directory they came from, and a blank section will be present either if the Kconfig didn't exist, or it did exist but had no options in it. Change-Id: I54060d613f0e0ab9372bed37a2fe5849bf5bbcdb --- build_tools/kconfig_base.py | 55 +++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 build_tools/kconfig_base.py diff --git a/build_tools/kconfig_base.py b/build_tools/kconfig_base.py new file mode 100755 index 0000000000..13cdb7377a --- /dev/null +++ b/build_tools/kconfig_base.py @@ -0,0 +1,55 @@ +#! /usr/bin/env python3 +# +# Copyright 2022 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import argparse + +from code_formatter import code_formatter + +parser = argparse.ArgumentParser() +parser.add_argument("output", help="path of generated base Kconfig file") +parser.add_argument("main", help="relative path to the main gem5 Kconfig file") +parser.add_argument("extras_dirs", nargs="*", help="EXTRAS paths") + +args = parser.parse_args() + +code = code_formatter() + +code( + f"""# Automatically generated base Kconfig file, DO NOT EDIT! + +source "{args.main}" +""" +) + +for extras_dir in args.extras_dirs: + code( + f""" +osource "{extras_dir}/Kconfig" +""" + ) + +code.write(args.output) From f4c578f458768b72e628d9267217a78fd603b406 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 24 Mar 2022 16:20:58 -0700 Subject: [PATCH 04/22] scons: Flesh out the help text for "magic" targets. These targets are not necessarily obvious, and tell SCons to do useful things, like build a particular version of the gem5 binary with a particular configuration, or run the unit tests. Add descriptions of these targets to the help so that they are much more discoverable. Change-Id: If84399be1a7155ff5f66f511efe1f1c241089c84 --- SConstruct | 64 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/SConstruct b/SConstruct index 405adbc080..3a26e35843 100755 --- a/SConstruct +++ b/SConstruct @@ -44,15 +44,6 @@ # # SCons top-level build description (SConstruct) file. # -# While in this directory ('gem5'), just type 'scons' to build the default -# configuration (see below), or type 'scons build//' -# to build some other configuration (e.g., 'build/X86/gem5.opt' for -# the optimized X86 version). -# -# You can build gem5 in a different directory as long as there is a -# 'build/' somewhere along the target path. The build system -# expects that all configs under the same build directory are being -# built for the same host system. # # Examples: # @@ -81,7 +72,7 @@ import itertools import os import sys -from os import mkdir, remove, environ +from os import mkdir, remove, environ, listdir from os.path import abspath, dirname, expanduser from os.path import isdir, isfile from os.path import join, split @@ -207,6 +198,59 @@ if not ('CC' in main and 'CXX' in main): # Find default configuration & binary. Default(environ.get('M5_DEFAULT_BINARY', 'build/ARM/gem5.debug')) +buildopts_dir = Dir('#build_opts') +buildopts = list([f for f in os.listdir(buildopts_dir.abspath) if + isfile(os.path.join(buildopts_dir.abspath, f))]) +buildopts.sort() + +buildopt_list = '\n'.join(' ' * 10 + buildopt for buildopt in buildopts) + +Help(f""" +Targets: + To build gem5 using a predefined configuration, use a target with + a directory called "build" in the path, followed by a directory named + after a predefined configuration, and then the actual target, likely + a gem5 binary. For example: + + scons build/X86/gem5.opt + + The "build" component tells SCons that the next part names an initial + configuration, and the part after that is the actual target. + The predefined targets currently available are: + +{buildopt_list} + + The extension on the gem5 binary specifies what type of binary to + build. Options are: + + debug: A debug binary with optimizations turned off and debug info + turned on. + opt: An optimized binary with debugging still turned on. + fast: An optimized binary with debugging, asserts, and tracing + disabled. + + gem5 can also be built as a static or dynamic library. In that case, + the extension is fixed by the operating system, so the binary type + is part of the target file name. For example: + + scons build/ARM/libgem5_opt.so + + To build unit tests, you can use a target like this: + + scons build/RISCV/unittests.debug + + The unittests.debug part of the target is actual a directory which + holds the results for all the unit tests built with the "debug" + settings. When that's used as the target, SCons will build all the + files under that directory, which will run all the tests. + + To build and run an individual test, you can built it's binary + specifically and then run it manually: + + scons build/SPARC/base/bitunion.test.opt + build/SPARC/base/bitunion.test.opt +""", append=True) + ######################################################################## # From 1e84d9f941d4b5397fc2322bc180d1ec31e00260 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 17 Feb 2022 00:48:54 -0800 Subject: [PATCH 05/22] scons: Add a mechanism to run menuconfig to set up a build dir. If you call scons with the fist argument set to menuconfig, that means to run menuconfig on the path following it. Or in other words, if you ran this command: scons menuconfig build/foo/bar That would tell SCons to set up a build directory at the path build/foo/bar, and then invoke menuconfig so you can set up its configuration. In addition to using this mechanism to set up a new build directory, you can also use it to reconfigure an existing directory. This supplements and does not replace the existing mechanism of using "build/${VARIANT}" to select a config with defconfig. Change-Id: Ief8e8c2ee6477799455c2004bef06c64be5cc1db --- SConstruct | 70 +++++++++++++++++++++++++------- site_scons/gem5_scons/kconfig.py | 13 ++++++ 2 files changed, 69 insertions(+), 14 deletions(-) diff --git a/SConstruct b/SConstruct index 3a26e35843..fa51d794a5 100755 --- a/SConstruct +++ b/SConstruct @@ -259,27 +259,60 @@ Targets: # ######################################################################## +kconfig_actions = ('menuconfig',) + +Help(""" +Kconfig: + In addition to the default configs, you can also create your own + configs, or edit one that already exists. To edit or create a config + for a particular directory, give SCons a target which is the directory + to configure, and then "menuconfig". For example: + + scons menuconfig build/foo/bar + + will set up a build directory in build/foo/bar if one doesn't already + exist, and open the menuconfig editor to view/set configuration + values. +""", append=True) + # Take a list of paths (or SCons Nodes) and return a list with all # paths made absolute and ~-expanded. Paths will be interpreted # relative to the launch directory unless a different root is provided + +def makePathAbsolute(path, root=GetLaunchDir()): + return abspath(os.path.join(root, expanduser(str(path)))) def makePathListAbsolute(path_list, root=GetLaunchDir()): - return [abspath(os.path.join(root, expanduser(str(p)))) - for p in path_list] + return [makePathAbsolute(p, root) for p in path_list] -# Each target must have 'build' in the interior of the path; the -# directory below this will determine the build parameters. For -# example, for target 'foo/bar/build/X86/arch/x86/blah.do' we -# recognize that X86 specifies the configuration because it -# follow 'build' in the build path. +if BUILD_TARGETS and BUILD_TARGETS[0] in kconfig_actions: + # The build targets are really arguments for the kconfig action. + kconfig_args = BUILD_TARGETS[:] + BUILD_TARGETS[:] = [] -# The funky assignment to "[:]" is needed to replace the list contents -# in place rather than reassign the symbol to a new list, which -# doesn't work (obviously!). -BUILD_TARGETS[:] = makePathListAbsolute(BUILD_TARGETS) + kconfig_action = kconfig_args[0] + if len(kconfig_args) < 2: + error(f'Missing arguments for kconfig action {kconfig_action}') + dir_to_configure = makePathAbsolute(kconfig_args[1]) -# Generate a list of the unique build directories that the collected targets -# reference. -variant_paths = set(map(parse_build_path, BUILD_TARGETS)) + kconfig_args = kconfig_args[2:] + + variant_paths = {dir_to_configure} +else: + # Each target must have 'build' in the interior of the path; the + # directory below this will determine the build parameters. For + # example, for target 'foo/bar/build/X86/arch/x86/blah.do' we + # recognize that X86 specifies the configuration because it + # follow 'build' in the build path. + + # The funky assignment to "[:]" is needed to replace the list contents + # in place rather than reassign the symbol to a new list, which + # doesn't work (obviously!). + BUILD_TARGETS[:] = makePathListAbsolute(BUILD_TARGETS) + + # Generate a list of the unique build directories that the collected + # targets reference. + variant_paths = set(map(parse_build_path, BUILD_TARGETS)) + kconfig_action = None ######################################################################## @@ -758,6 +791,15 @@ for variant_path in variant_paths: for cb in after_sconsopts_callbacks: cb() + # Handle any requested kconfig action, then exit. + if kconfig_action: + if kconfig_action == 'menuconfig': + kconfig.menuconfig(env, kconfig_file.abspath, config_file.abspath, + variant_path) + else: + error(f'Unrecognized kconfig action {kconfig_action}') + Exit(0) + # If no config exists yet, see if we know how to make one? if not isfile(config_file.abspath): buildopts_file = Dir('#build_opts').File(variant_dir) diff --git a/site_scons/gem5_scons/kconfig.py b/site_scons/gem5_scons/kconfig.py index 6c2ec81fa3..d609e24875 100644 --- a/site_scons/gem5_scons/kconfig.py +++ b/site_scons/gem5_scons/kconfig.py @@ -73,6 +73,19 @@ def defconfig(env, base_kconfig, config_in, config_out): error("Failed to run defconfig") +def menuconfig( + env, base_kconfig, config_path, main_menu_text, style="aquatic" +): + """ + Interface of handling menuconfig.py of Kconfiglib + """ + kconfig_env = _prep_env(env, base_kconfig, config_path) + kconfig_env["ENV"]["MENUCONFIG_STYLE"] = style + kconfig_env["ENV"]["MAIN_MENU_TEXT"] = main_menu_text + if kconfig_env.Execute('"${MENUCONFIG_PY}" "${BASE_KCONFIG}"') != 0: + error("Failed to run menuconfig") + + def update_env(env, base_kconfig, config_path): """ Update the Scons' env["CONF"] options from kconfig env From 1ae2dfcc56e42e83af20494c9635c33499454058 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 18 Feb 2022 00:11:07 -0800 Subject: [PATCH 06/22] scons: Add a mechanism to manually defconfig a build dir. This will let you specify *any* defconfig file, instead of implicitly selecting one from the defconfig directory based on the variant name. Change-Id: I74c981b206849f08e60c2df702c06534c670cc7c --- SConstruct | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index fa51d794a5..e27a97eb40 100755 --- a/SConstruct +++ b/SConstruct @@ -259,20 +259,44 @@ Targets: # ######################################################################## -kconfig_actions = ('menuconfig',) +kconfig_actions = ( + 'menuconfig', + 'defconfig', +) Help(""" Kconfig: In addition to the default configs, you can also create your own - configs, or edit one that already exists. To edit or create a config - for a particular directory, give SCons a target which is the directory - to configure, and then "menuconfig". For example: + configs, or edit one that already exists. To use one of the kconfig + tools with a particular directory, use a target which is the directory + to configure, and then the name of the tool. For example, to run + menuconfig on directory build/foo/bar, run: scons menuconfig build/foo/bar will set up a build directory in build/foo/bar if one doesn't already exist, and open the menuconfig editor to view/set configuration values. + + The tools available for working with kconfig are generally very + similar to ones used with the linux kernel, so information about the + kernel versions will typically (but not always) apply here as well. + +Kconfig tools: + menuconfig: + Opens the menuconfig editor which will let you view and edit config + values, and view help text. menuconfig runs in text mode. + + scons menuconfig build/foo/bar + + + defconfig: + Set up a config using values specified in a defconfig file, or if no + value is given, use the default. The second argument specifies the + defconfig file. A defconfig file in the defconfig directory can be + implicitly specified in the build path via `build//` + + scons defconfig build/foo/bar build_opts/MIPS """, append=True) # Take a list of paths (or SCons Nodes) and return a list with all @@ -796,6 +820,12 @@ for variant_path in variant_paths: if kconfig_action == 'menuconfig': kconfig.menuconfig(env, kconfig_file.abspath, config_file.abspath, variant_path) + elif kconfig_action == 'defconfig': + if len(kconfig_args) != 1: + error('Usage: scons defconfig ') + defconfig_path = makePathAbsolute(kconfig_args[0]) + kconfig.defconfig(env, kconfig_file.abspath, + defconfig_path, config_file.abspath) else: error(f'Unrecognized kconfig action {kconfig_action}') Exit(0) From 083bca1e239c3d4b5b1d690dfcf13227eaea2a0a Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 18 Feb 2022 00:39:44 -0800 Subject: [PATCH 07/22] scons: Hook in the kconfig setconfig utility. This little utility lets you set particular values in an existing config without having to open up the whole menuconfig interface. Also reorganize things in kconfig.py a little to help share code between wrappers. Change-Id: I7cba0c0ef8d318d6c39e49c779ebb2bbdc3d94c8 --- SConstruct | 33 +++++++++++------ site_scons/gem5_scons/kconfig.py | 62 +++++++++++++++++++++++++------- 2 files changed, 72 insertions(+), 23 deletions(-) diff --git a/SConstruct b/SConstruct index e27a97eb40..5ae1080cff 100755 --- a/SConstruct +++ b/SConstruct @@ -260,8 +260,9 @@ Targets: ######################################################################## kconfig_actions = ( - 'menuconfig', 'defconfig', + 'menuconfig', + 'setconfig', ) Help(""" @@ -283,6 +284,15 @@ Kconfig: kernel versions will typically (but not always) apply here as well. Kconfig tools: + defconfig: + Set up a config using values specified in a defconfig file, or if no + value is given, use the default. The second argument specifies the + defconfig file. A defconfig file in the build_opts directory can be + implicitly specified in the build path via `build//` + + scons defconfig build/foo/bar build_opts/MIPS + + menuconfig: Opens the menuconfig editor which will let you view and edit config values, and view help text. menuconfig runs in text mode. @@ -290,13 +300,11 @@ Kconfig tools: scons menuconfig build/foo/bar - defconfig: - Set up a config using values specified in a defconfig file, or if no - value is given, use the default. The second argument specifies the - defconfig file. A defconfig file in the defconfig directory can be - implicitly specified in the build path via `build//` + setconfig: + Set values in an existing config directory as specified on the command + line. For example, to enable gem5's built in systemc kernel: - scons defconfig build/foo/bar build_opts/MIPS + scons setconfig build/foo/bar USE_SYSTEMC=y """, append=True) # Take a list of paths (or SCons Nodes) and return a list with all @@ -817,15 +825,18 @@ for variant_path in variant_paths: # Handle any requested kconfig action, then exit. if kconfig_action: - if kconfig_action == 'menuconfig': - kconfig.menuconfig(env, kconfig_file.abspath, config_file.abspath, - variant_path) - elif kconfig_action == 'defconfig': + if kconfig_action == 'defconfig': if len(kconfig_args) != 1: error('Usage: scons defconfig ') defconfig_path = makePathAbsolute(kconfig_args[0]) kconfig.defconfig(env, kconfig_file.abspath, defconfig_path, config_file.abspath) + elif kconfig_action == 'menuconfig': + kconfig.menuconfig(env, kconfig_file.abspath, config_file.abspath, + variant_path) + elif kconfig_action == 'setconfig': + kconfig.setconfig(env, kconfig_file.abspath, config_file.abspath, + ARGUMENTS) else: error(f'Unrecognized kconfig action {kconfig_action}') Exit(0) diff --git a/site_scons/gem5_scons/kconfig.py b/site_scons/gem5_scons/kconfig.py index d609e24875..0251fdd8ea 100644 --- a/site_scons/gem5_scons/kconfig.py +++ b/site_scons/gem5_scons/kconfig.py @@ -28,6 +28,12 @@ import os from . import error import kconfiglib +_kconfig_helpers = { + "DEFCONFIG_PY": "defconfig.py", + "MENUCONFIG_PY": "menuconfig.py", + "SETCONFIG_PY": "setconfig.py", +} + def _prep_env(env, base_kconfig, config_path=None): """ @@ -47,17 +53,31 @@ def _prep_env(env, base_kconfig, config_path=None): if config_path: kconfig_env["ENV"]["KCONFIG_CONFIG"] = config_path + kconfig_env["BASE_KCONFIG"] = base_kconfig + ext = env.Dir("#ext") kconfiglib_dir = ext.Dir("Kconfiglib") - defconfig_py = kconfiglib_dir.File("defconfig.py") - menuconfig_py = kconfiglib_dir.File("menuconfig.py") - - kconfig_env["DEFCONFIG_PY"] = defconfig_py - kconfig_env["MENUCONFIG_PY"] = menuconfig_py - kconfig_env["BASE_KCONFIG"] = base_kconfig + for key, name in _kconfig_helpers.items(): + kconfig_env[key] = kconfiglib_dir.File(name) return kconfig_env +def _process_kconfig(env, base_kconfig): + """ + Create the kconfig instance by given Scons env vars + + :param env: Scons env + :param base_kconfig: path to the Top-level Kconfig file + """ + saved_env = os.environ + try: + os.environ.update({key: str(val) for key, val in env["ENV"].items()}) + kconfig = kconfiglib.Kconfig(filename=base_kconfig) + finally: + os.environ = saved_env + return kconfig + + def defconfig(env, base_kconfig, config_in, config_out): """ Interface of handling defconfig.py of Kconfiglib @@ -86,6 +106,29 @@ def menuconfig( error("Failed to run menuconfig") +def setconfig(env, base_kconfig, config_path, assignments): + """ + Interface of handling setconfig.py of Kconfiglib + """ + kconfig_env = _prep_env(env, base_kconfig, config_path) + + kconfig = _process_kconfig(kconfig_env, base_kconfig) + sym_names = list(sym.name for sym in kconfig.unique_defined_syms) + + filtered = dict( + {key: val for key, val in assignments.items() if key in sym_names} + ) + + setconfig_cmd_parts = ['"${SETCONFIG_PY}" --kconfig "${BASE_KCONFIG}"'] + for key, val in filtered.items(): + if isinstance(val, bool): + val = "y" if val else "n" + setconfig_cmd_parts.append(f"{key}={val}") + setconfig_cmd = " ".join(setconfig_cmd_parts) + if kconfig_env.Execute(setconfig_cmd) != 0: + error("Failed to run setconfig") + + def update_env(env, base_kconfig, config_path): """ Update the Scons' env["CONF"] options from kconfig env @@ -96,12 +139,7 @@ def update_env(env, base_kconfig, config_path): """ kconfig_env = _prep_env(env, base_kconfig, config_path) - saved_env = os.environ - os.environ.update( - {key: str(val) for key, val in kconfig_env["ENV"].items()} - ) - kconfig = kconfiglib.Kconfig(filename=base_kconfig) - os.environ = saved_env + kconfig = _process_kconfig(kconfig_env, base_kconfig) kconfig.load_config(config_path) for sym in kconfig.unique_defined_syms: From 91b3da016bd6c7e09f5cca644359deba585b3a9a Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 18 Feb 2022 00:45:56 -0800 Subject: [PATCH 08/22] scons: Hook in the listnewconfig kconfig helper. This helper lists config options which are new in the Kconfig and which are not currently set in the config file. Change-Id: I0c426d85c0cf0d2bdbac599845669165285a82a0 --- SConstruct | 11 +++++++++++ site_scons/gem5_scons/kconfig.py | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/SConstruct b/SConstruct index 5ae1080cff..99b277caae 100755 --- a/SConstruct +++ b/SConstruct @@ -261,6 +261,7 @@ Targets: kconfig_actions = ( 'defconfig', + 'listnewconfig', 'menuconfig', 'setconfig', ) @@ -293,6 +294,13 @@ Kconfig tools: scons defconfig build/foo/bar build_opts/MIPS + listnewconfig: + Lists config options which are new in the Kconfig and which are not + currently set in the existing config file. + + scons listnewconfig build/foo/bar + + menuconfig: Opens the menuconfig editor which will let you view and edit config values, and view help text. menuconfig runs in text mode. @@ -831,6 +839,9 @@ for variant_path in variant_paths: defconfig_path = makePathAbsolute(kconfig_args[0]) kconfig.defconfig(env, kconfig_file.abspath, defconfig_path, config_file.abspath) + elif kconfig_action == 'listnewconfig': + kconfig.listnewconfig(env, kconfig_file.abspath, + config_file.abspath) elif kconfig_action == 'menuconfig': kconfig.menuconfig(env, kconfig_file.abspath, config_file.abspath, variant_path) diff --git a/site_scons/gem5_scons/kconfig.py b/site_scons/gem5_scons/kconfig.py index 0251fdd8ea..a5fa471b07 100644 --- a/site_scons/gem5_scons/kconfig.py +++ b/site_scons/gem5_scons/kconfig.py @@ -30,6 +30,7 @@ import kconfiglib _kconfig_helpers = { "DEFCONFIG_PY": "defconfig.py", + "LISTNEWCONFIG_PY": "listnewconfig.py", "MENUCONFIG_PY": "menuconfig.py", "SETCONFIG_PY": "setconfig.py", } @@ -93,6 +94,18 @@ def defconfig(env, base_kconfig, config_in, config_out): error("Failed to run defconfig") +def listnewconfig(env, base_kconfig, config_path): + """ + Interface of handling listnewconfig.py of Kconfiglib + """ + kconfig_env = _prep_env(env, base_kconfig, config_path) + # Provide a little visual separation between SCons output and + # listnewconfig output. + print() + if kconfig_env.Execute('"${LISTNEWCONFIG_PY}" "${BASE_KCONFIG}"') != 0: + error("Failed to run listnewconfig") + + def menuconfig( env, base_kconfig, config_path, main_menu_text, style="aquatic" ): From 51b8cfcede57badaa4ee21699ce8c0a923098bb3 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 18 Feb 2022 00:52:43 -0800 Subject: [PATCH 09/22] scons: Hook up the kconfig guiconfig program. Change-Id: I0563a2fb2d79cea5974aeaf65a400be5ee51dc63 --- SConstruct | 11 +++++++++++ site_scons/gem5_scons/kconfig.py | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/SConstruct b/SConstruct index 99b277caae..fa321b2873 100755 --- a/SConstruct +++ b/SConstruct @@ -261,6 +261,7 @@ Targets: kconfig_actions = ( 'defconfig', + 'guiconfig', 'listnewconfig', 'menuconfig', 'setconfig', @@ -294,6 +295,13 @@ Kconfig tools: scons defconfig build/foo/bar build_opts/MIPS + guiconfig: + Opens the guiconfig editor which will let you view and edit config + values, and view help text. guiconfig runs as a graphical application. + + scons guiconfig build/foo/bar + + listnewconfig: Lists config options which are new in the Kconfig and which are not currently set in the existing config file. @@ -839,6 +847,9 @@ for variant_path in variant_paths: defconfig_path = makePathAbsolute(kconfig_args[0]) kconfig.defconfig(env, kconfig_file.abspath, defconfig_path, config_file.abspath) + elif kconfig_action == 'guiconfig': + kconfig.guiconfig(env, kconfig_file.abspath, config_file.abspath, + variant_path) elif kconfig_action == 'listnewconfig': kconfig.listnewconfig(env, kconfig_file.abspath, config_file.abspath) diff --git a/site_scons/gem5_scons/kconfig.py b/site_scons/gem5_scons/kconfig.py index a5fa471b07..5638aa7643 100644 --- a/site_scons/gem5_scons/kconfig.py +++ b/site_scons/gem5_scons/kconfig.py @@ -30,6 +30,7 @@ import kconfiglib _kconfig_helpers = { "DEFCONFIG_PY": "defconfig.py", + "GUICONFIG_PY": "guiconfig.py", "LISTNEWCONFIG_PY": "listnewconfig.py", "MENUCONFIG_PY": "menuconfig.py", "SETCONFIG_PY": "setconfig.py", @@ -94,6 +95,16 @@ def defconfig(env, base_kconfig, config_in, config_out): error("Failed to run defconfig") +def guiconfig(env, base_kconfig, config_path, main_menu_text): + """ + Interface of handling guiconfig.py of Kconfiglib + """ + kconfig_env = _prep_env(env, base_kconfig, config_path) + kconfig_env["ENV"]["MAIN_MENU_TEXT"] = main_menu_text + if kconfig_env.Execute('"${GUICONFIG_PY}" "${BASE_KCONFIG}"') != 0: + error("Failed to run guiconfig") + + def listnewconfig(env, base_kconfig, config_path): """ Interface of handling listnewconfig.py of Kconfiglib From ec76214f680c824997461638d35654a3d540714b Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 18 Feb 2022 00:59:58 -0800 Subject: [PATCH 10/22] scons: Hook up the savedefconfig kconfig helper. This helper utility lets you save the defconfig which would give rise to a given config. For instance, you could use menuconfig to set up a config how you want it with the options you cared about configured, and then use savedefconfig to save a defconfig of that somewhere to the side, in the gem5 defconfig directory, etc. Then later, you could use that defconfig to set up a new build directory with that same config, even if the kconfig options have changed a little bit since then. A saved defconfig like that can also be a good way to visually see what options have been set to something interesting, and an easier way to pass a config to someone else to use, to put in bug reports, etc. Change-Id: Ifd344278638c59b48c261b36058832034c009c78 --- SConstruct | 18 ++++++++++++++++++ site_scons/gem5_scons/kconfig.py | 17 +++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/SConstruct b/SConstruct index fa321b2873..57134b6863 100755 --- a/SConstruct +++ b/SConstruct @@ -264,6 +264,7 @@ kconfig_actions = ( 'guiconfig', 'listnewconfig', 'menuconfig', + 'savedefconfig', 'setconfig', ) @@ -316,6 +317,17 @@ Kconfig tools: scons menuconfig build/foo/bar + savedefconfig: + Save a defconfig file which would give rise to the current config. + For instance, you could use menuconfig to set up a config how you want + it with the options you cared about, and then use savedefconfig to save + a minimal config file. These files would be suitable to use in the + defconfig directory. The second argument specifies the filename for + the new defconfig file. + + scons savedefconfig build/foo/bar new_def_config + + setconfig: Set values in an existing config directory as specified on the command line. For example, to enable gem5's built in systemc kernel: @@ -856,6 +868,12 @@ for variant_path in variant_paths: elif kconfig_action == 'menuconfig': kconfig.menuconfig(env, kconfig_file.abspath, config_file.abspath, variant_path) + elif kconfig_action == 'savedefconfig': + if len(kconfig_args) != 1: + error('Usage: scons defconfig ') + defconfig_path = makePathAbsolute(kconfig_args[0]) + kconfig.savedefconfig(env, kconfig_file.abspath, + config_file.abspath, defconfig_path) elif kconfig_action == 'setconfig': kconfig.setconfig(env, kconfig_file.abspath, config_file.abspath, ARGUMENTS) diff --git a/site_scons/gem5_scons/kconfig.py b/site_scons/gem5_scons/kconfig.py index 5638aa7643..347e11277d 100644 --- a/site_scons/gem5_scons/kconfig.py +++ b/site_scons/gem5_scons/kconfig.py @@ -33,6 +33,7 @@ _kconfig_helpers = { "GUICONFIG_PY": "guiconfig.py", "LISTNEWCONFIG_PY": "listnewconfig.py", "MENUCONFIG_PY": "menuconfig.py", + "SAVEDEFCONFIG_PY": "savedefconfig.py", "SETCONFIG_PY": "setconfig.py", } @@ -130,6 +131,22 @@ def menuconfig( error("Failed to run menuconfig") +def savedefconfig(env, base_kconfig, config_in, config_out): + """ + Interface of handling savedefconfig.py of Kconfiglib + """ + kconfig_env = _prep_env(env, base_kconfig, config_in) + kconfig_env["CONFIG_OUT"] = config_out + if ( + kconfig_env.Execute( + '"${SAVEDEFCONFIG_PY}" ' + '--kconfig "${BASE_KCONFIG}" --out "${CONFIG_OUT}"' + ) + != 0 + ): + error("Failed to run savedefconfig") + + def setconfig(env, base_kconfig, config_path, assignments): """ Interface of handling setconfig.py of Kconfiglib From 63919f6a682bc4ee3e9d74491ed0d3540b719670 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 18 Feb 2022 01:11:33 -0800 Subject: [PATCH 11/22] scons: Hook up oldconfig and olddefconfig. These two utilities help update an old config to add settings for new config options. The difference between them is that oldconfig asks what new settings you want to use, while olddefconfig automatically picks the defaults. Change-Id: Icd3e57f834684e620705beb884faa5b6e2cc7baa --- SConstruct | 23 +++++++++++++++++++++++ site_scons/gem5_scons/kconfig.py | 20 ++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/SConstruct b/SConstruct index 57134b6863..c4782691ff 100755 --- a/SConstruct +++ b/SConstruct @@ -264,6 +264,8 @@ kconfig_actions = ( 'guiconfig', 'listnewconfig', 'menuconfig', + 'oldconfig', + 'olddefconfig', 'savedefconfig', 'setconfig', ) @@ -317,6 +319,22 @@ Kconfig tools: scons menuconfig build/foo/bar + oldconfig: + Update an existing config by adding settings for new options. This is + the same as the olddefconfig tool, except it asks what values you want + for the new settings. + + scons oldconfig build/foo/bar + + + olddefconfig: + Update an existing config by adding settings for new options. This is + the same as the oldconfig tool, except it uses the default for any new + setting. + + scons olddefconfig build/foo/bar + + savedefconfig: Save a defconfig file which would give rise to the current config. For instance, you could use menuconfig to set up a config how you want @@ -868,6 +886,11 @@ for variant_path in variant_paths: elif kconfig_action == 'menuconfig': kconfig.menuconfig(env, kconfig_file.abspath, config_file.abspath, variant_path) + elif kconfig_action == 'oldconfig': + kconfig.oldconfig(env, kconfig_file.abspath, config_file.abspath) + elif kconfig_action == 'olddefconfig': + kconfig.olddefconfig(env, kconfig_file.abspath, + config_file.abspath) elif kconfig_action == 'savedefconfig': if len(kconfig_args) != 1: error('Usage: scons defconfig ') diff --git a/site_scons/gem5_scons/kconfig.py b/site_scons/gem5_scons/kconfig.py index 347e11277d..42b2eec482 100644 --- a/site_scons/gem5_scons/kconfig.py +++ b/site_scons/gem5_scons/kconfig.py @@ -33,6 +33,8 @@ _kconfig_helpers = { "GUICONFIG_PY": "guiconfig.py", "LISTNEWCONFIG_PY": "listnewconfig.py", "MENUCONFIG_PY": "menuconfig.py", + "OLDCONFIG_PY": "oldconfig.py", + "OLDDEFCONFIG_PY": "olddefconfig.py", "SAVEDEFCONFIG_PY": "savedefconfig.py", "SETCONFIG_PY": "setconfig.py", } @@ -118,6 +120,24 @@ def listnewconfig(env, base_kconfig, config_path): error("Failed to run listnewconfig") +def oldconfig(env, base_kconfig, config_path): + """ + Interface of handling oldconfig.py of Kconfiglib + """ + kconfig_env = _prep_env(env, base_kconfig, config_path) + if kconfig_env.Execute('"${OLDCONFIG_PY}" "${BASE_KCONFIG}"') != 0: + error("Failed to run oldconfig") + + +def olddefconfig(env, base_kconfig, config_path): + """ + Interface of handling olddefconfig.py of Kconfiglib + """ + kconfig_env = _prep_env(env, base_kconfig, config_path) + if kconfig_env.Execute('"${OLDDEFCONFIG_PY}" "${BASE_KCONFIG}"') != 0: + error("Failed to run oldconfig") + + def menuconfig( env, base_kconfig, config_path, main_menu_text, style="aquatic" ): From d37673be9f7c3c0daab596f8957572260cfb2be4 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 24 Mar 2022 17:28:26 -0700 Subject: [PATCH 12/22] scons: Remove the default-default build target. In gem5, there are many equally valid and equally useful top level targets which the user might want. It no longer makes sense to arbitrarily pick one to be the default target. It makes sense to force the user to actually specify what they want, instead of assuming it must be the ARM debug binary. There is currently an M5_DEFAULT_BINARY environment variable which will change what the default binary is, if set. This change leaves that in place, but removes the default-default, or in other words the default that is used if M5_DEFAULT_BINARY is not set. This way if the user knows what default they want, they can specify it locally in their environment and avoid having to type it over and over again, but we're not making an arbitrary choice at a more global level without the context to know what actually makes sense. Change-Id: I886adb1289b9879d53387250f950909a4809ed8b --- SConstruct | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index c4782691ff..44b3e8f795 100755 --- a/SConstruct +++ b/SConstruct @@ -196,7 +196,14 @@ if not ('CC' in main and 'CXX' in main): error("No C++ compiler installed (package g++ on Ubuntu and RedHat)") # Find default configuration & binary. -Default(environ.get('M5_DEFAULT_BINARY', 'build/ARM/gem5.debug')) +default_target = environ.get('M5_DEFAULT_BINARY', None) +if default_target: + Default(default_target) + +# If no target is set, even a default, print help instead. +if not BUILD_TARGETS: + warning("No target specified, and no default.") + SetOption('help', True) buildopts_dir = Dir('#build_opts') buildopts = list([f for f in os.listdir(buildopts_dir.abspath) if From d758df4b5ca57dcd1f1b5cd30b272711a60406f5 Mon Sep 17 00:00:00 2001 From: Roger Chang Date: Thu, 14 Sep 2023 11:41:40 +0800 Subject: [PATCH 13/22] scons: Update the Kconfig build options The CL updates the Kconfig: 1. Replace the USE_NULL_ISA with BUILD_ISA 2. The USE_XXX_ISAs are depends on BUILD_ISA 3. If the BUILD_ISA is set, at least one of USE_XXX_ISAs must be set 4. Refactor the USE_KVM option Change-Id: I2a600dea9fb671263b0191c46c5790ebbe91a7b8 --- build_opts/ALL | 1 + build_opts/ARM | 1 + build_opts/ARM_MESI_Three_Level | 1 + build_opts/ARM_MESI_Three_Level_HTM | 1 + build_opts/ARM_MOESI_hammer | 1 + build_opts/GCN3_X86 | 1 + build_opts/Garnet_standalone | 1 - build_opts/MIPS | 1 + build_opts/NULL | 1 - build_opts/NULL_MESI_Two_Level | 1 - build_opts/NULL_MOESI_CMP_directory | 1 - build_opts/NULL_MOESI_CMP_token | 1 - build_opts/NULL_MOESI_hammer | 1 - build_opts/POWER | 1 + build_opts/RISCV | 1 + build_opts/SPARC | 1 + build_opts/VEGA_X86 | 1 + build_opts/X86 | 1 + build_opts/X86_MESI_Two_Level | 1 + build_opts/X86_MI_example | 1 + build_opts/X86_MOESI_AMD_Base | 1 + src/arch/Kconfig | 13 ++++++++++++- src/arch/SConscript | 25 +++++++++++-------------- src/arch/null/Kconfig | 27 --------------------------- src/cpu/kvm/Kconfig | 3 +-- src/cpu/minor/SConscript | 2 +- src/cpu/o3/SConscript | 2 +- src/cpu/o3/probe/SConscript | 2 +- src/cpu/simple/SConscript | 2 +- src/cpu/simple/probes/SConscript | 2 +- src/python/gem5/runtime.py | 3 +++ 31 files changed, 47 insertions(+), 55 deletions(-) delete mode 100644 src/arch/null/Kconfig diff --git a/build_opts/ALL b/build_opts/ALL index 7597531c3a..b44c7a09f7 100644 --- a/build_opts/ALL +++ b/build_opts/ALL @@ -1,5 +1,6 @@ RUBY=y RUBY_PROTOCOL_MESI_TWO_LEVEL=y +BUILD_ISA=y USE_ARM_ISA=y USE_MIPS_ISA=y USE_POWER_ISA=y diff --git a/build_opts/ARM b/build_opts/ARM index 998b2cf008..b50f366703 100644 --- a/build_opts/ARM +++ b/build_opts/ARM @@ -1,3 +1,4 @@ +BUILD_ISA=y USE_ARM_ISA=y RUBY=y RUBY_PROTOCOL_CHI=y diff --git a/build_opts/ARM_MESI_Three_Level b/build_opts/ARM_MESI_Three_Level index 3782efb706..4cda128fb1 100644 --- a/build_opts/ARM_MESI_Three_Level +++ b/build_opts/ARM_MESI_Three_Level @@ -1,3 +1,4 @@ +BUILD_ISA=y USE_ARM_ISA=y RUBY=y RUBY_PROTOCOL_MESI_THREE_LEVEL=y diff --git a/build_opts/ARM_MESI_Three_Level_HTM b/build_opts/ARM_MESI_Three_Level_HTM index 04e2a5ebe1..ade6a0dfb6 100644 --- a/build_opts/ARM_MESI_Three_Level_HTM +++ b/build_opts/ARM_MESI_Three_Level_HTM @@ -1,3 +1,4 @@ +BUILD_ISA=y USE_ARM_ISA=y RUBY=y RUBY_PROTOCOL_MESI_THREE_LEVEL_HTM=y diff --git a/build_opts/ARM_MOESI_hammer b/build_opts/ARM_MOESI_hammer index ce8509280f..44038ff493 100644 --- a/build_opts/ARM_MOESI_hammer +++ b/build_opts/ARM_MOESI_hammer @@ -1,3 +1,4 @@ +BUILD_ISA=y USE_ARM_ISA=y RUBY=y RUBY_PROTOCOL_MOESI_HAMMER=y diff --git a/build_opts/GCN3_X86 b/build_opts/GCN3_X86 index 6e5534caf8..fd471871b6 100644 --- a/build_opts/GCN3_X86 +++ b/build_opts/GCN3_X86 @@ -1,5 +1,6 @@ RUBY=y RUBY_PROTOCOL_GPU_VIPER=y +BUILD_ISA=y USE_X86_ISA=y GCN3_GPU_ISA=y BUILD_GPU=y diff --git a/build_opts/Garnet_standalone b/build_opts/Garnet_standalone index 7460c9d73a..5df3d6c74f 100644 --- a/build_opts/Garnet_standalone +++ b/build_opts/Garnet_standalone @@ -1,3 +1,2 @@ RUBY=y RUBY_PROTOCOL_GARNET_STANDALONE=y -USE_NULL_ISA=y diff --git a/build_opts/MIPS b/build_opts/MIPS index 40955cf999..e60d44ebc4 100644 --- a/build_opts/MIPS +++ b/build_opts/MIPS @@ -1,3 +1,4 @@ RUBY=y RUBY_PROTOCOL_MI_EXAMPLE=y +BUILD_ISA=y USE_MIPS_ISA=y diff --git a/build_opts/NULL b/build_opts/NULL index d514ef168f..16f4686a5a 100644 --- a/build_opts/NULL +++ b/build_opts/NULL @@ -1,3 +1,2 @@ RUBY=y RUBY_PROTOCOL_MI_EXAMPLE=y -USE_NULL_ISA=y diff --git a/build_opts/NULL_MESI_Two_Level b/build_opts/NULL_MESI_Two_Level index a6279e6b49..57542472df 100644 --- a/build_opts/NULL_MESI_Two_Level +++ b/build_opts/NULL_MESI_Two_Level @@ -1,3 +1,2 @@ RUBY=y RUBY_PROTOCOL_MESI_TWO_LEVEL=y -USE_NULL_ISA=y diff --git a/build_opts/NULL_MOESI_CMP_directory b/build_opts/NULL_MOESI_CMP_directory index 88b1de8dbc..3c5308f525 100644 --- a/build_opts/NULL_MOESI_CMP_directory +++ b/build_opts/NULL_MOESI_CMP_directory @@ -1,3 +1,2 @@ RUBY=y RUBY_PROTOCOL_MOESI_CMP_DIRECTORY=y -USE_NULL_ISA=y diff --git a/build_opts/NULL_MOESI_CMP_token b/build_opts/NULL_MOESI_CMP_token index 5c3308125e..2297bdd722 100644 --- a/build_opts/NULL_MOESI_CMP_token +++ b/build_opts/NULL_MOESI_CMP_token @@ -1,3 +1,2 @@ RUBY=y RUBY_PROTOCOL_MOESI_CMP_TOKEN=y -USE_NULL_ISA=y diff --git a/build_opts/NULL_MOESI_hammer b/build_opts/NULL_MOESI_hammer index 79cc7de4f9..fe63b9c54c 100644 --- a/build_opts/NULL_MOESI_hammer +++ b/build_opts/NULL_MOESI_hammer @@ -1,3 +1,2 @@ RUBY=y RUBY_PROTOCOL_MOESI_HAMMER=y -USE_NULL_ISA=y diff --git a/build_opts/POWER b/build_opts/POWER index 69f5e395cf..02f7e161d2 100644 --- a/build_opts/POWER +++ b/build_opts/POWER @@ -1,3 +1,4 @@ RUBY=y RUBY_PROTOCOL_MI_EXAMPLE=y +BUILD_ISA=y USE_POWER_ISA=y diff --git a/build_opts/RISCV b/build_opts/RISCV index 756c39ec02..c0de30e4b5 100644 --- a/build_opts/RISCV +++ b/build_opts/RISCV @@ -1,3 +1,4 @@ RUBY=y RUBY_PROTOCOL_MI_EXAMPLE=y +BUILD_ISA=y USE_RISCV_ISA=y diff --git a/build_opts/SPARC b/build_opts/SPARC index f2766d5ce4..7f3b544d4a 100644 --- a/build_opts/SPARC +++ b/build_opts/SPARC @@ -1,3 +1,4 @@ RUBY=y RUBY_PROTOCOL_MI_EXAMPLE=y +BUILD_ISA=y USE_SPARC_ISA=y diff --git a/build_opts/VEGA_X86 b/build_opts/VEGA_X86 index 58187a355d..0e070529ad 100644 --- a/build_opts/VEGA_X86 +++ b/build_opts/VEGA_X86 @@ -1,5 +1,6 @@ RUBY=y RUBY_PROTOCOL_GPU_VIPER=y +BUILD_ISA=y USE_X86_ISA=y VEGA_GPU_ISA=y BUILD_GPU=y diff --git a/build_opts/X86 b/build_opts/X86 index 5167bf8c06..6d6f4d523a 100644 --- a/build_opts/X86 +++ b/build_opts/X86 @@ -1,4 +1,5 @@ RUBY=y NUMBER_BITS_PER_SET=128 RUBY_PROTOCOL_MESI_TWO_LEVEL=y +BUILD_ISA=y USE_X86_ISA=y diff --git a/build_opts/X86_MESI_Two_Level b/build_opts/X86_MESI_Two_Level index 5167bf8c06..6d6f4d523a 100644 --- a/build_opts/X86_MESI_Two_Level +++ b/build_opts/X86_MESI_Two_Level @@ -1,4 +1,5 @@ RUBY=y NUMBER_BITS_PER_SET=128 RUBY_PROTOCOL_MESI_TWO_LEVEL=y +BUILD_ISA=y USE_X86_ISA=y diff --git a/build_opts/X86_MI_example b/build_opts/X86_MI_example index 1388769868..4236851d4d 100644 --- a/build_opts/X86_MI_example +++ b/build_opts/X86_MI_example @@ -1,3 +1,4 @@ RUBY=y RUBY_PROTOCOL_MI_EXAMPLE=y +BUILD_ISA=y USE_X86_ISA=y diff --git a/build_opts/X86_MOESI_AMD_Base b/build_opts/X86_MOESI_AMD_Base index 09b50b6558..ffb7fb73c0 100644 --- a/build_opts/X86_MOESI_AMD_Base +++ b/build_opts/X86_MOESI_AMD_Base @@ -1,3 +1,4 @@ RUBY=y RUBY_PROTOCOL_MOESI_AMD_BASE=y +BUILD_ISA=y USE_X86_ISA=y diff --git a/src/arch/Kconfig b/src/arch/Kconfig index 05d637913e..729265c317 100644 --- a/src/arch/Kconfig +++ b/src/arch/Kconfig @@ -28,10 +28,21 @@ config TARGET_GPU_ISA rsource "amdgpu/Kconfig" +config BUILD_ISA + bool "Build the arch ISA" + default n + +menu "ISA" + +if BUILD_ISA + rsource "arm/Kconfig" rsource "mips/Kconfig" -rsource "null/Kconfig" rsource "power/Kconfig" rsource "riscv/Kconfig" rsource "sparc/Kconfig" rsource "x86/Kconfig" + +endif + +endmenu diff --git a/src/arch/SConscript b/src/arch/SConscript index 7285c0ec59..2426401d73 100644 --- a/src/arch/SConscript +++ b/src/arch/SConscript @@ -56,20 +56,17 @@ Import('*') # ################################################################# -if env['CONF']['USE_ARM_ISA']: - isa = 'arm' -elif env['CONF']['USE_MIPS_ISA']: - isa = 'mips' -elif env['CONF']['USE_POWER_ISA']: - isa = 'power' -elif env['CONF']['USE_RISCV_ISA']: - isa = 'riscv' -elif env['CONF']['USE_SPARC_ISA']: - isa = 'sparc' -elif env['CONF']['USE_X86_ISA']: - isa = 'x86' -elif env['CONF']['USE_NULL_ISA']: - isa = 'null' +if env['CONF']['BUILD_ISA']: + if ( + not env['CONF']['USE_ARM_ISA'] and + not env['CONF']['USE_MIPS_ISA'] and + not env['CONF']['USE_POWER_ISA'] and + not env['CONF']['USE_RISCV_ISA'] and + not env['CONF']['USE_SPARC_ISA'] and + not env['CONF']['USE_X86_ISA'] + ): + error("At least one ISA need to be set") + amdgpu_isa = ['gcn3', 'vega'] diff --git a/src/arch/null/Kconfig b/src/arch/null/Kconfig deleted file mode 100644 index 64151ecf73..0000000000 --- a/src/arch/null/Kconfig +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2022 Google LLC -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer; -# redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution; -# neither the name of the copyright holders nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -config USE_NULL_ISA - bool "Null ISA support" diff --git a/src/cpu/kvm/Kconfig b/src/cpu/kvm/Kconfig index 824a2e3c41..2b76e94360 100644 --- a/src/cpu/kvm/Kconfig +++ b/src/cpu/kvm/Kconfig @@ -30,5 +30,4 @@ config KVM_ISA config USE_KVM depends on KVM_ISA != "" bool "Enable hardware virtualized (KVM) CPU models" - default y if KVM_ISA != "" - default n + default y diff --git a/src/cpu/minor/SConscript b/src/cpu/minor/SConscript index 9603b4114c..0b98037d6d 100644 --- a/src/cpu/minor/SConscript +++ b/src/cpu/minor/SConscript @@ -40,7 +40,7 @@ Import('*') -if not env['CONF']['USE_NULL_ISA']: +if env['CONF']['BUILD_ISA']: SimObject('BaseMinorCPU.py', sim_objects=[ 'MinorOpClass', 'MinorOpClassSet', 'MinorFUTiming', 'MinorFU', 'MinorFUPool', 'BaseMinorCPU'], diff --git a/src/cpu/o3/SConscript b/src/cpu/o3/SConscript index 2ac703b041..c49db9373d 100755 --- a/src/cpu/o3/SConscript +++ b/src/cpu/o3/SConscript @@ -30,7 +30,7 @@ import sys Import('*') -if not env['CONF']['USE_NULL_ISA']: +if env['CONF']['BUILD_ISA']: SimObject('FUPool.py', sim_objects=['FUPool']) SimObject('FuncUnitConfig.py', sim_objects=[]) SimObject('BaseO3CPU.py', sim_objects=['BaseO3CPU'], enums=[ diff --git a/src/cpu/o3/probe/SConscript b/src/cpu/o3/probe/SConscript index 6039ef2eb9..3065e50a8c 100644 --- a/src/cpu/o3/probe/SConscript +++ b/src/cpu/o3/probe/SConscript @@ -37,7 +37,7 @@ Import('*') -if not env['CONF']['USE_NULL_ISA']: +if env['CONF']['BUILD_ISA']: SimObject('SimpleTrace.py', sim_objects=['SimpleTrace']) Source('simple_trace.cc') DebugFlag('SimpleTrace') diff --git a/src/cpu/simple/SConscript b/src/cpu/simple/SConscript index ffa6467e9b..f2552012bf 100644 --- a/src/cpu/simple/SConscript +++ b/src/cpu/simple/SConscript @@ -28,7 +28,7 @@ Import('*') -if not env['CONF']['USE_NULL_ISA']: +if env['CONF']['BUILD_ISA']: SimObject('BaseAtomicSimpleCPU.py', sim_objects=['BaseAtomicSimpleCPU']) Source('atomic.cc') diff --git a/src/cpu/simple/probes/SConscript b/src/cpu/simple/probes/SConscript index e9fbbb306c..3af318f76f 100644 --- a/src/cpu/simple/probes/SConscript +++ b/src/cpu/simple/probes/SConscript @@ -28,6 +28,6 @@ Import('*') -if not env['CONF']['USE_NULL_ISA']: +if env['CONF']['BUILD_ISA']: SimObject('SimPoint.py', sim_objects=['SimPoint']) Source('simpoint.cc') diff --git a/src/python/gem5/runtime.py b/src/python/gem5/runtime.py index 6eed62a9da..9118237f37 100644 --- a/src/python/gem5/runtime.py +++ b/src/python/gem5/runtime.py @@ -42,6 +42,9 @@ def get_supported_isas() -> Set[ISA]: """ supported_isas = set() + if not buildEnv["BUILD_ISA"]: + return {ISA.NULL} + if "TARGET_ISA" in buildEnv.keys(): supported_isas.add(get_isa_from_str(buildEnv["TARGET_ISA"])) From 3b06925408369cfe75236adc4de3027cd2c63d02 Mon Sep 17 00:00:00 2001 From: Roger Chang Date: Thu, 14 Sep 2023 11:45:55 +0800 Subject: [PATCH 14/22] scons: Update Kconfig description Change-Id: I69206fb9881bc0d53660bbd1cf8fc225ead9fea3 --- SConstruct | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/SConstruct b/SConstruct index 44b3e8f795..77bbd3a866 100755 --- a/SConstruct +++ b/SConstruct @@ -216,10 +216,10 @@ Help(f""" Targets: To build gem5 using a predefined configuration, use a target with a directory called "build" in the path, followed by a directory named - after a predefined configuration, and then the actual target, likely - a gem5 binary. For example: + after a predefined configuration in "build_opts" directory, and then + the actual target, likely a gem5 binary. For example: - scons build/X86/gem5.opt + scons build/ALL/gem5.opt The "build" component tells SCons that the next part names an initial configuration, and the part after that is the actual target. @@ -237,11 +237,15 @@ Targets: disabled. gem5 can also be built as a static or dynamic library. In that case, - the extension is fixed by the operating system, so the binary type + the extension is determined by the operating system, so the binary type is part of the target file name. For example: scons build/ARM/libgem5_opt.so + In MacOS, the extension should change to "dylib" like this: + + scons build/ARM/libgem5_opt.dylib + To build unit tests, you can use a target like this: scons build/RISCV/unittests.debug @@ -283,18 +287,14 @@ Kconfig: configs, or edit one that already exists. To use one of the kconfig tools with a particular directory, use a target which is the directory to configure, and then the name of the tool. For example, to run - menuconfig on directory build/foo/bar, run: + menuconfig on directory build_foo/bar, run: - scons menuconfig build/foo/bar + scons menuconfig build_foo/bar - will set up a build directory in build/foo/bar if one doesn't already + will set up a build directory in build_foo/bar if one doesn't already exist, and open the menuconfig editor to view/set configuration values. - The tools available for working with kconfig are generally very - similar to ones used with the linux kernel, so information about the - kernel versions will typically (but not always) apply here as well. - Kconfig tools: defconfig: Set up a config using values specified in a defconfig file, or if no @@ -302,28 +302,28 @@ Kconfig tools: defconfig file. A defconfig file in the build_opts directory can be implicitly specified in the build path via `build//` - scons defconfig build/foo/bar build_opts/MIPS + scons defconfig build_foo/bar build_opts/MIPS guiconfig: Opens the guiconfig editor which will let you view and edit config values, and view help text. guiconfig runs as a graphical application. - scons guiconfig build/foo/bar + scons guiconfig build_foo/bar listnewconfig: Lists config options which are new in the Kconfig and which are not currently set in the existing config file. - scons listnewconfig build/foo/bar + scons listnewconfig build_foo/bar menuconfig: Opens the menuconfig editor which will let you view and edit config values, and view help text. menuconfig runs in text mode. - scons menuconfig build/foo/bar + scons menuconfig build_foo/bar oldconfig: @@ -331,7 +331,7 @@ Kconfig tools: the same as the olddefconfig tool, except it asks what values you want for the new settings. - scons oldconfig build/foo/bar + scons oldconfig build_foo/bar olddefconfig: @@ -339,7 +339,7 @@ Kconfig tools: the same as the oldconfig tool, except it uses the default for any new setting. - scons olddefconfig build/foo/bar + scons olddefconfig build_foo/bar savedefconfig: @@ -350,14 +350,14 @@ Kconfig tools: defconfig directory. The second argument specifies the filename for the new defconfig file. - scons savedefconfig build/foo/bar new_def_config + scons savedefconfig build_foo/bar new_def_config setconfig: Set values in an existing config directory as specified on the command line. For example, to enable gem5's built in systemc kernel: - scons setconfig build/foo/bar USE_SYSTEMC=y + scons setconfig build_foo/bar USE_SYSTEMC=y """, append=True) # Take a list of paths (or SCons Nodes) and return a list with all @@ -907,8 +907,6 @@ for variant_path in variant_paths: elif kconfig_action == 'setconfig': kconfig.setconfig(env, kconfig_file.abspath, config_file.abspath, ARGUMENTS) - else: - error(f'Unrecognized kconfig action {kconfig_action}') Exit(0) # If no config exists yet, see if we know how to make one? From 7b35765217c9caa9713789a35c06f4482f281fb8 Mon Sep 17 00:00:00 2001 From: Roger Chang Date: Wed, 18 Oct 2023 11:33:39 +0800 Subject: [PATCH 15/22] scons: Refactor the USE_SYSTEMC option Change-Id: I2f51081e0db932b83eea9dd395551afe13d54a34 --- src/systemc/Kconfig | 6 +++++- src/systemc/SConsopts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/systemc/Kconfig b/src/systemc/Kconfig index 3f3df93f53..3dde45d8da 100644 --- a/src/systemc/Kconfig +++ b/src/systemc/Kconfig @@ -23,6 +23,10 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +config HAVE_SYSTEMC + def_bool "$(HAVE_SYSTEMC)" + config USE_SYSTEMC + depends on HAVE_SYSTEMC bool "Enable SystemC API support" - default $(USE_SYSTEMC) + default y diff --git a/src/systemc/SConsopts b/src/systemc/SConsopts index 20436ec81b..e7d9c04fd1 100644 --- a/src/systemc/SConsopts +++ b/src/systemc/SConsopts @@ -44,4 +44,4 @@ def use_systemc_check(env, warn=False): main.AddMethod(use_systemc_check, 'UseSystemcCheck') -main['CONF']['USE_SYSTEMC'] = main.UseSystemcCheck() +main['CONF']['HAVE_SYSTEMC'] = main.UseSystemcCheck() From 758f9d2ea1625c659258b4da98cd3efea30774b2 Mon Sep 17 00:00:00 2001 From: Roger Chang Date: Thu, 19 Oct 2023 08:43:35 +0800 Subject: [PATCH 16/22] util: Add python3-tk package to dockerfile The guiconfig required the python3-tk package to run. Change-Id: I1d126021c2c57448b1ceefb9fff256e2a6bbbf33 --- util/dockerfiles/ubuntu-20.04_all-dependencies/Dockerfile | 2 +- util/dockerfiles/ubuntu-22.04_all-dependencies/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/util/dockerfiles/ubuntu-20.04_all-dependencies/Dockerfile b/util/dockerfiles/ubuntu-20.04_all-dependencies/Dockerfile index 8f092adc7a..80580edf41 100644 --- a/util/dockerfiles/ubuntu-20.04_all-dependencies/Dockerfile +++ b/util/dockerfiles/ubuntu-20.04_all-dependencies/Dockerfile @@ -32,7 +32,7 @@ RUN apt -y update && apt -y upgrade && \ libprotobuf-dev protobuf-compiler libprotoc-dev libgoogle-perftools-dev \ python3-dev python-is-python3 doxygen libboost-all-dev \ libhdf5-serial-dev python3-pydot libpng-dev libelf-dev pkg-config pip \ - python3-venv black gcc-10 g++-10 + python3-venv black gcc-10 g++-10 python3-tk RUN pip install mypy pre-commit diff --git a/util/dockerfiles/ubuntu-22.04_all-dependencies/Dockerfile b/util/dockerfiles/ubuntu-22.04_all-dependencies/Dockerfile index 9e2580e642..21626ed994 100644 --- a/util/dockerfiles/ubuntu-22.04_all-dependencies/Dockerfile +++ b/util/dockerfiles/ubuntu-22.04_all-dependencies/Dockerfile @@ -31,6 +31,6 @@ RUN apt -y update && apt -y upgrade && \ apt -y install build-essential git m4 scons zlib1g zlib1g-dev \ libprotobuf-dev protobuf-compiler libprotoc-dev libgoogle-perftools-dev \ python3-dev doxygen libboost-all-dev libhdf5-serial-dev python3-pydot \ - libpng-dev libelf-dev pkg-config pip python3-venv black + libpng-dev libelf-dev pkg-config pip python3-venv black python3-tk RUN pip install mypy pre-commit From 5b212334913d6f9f23cd835979c938db9d9bc070 Mon Sep 17 00:00:00 2001 From: Roger Chang Date: Thu, 19 Oct 2023 13:11:05 +0800 Subject: [PATCH 17/22] tests: Update Gem5Fixture to compatible of Kconfig system Used after the build system changed to Kconfig Change-Id: I699b36f09691dc821da8ee80fe5b60f30fe2179c --- tests/gem5/fixture.py | 68 ++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 27 deletions(-) diff --git a/tests/gem5/fixture.py b/tests/gem5/fixture.py index da2cf11be2..94596f4f5c 100644 --- a/tests/gem5/fixture.py +++ b/tests/gem5/fixture.py @@ -151,9 +151,44 @@ class SConsFixture(UniqueFixture): if config.skip_build: return - def _setup(self, testitem): - if config.skip_build: - return + if not self.targets: + log.test_log.error("No SCons targets specified.") + else: + log.test_log.message( + "Building the following targets. This may take a while." + ) + log.test_log.message(f"{', '.join(self.targets)}") + log.test_log.message( + "You may want to use --skip-build, or use 'rerun'." + ) + + if self.protocol: + defconfig_command = [ + "scons", + "-C", + self.directory, + "--ignore-style", + "--no-compress-debug", + "defconfig", + self.target_dir, + joinpath(self.directory, "build_opts", self.isa.upper()), + ] + setconfig_command = [ + "scons", + "-C", + self.directory, + "--ignore-style", + "--no-compress-debug", + "setconfig", + self.target_dir, + f"RUBY_PROTOCOL_{self.protocol.upper()}=y", + ] + log_call( + log.test_log, defconfig_command, time=None, stderr=sys.stderr + ) + log_call( + log.test_log, setconfig_command, time=None, stderr=sys.stderr + ) command = [ "scons", @@ -164,26 +199,7 @@ class SConsFixture(UniqueFixture): "--ignore-style", "--no-compress-debug", ] - - if not self.targets: - log.test_log.warn( - "No SCons targets specified, this will" - " build the default all target.\n" - "This is likely unintended, and you" - " may wish to kill testlib and reconfigure." - ) - else: - log.test_log.message( - "Building the following targets. This may take a while." - ) - log.test_log.message(f"{', '.join(self.targets)}") - log.test_log.message( - "You may want to use --skip-build, or use 'rerun'." - ) - command.extend(self.targets) - if self.options: - command.extend(self.options) log_call(log.test_log, command, time=None, stderr=sys.stderr) @@ -194,6 +210,7 @@ class Gem5Fixture(SConsFixture): target_dir += "_" + protocol target = joinpath(target_dir, f"gem5.{variant}") obj = super().__new__(cls, target) + obj.target_dir = target_dir return obj def _init(self, isa, variant, protocol=None): @@ -203,15 +220,12 @@ class Gem5Fixture(SConsFixture): self.path = self.target self.directory = config.base_dir - self.options = [] - if protocol: - self.options = ["--default=" + isa.upper(), "PROTOCOL=" + protocol] + self.isa = isa + self.protocol = protocol self.set_global() def get_get_build_info(self) -> Optional[str]: build_target = self.target - if self.options: - build_target += " ".join(self.options) return build_target From 5828b1eb32b439d3695df2568c807045553182ae Mon Sep 17 00:00:00 2001 From: Roger Chang Date: Thu, 19 Oct 2023 13:22:35 +0800 Subject: [PATCH 18/22] misc: Update daily-test.yaml to match Kconfig build system configuration Change-Id: I20b04d006c67374e3226a91c03550f2731ed7fe7 --- .github/workflows/daily-tests.yaml | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/workflows/daily-tests.yaml b/.github/workflows/daily-tests.yaml index 89a72fd852..987f5c1ad2 100644 --- a/.github/workflows/daily-tests.yaml +++ b/.github/workflows/daily-tests.yaml @@ -28,15 +28,20 @@ jobs: # the default is to add -j $(nproc), but some images # require more specifications when built include: - - command-line: -j $(nproc) + - setconfig-option: '' + - isa-option: '' - image: ALL_CHI - command-line: --default=ALL PROTOCOL=CHI -j $(nproc) + setconfig-option: RUBY_PROTOCOL_CHI=y + isa-option: ALL - image: ALL_MSI - command-line: --default=ALL PROTOCOL=MSI -j $(nproc) + setconfig-option: RUBY_PROTOCOL_MSI=y + isa-option: ALL - image: ALL_MESI_Two_Level - command-line: --default=ALL PROTOCOL=MESI_Two_Level -j $(nproc) + setconfig-option: RUBY_PROTOCOL_MESI_TWO_LEVEL=y + isa-option: ALL - image: NULL_MI_example - command-line: --default=NULL PROTOCOL=MI_example -j $(nproc) + setconfig-option: RUBY_PROTOCOL_MI_EXAMPLE=y + isa-option: 'NULL' runs-on: [self-hosted, linux, x64] needs: name-artifacts container: ghcr.io/gem5/ubuntu-22.04_all-dependencies:latest @@ -46,8 +51,14 @@ jobs: # Scheduled workflows run on the default branch by default. We # therefore need to explicitly checkout the develop branch. ref: develop + - name: defconfig gem5 + if: ${{ matrix.setconfig-option != '' }} + run: scons defconfig build/${{ matrix.image }} build_opts/${{ matrix.isa-option }} + - name: setconfig gem5 + if: ${{ matrix.setconfig-option != '' }} + run: scons setconfig build/${{ matrix.image }} ${{ matrix.setconfig-option }} - name: Build gem5 - run: scons build/${{ matrix.image }}/gem5.opt ${{ matrix.command-line }} + run: scons build/${{ matrix.image }}/gem5.opt -j $(nproc) - uses: actions/upload-artifact@v3 with: name: ${{ needs.name-artifacts.outputs.build-name }}${{ matrix.image }} @@ -245,8 +256,10 @@ jobs: ref: develop - name: Build ARM/gem5.opt run: scons build/ARM/gem5.opt --ignore-style --duplicate-sources -j$(nproc) + - name: disable systemc + run: scons setconfig build/ARM --ignore-style USE_SYSTEMC=n - name: Build ARM/libgem5_opt.so - run: scons build/ARM/libgem5_opt.so --with-cxx-config --without-python --without-tcmalloc USE_SYSTEMC=0 -j$(nproc) --duplicate-sources + run: scons build/ARM/libgem5_opt.so --with-cxx-config --without-python --without-tcmalloc -j$(nproc) --duplicate-sources - name: Compile gem5 withing SystemC working-directory: ${{ github.workspace }}/util/systemc/gem5_within_systemc run: make From 4d632cb73fbac542fcc625dd0a70ab2ba97721d4 Mon Sep 17 00:00:00 2001 From: Roger Chang Date: Tue, 24 Oct 2023 10:34:31 +0800 Subject: [PATCH 19/22] scons: Add new config option HAVE_CAPSTONE to Kconfig The config option HAVE_CAPSTONE is added in the previous [1] and the Kconfig options should be sync with it. [1] https://github.com/gem5/gem5/pull/494 Change-Id: Id83718bc825f53d87d37d6ac930b96371209bdb3 --- src/Kconfig | 2 +- src/cpu/Kconfig | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/cpu/Kconfig diff --git a/src/Kconfig b/src/Kconfig index 02bf90ab86..2d24aad1ad 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -48,6 +48,6 @@ rsource "learning_gem5/part3/Kconfig" rsource "proto/Kconfig" rsource "dev/net/Kconfig" rsource "arch/Kconfig" -rsource "cpu/kvm/Kconfig" +rsource "cpu/Kconfig" rsource "systemc/Kconfig" rsource "gpu-compute/Kconfig" diff --git a/src/cpu/Kconfig b/src/cpu/Kconfig new file mode 100644 index 0000000000..33a00e9c45 --- /dev/null +++ b/src/cpu/Kconfig @@ -0,0 +1,29 @@ +# Copyright 2023 Google LLC +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +config HAVE_CAPSTONE + def_bool $(HAVE_CAPSTONE) + +rsource "kvm/Kconfig" From 23e4525e29cc3580ed32506f587a5a6739b755ea Mon Sep 17 00:00:00 2001 From: Roger Chang Date: Thu, 23 Nov 2023 08:41:37 +0800 Subject: [PATCH 20/22] util: Update the tlm README Change-Id: I4006257bf55d7065136347788783796fd39ab725 --- util/tlm/README | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/util/tlm/README b/util/tlm/README index 3ae43c5909..1dbfe41ae7 100644 --- a/util/tlm/README +++ b/util/tlm/README @@ -93,13 +93,14 @@ without python. > cd ../.. > scons build/ARM/gem5.opt -> scons --with-cxx-config --without-python --without-tcmalloc USE_SYSTEMC=0 \ -> build/ARM/libgem5_opt.so +> scons setconfig build/ARM USE_SYSTEMC=n +> scons --with-cxx-config --without-python --without-tcmalloc \ +> --duplicate-sources build/ARM/libgem5_opt.so > cd util/tlm Note: For MAC / OSX this command should be used: -> scons --with-cxx-config --without-python --without-tcmalloc USE_SYSTEMC=0 \ -> build/ARM/libgem5_opt.dylib +> scons --with-cxx-config --without-python --without-tcmalloc \ +> --duplicate-sources build/ARM/libgem5_opt.dylib To build all sources of the SystemC binding and the examples simply run scons: From 412cf3e644e32f0caa217bd759fe465fdd01881f Mon Sep 17 00:00:00 2001 From: Roger Chang Date: Thu, 23 Nov 2023 08:46:27 +0800 Subject: [PATCH 21/22] util: Update the gem5_within_systemc README Change-Id: Ife34fe5ccd00fa2c6a83f34af49333d49017dfed --- util/systemc/gem5_within_systemc/README | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/util/systemc/gem5_within_systemc/README b/util/systemc/gem5_within_systemc/README index bcaaceeb77..8d396c15ad 100644 --- a/util/systemc/gem5_within_systemc/README +++ b/util/systemc/gem5_within_systemc/README @@ -36,12 +36,13 @@ present in the "build" directory. > cd ../../.. > scons build/ARM/gem5.opt -> scons --with-cxx-config --without-python --without-tcmalloc USE_SYSTEMC=0 \ +> scons setconfig build/ARM USE_SYSTEMC=n +> scons --with-cxx-config --without-python --without-tcmalloc \ > --duplicate-source build/ARM/libgem5_opt.so > cd util/systemc Note: For MAC / OSX this command should be used: -> scons --with-cxx-config --without-python --without-tcmalloc USE_SYSTEMC=0 \ +> scons --with-cxx-config --without-python --without-tcmalloc \ > --duplicate-sources build/ARM/libgem5_opt.dylib Set a proper LD_LIBRARY_PATH e.g. for bash: @@ -67,7 +68,7 @@ Then run make: Make a config file for the C++-configured gem5 using normal gem5 -> ../../../build/ARM/gem5.opt ../../../configs/example/se.py -c \ +> ../../../build/ARM/gem5.opt ../../../configs/deprecated/example/se.py -c \ > ../../../tests/test-progs/hello/bin/arm/linux/hello The binary 'gem5.opt.cxx' can now be used to load in the generated config From 92670e974561f6f0dfcacf81ba9b43a0826d623e Mon Sep 17 00:00:00 2001 From: Roger Chang Date: Thu, 23 Nov 2023 14:15:28 +0800 Subject: [PATCH 22/22] fastmodel: Simply the logic of USE_ARM_FASTMODEL setting Change-Id: Ib00cf83ca881727987050a987a2adb1e9f9d31ef --- src/arch/arm/fastmodel/SConscript | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/arch/arm/fastmodel/SConscript b/src/arch/arm/fastmodel/SConscript index f8cfd5991c..8b1ab6af05 100644 --- a/src/arch/arm/fastmodel/SConscript +++ b/src/arch/arm/fastmodel/SConscript @@ -48,11 +48,7 @@ from gem5_scons import Transform, warning, error import os.path if env['CONF']['USE_ARM_FASTMODEL']: - if env['CONF']['USE_SYSTEMC']: - env.TagImplies('arm fastmodel', 'arm isa') - else: - warning('ARM Fast Models require systemc support') - env['CONF']['USE_ARM_FASTMODEL'] = False + env.TagImplies('arm fastmodel', 'arm isa') systemc_home = Dir('#/src/systemc/ext/systemc_home')