[gem5-dev] Change in gem5/gem5[develop]: tests: [WIP] Add KVM CPU switch tests

2021-09-16 Thread Bobby R. Bruce (Gerrit) via gem5-dev
Bobby R. Bruce has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/50487 )



Change subject: tests: [WIP] Add KVM CPU switch tests
..

tests: [WIP] Add KVM CPU switch tests

WIP, not yet complete

Change-Id: Ief5d09084a88726fc3944e0c56f3a61a5d04ec1b
---
A tests/gem5/kvm-switch-tests/test_kvm_cpu_switch.py
1 file changed, 146 insertions(+), 0 deletions(-)



diff --git a/tests/gem5/kvm-switch-tests/test_kvm_cpu_switch.py  
b/tests/gem5/kvm-switch-tests/test_kvm_cpu_switch.py

new file mode 100644
index 000..78008f8
--- /dev/null
+++ b/tests/gem5/kvm-switch-tests/test_kvm_cpu_switch.py
@@ -0,0 +1,146 @@
+# Copyright (c) 2021 The Regents of the University of California
+# 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.
+
+"""
+The purpose of this Suite of tests is to check the gem5.components  
switchable

+processor is functioning as intended; allowing switching from KVM to a more
+detailed processor.
+"""
+
+import os
+
+from testlib import *
+
+if config.bin_path:
+resource_path = config.bin_path
+else:
+resource_path = joinpath(absdirpath(__file__), "..", "resources")
+
+
+def test_kvm_switch(cpu: str, num_cpus: int, mem_system: str, length: str):
+
+if not os.access("/dev/kvm", mode=os.R_OK | os.W_OK):
+# Don't run the tests if KVM is unavailable.
+return
+
+name = "{}-cpu_{}-cores_{}_kvm-switch-test".format(
+cpu, str(num_cpus), mem_system
+)
+verifiers = []
+
+if mem_system == "mesi_two_level":
+protocol_to_use = "MESI_Two_Level"
+isa_to_use = constants.x86_tag
+elif mem_system == "mi_example":
+protocol_to_use = None
+isa_to_use = constants.x86_tag
+else:
+protocol_to_use = None
+isa_to_use = constants.gcn3_x86_tag
+
+gem5_verify_config(
+name=name,
+verifiers=verifiers,
+fixtures=(),
+config=joinpath(
+config.base_dir,
+"tests",
+"gem5",
+"configs",
+"boot_kvm_switch_exit.py",
+),
+config_args=[
+"--cpu",
+cpu,
+"--num-cpus",
+str(num_cpus),
+"--mem-system",
+mem_system,
+"--override-download",
+"--resource-directory",
+resource_path,
+"--kernel-args=''",
+],
+valid_isas=(isa_to_use,),
+valid_hosts=constants.supported_hosts,
+protocol=protocol_to_use,
+length=length,
+)
+
+
+ The quick (pre-submit/Kokoro) tests 
+
+test_kvm_switch(
+cpu="atomic", num_cpus=1, mem_system="classic",  
length=constants.quick_tag

+)
+test_kvm_switch(
+cpu="classic", num_cpus=1, mem_system="classic",  
length=constants.quick_tag

+)
+test_kvm_switch(
+cpu="timing", num_cpus=1, mem_system="classic",  
length=constants.quick_tag

+)
+test_kvm_switch(
+cpu="atomic",
+num_cpus=1,
+mem_system="mi_example",
+length=constants.quick_tag,
+)
+test_kvm_switch(
+cpu="classic", num_cpus=4, mem_system="classic",  
length=constants.quick_tag

+)
+test_kvm_switch(
+cpu="timing",
+num_cpus=4,
+mem_system="mi_example",
+length=constants.quick_tag,
+)
+
+### The long (nightly) tests 
+
+test_kvm_switch(
+cpu="atomic",
+num_cpus=1,
+mem_system="mesi_two_level",
+length=constants.long_tag,
+)
+test_kvm_switch(
+cpu="classic",
+num_cpus=1,
+ 

[gem5-dev] Change in gem5/gem5[develop]: base: Make the AddrRange::exclude method const.

2021-09-16 Thread Gabe Black (Gerrit) via gem5-dev
Gabe Black has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/50337 )




1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the  
submitted one.

Change subject: base: Make the AddrRange::exclude method const.
..

base: Make the AddrRange::exclude method const.

This should not modify the base AddrRange, and can be marked const.

Change-Id: I8554707ab8dd895d24891acff18013308ab779a6
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/50337
Tested-by: kokoro 
Reviewed-by: Daniel Carvalho 
Maintainer: Daniel Carvalho 
---
M src/base/addr_range.hh
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Daniel Carvalho: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/base/addr_range.hh b/src/base/addr_range.hh
index eb611cc..77cd51a 100644
--- a/src/base/addr_range.hh
+++ b/src/base/addr_range.hh
@@ -612,7 +612,7 @@
  * @ingroup api_addr_range
  */
 std::vector
-exclude(const std::vector _ranges)
+exclude(const std::vector _ranges) const
 {
 assert(!interleaved());


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/50337
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I8554707ab8dd895d24891acff18013308ab779a6
Gerrit-Change-Number: 50337
Gerrit-PatchSet: 3
Gerrit-Owner: Gabe Black 
Gerrit-Reviewer: Bobby R. Bruce 
Gerrit-Reviewer: Daniel Carvalho 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: kokoro 
Gerrit-MessageType: merged
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

[gem5-dev] Change in gem5/gem5[develop]: scons: Simplify the PySource class slightly.

2021-09-16 Thread Gabe Black (Gerrit) via gem5-dev
Gabe Black has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/49388 )




10 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the  
submitted one.

Change subject: scons: Simplify the PySource class slightly.
..

scons: Simplify the PySource class slightly.

Demote the cpp attribute to a local variable, and get rid of the unused
"package" attribute.

Change-Id: I190792274ea9bdd9853aa3b6e07ce4151b378251
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49388
Maintainer: Gabe Black 
Tested-by: kokoro 
Reviewed-by: Hoa Nguyen 
---
M src/SConscript
1 file changed, 4 insertions(+), 4 deletions(-)

Approvals:
  Hoa Nguyen: Looks good to me, approved
  Gabe Black: Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/SConscript b/src/SConscript
index a5b679c..2e48048 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -160,24 +160,24 @@
 if not os.path.exists(abspath):
 abspath = self.tnode.abspath

-self.package = package
 self.modname = modname
 self.modpath = modpath
 self.abspath = abspath
-self.cpp = File(self.filename + '.cc')

 PySource.modules[modpath] = self

+cpp = File(self.filename + '.cc')
+
 overrides = {
 'PYSOURCE_MODPATH': modpath,
 'PYSOURCE_ABSPATH': abspath,
 }
-marshal_env.Command(self.cpp, [ py_marshal, File(source) ],
+marshal_env.Command(cpp, [ py_marshal, File(source) ],
 MakeAction(embedPyFile, Transform("EMBED PY"),
 varlist=overrides.keys()),
 **overrides)
 if main['USE_PYTHON']:
-Source(self.cpp, tags=self.tags, add_tags='python')
+Source(cpp, tags=self.tags, add_tags='python')

 class SimObject(PySource):
 '''Add a SimObject python file as a python source object and add

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/49388
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I190792274ea9bdd9853aa3b6e07ce4151b378251
Gerrit-Change-Number: 49388
Gerrit-PatchSet: 12
Gerrit-Owner: Gabe Black 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Hoa Nguyen 
Gerrit-Reviewer: kokoro 
Gerrit-MessageType: merged
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

[gem5-dev] Change in gem5/gem5[develop]: python: Pull most of the logic in marshal.cc into python.

2021-09-16 Thread Gabe Black (Gerrit) via gem5-dev
Gabe Black has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/49391 )




10 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the  
submitted one.

Change subject: python: Pull most of the logic in marshal.cc into python.
..

python: Pull most of the logic in marshal.cc into python.

Put most of the logic in python, and turn the c++ parts into a very
generic wrapper which could meaningfully run any python code under the
interpreter which will be embedded in gem5.

Change-Id: I3f6e50839490eaf0db9a6bd242efbcb8de1b6e24
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49391
Tested-by: kokoro 
Reviewed-by: Hoa Nguyen 
Reviewed-by: Andreas Sandberg 
Maintainer: Andreas Sandberg 
---
M src/python/marshal.cc
1 file changed, 23 insertions(+), 11 deletions(-)

Approvals:
  Andreas Sandberg: Looks good to me, approved; Looks good to me, approved
  Hoa Nguyen: Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/python/marshal.cc b/src/python/marshal.cc
index 7e05c3a..99305b2 100644
--- a/src/python/marshal.cc
+++ b/src/python/marshal.cc
@@ -37,19 +37,23 @@

 #include 

-#include 
-
 namespace py = pybind11;
-using namespace pybind11::literals;

 constexpr auto MarshalScript = R"(
 import marshal
+import sys

+if len(sys.argv) < 2:
+print(f"Usage: {sys.argv[0]} PYSOURCE", file=sys.stderr)
+sys.exit(1)
+
+source = sys.argv[1]
 with open(source, 'r') as f:
 src = f.read()

 compiled = compile(src, source, 'exec')
 marshalled = marshal.dumps(compiled)
+sys.stdout.buffer.write(marshalled)
 )";

 int
@@ -57,17 +61,25 @@
 {
 py::scoped_interpreter guard;

-if (argc != 2) {
-std::cerr << "Usage: marshal PYSOURCE" << std::endl;
-exit(1);
+// Embedded python doesn't set up sys.argv, so we'll do that ourselves.
+py::list py_argv;
+auto sys = py::module::import("sys");
+if (py::hasattr(sys, "argv")) {
+// sys.argv already exists, so grab that.
+py_argv = sys.attr("argv");
+} else {
+// sys.argv doesn't exist, so create it.
+sys.add_object("argv", py_argv);
 }
+// Clear out argv just in case it has something in it.
+py_argv.attr("clear")();

-auto locals = py::dict("source"_a=argv[1]);
+// Fill it with our argvs.
+for (int i = 0; i < argc; i++)
+py_argv.append(argv[i]);

-py::exec(MarshalScript, py::globals(), locals);
-
-auto marshalled = locals["marshalled"].cast();
-std::cout << marshalled;
+// Actually call the script.
+py::exec(MarshalScript, py::globals());

 return 0;
 }

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/49391
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I3f6e50839490eaf0db9a6bd242efbcb8de1b6e24
Gerrit-Change-Number: 49391
Gerrit-PatchSet: 12
Gerrit-Owner: Gabe Black 
Gerrit-Reviewer: Andreas Sandberg 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Hoa Nguyen 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: kokoro 
Gerrit-MessageType: merged
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

[gem5-dev] Change in gem5/gem5[develop]: scons: Eliminate the tnode dict in PySource.

2021-09-16 Thread Gabe Black (Gerrit) via gem5-dev
Gabe Black has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/49387 )


Change subject: scons: Eliminate the tnode dict in PySource.
..

scons: Eliminate the tnode dict in PySource.

Rather than pass these values to the embedPyFile function indirectly
through python, we should pass them through the environment so SCons can
know about them, and also to simplify the PySource class.

Change-Id: I466613c194bfd965a6f5f34e1e92131834fb8b66
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49387
Maintainer: Gabe Black 
Tested-by: kokoro 
Reviewed-by: Hoa Nguyen 
---
M src/SConscript
1 file changed, 14 insertions(+), 13 deletions(-)

Approvals:
  Hoa Nguyen: Looks good to me, approved
  Gabe Black: Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/SConscript b/src/SConscript
index 8c5c2b9..a5b679c 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -88,11 +88,6 @@
 # byte code, compress it, and then generate a c++ file that
 # inserts the result into an array.
 def embedPyFile(target, source, env):
-def c_str(string):
-if string is None:
-return "0"
-return '"%s"' % string
-
 '''Action function to compile a .py into a code object, marshal it,
 compress it, and stick it into an asm file so the code appears as
 just bytes with a label in the data section. The action takes two
@@ -104,12 +99,14 @@

 import subprocess

+marshal_bin, pysource = source
+modpath = env['PYSOURCE_MODPATH']
+abspath = env['PYSOURCE_ABSPATH']
 marshalled = subprocess.check_output(
-[source[0].abspath, str(source[1])], env=env['ENV'])
+[marshal_bin.abspath, str(pysource)], env=env['ENV'])

 compressed = zlib.compress(marshalled)
 data = compressed
-pysource = PySource.tnodes[source[1]]

 code = code_formatter()
 code('''\
@@ -127,8 +124,8 @@
 # into a global list.
 code('''
 EmbeddedPython embedded_module_info(
-${{c_str(pysource.abspath)}},
-${{c_str(pysource.modpath)}},
+"${abspath}",
+"${modpath}",
 embedded_module_data,
 ${{len(data)}},
 ${{len(marshalled)}});
@@ -141,7 +138,6 @@
 class PySource(SourceFile):
 '''Add a python source file to the named package'''
 modules = {}
-tnodes = {}

 def __init__(self, package, source, tags=None, add_tags=None):
 '''specify the python package, the source file, and any tags'''
@@ -171,10 +167,15 @@
 self.cpp = File(self.filename + '.cc')

 PySource.modules[modpath] = self
-PySource.tnodes[self.tnode] = self

-marshal_env.Command(self.cpp, [ py_marshal, self.tnode ],
-MakeAction(embedPyFile, Transform("EMBED PY")))
+overrides = {
+'PYSOURCE_MODPATH': modpath,
+'PYSOURCE_ABSPATH': abspath,
+}
+marshal_env.Command(self.cpp, [ py_marshal, File(source) ],
+MakeAction(embedPyFile, Transform("EMBED PY"),
+varlist=overrides.keys()),
+**overrides)
 if main['USE_PYTHON']:
 Source(self.cpp, tags=self.tags, add_tags='python')


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/49387
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I466613c194bfd965a6f5f34e1e92131834fb8b66
Gerrit-Change-Number: 49387
Gerrit-PatchSet: 12
Gerrit-Owner: Gabe Black 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Hoa Nguyen 
Gerrit-Reviewer: kokoro 
Gerrit-MessageType: merged
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

[gem5-dev] Change in gem5/gem5[develop]: scons: Get rid of a loop which touched all the param ptype attributes.

2021-09-16 Thread Gabe Black (Gerrit) via gem5-dev
Gabe Black has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/49390 )




10 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the  
submitted one.
Change subject: scons: Get rid of a loop which touched all the param ptype  
attributes.

..

scons: Get rid of a loop which touched all the param ptype attributes.

As far as I can tell, this code is left over from when gem5 used SWIG,
and is not necessary any more.

Change-Id: Id36887773d2fc1373ffe689ee1b50b4989bf5a38
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49390
Maintainer: Gabe Black 
Tested-by: kokoro 
Reviewed-by: Hoa Nguyen 
---
M src/SConscript
1 file changed, 0 insertions(+), 8 deletions(-)

Approvals:
  Hoa Nguyen: Looks good to me, approved
  Gabe Black: Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/SConscript b/src/SConscript
index f4e59a8..fdd5830 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -676,14 +676,6 @@
 sim_objects = m5.SimObject.allClasses
 all_enums = m5.params.allEnums

-for name,obj in sorted(sim_objects.items()):
-for param in obj._params.local.values():
-# load the ptype attribute now because it depends on the
-# current version of SimObject.allClasses, but when scons
-# actually uses the value, all versions of
-# SimObject.allClasses will have been loaded
-param.ptype
-
 
 #
 # calculate extra dependencies

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/49390
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Id36887773d2fc1373ffe689ee1b50b4989bf5a38
Gerrit-Change-Number: 49390
Gerrit-PatchSet: 12
Gerrit-Owner: Gabe Black 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Hoa Nguyen 
Gerrit-Reviewer: kokoro 
Gerrit-MessageType: merged
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

[gem5-dev] Change in gem5/gem5[develop]: scons: Use source filters to exclude python source if --without-python.

2021-09-16 Thread Gabe Black (Gerrit) via gem5-dev
Gabe Black has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/49389 )




10 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the  
submitted one.
Change subject: scons: Use source filters to exclude python source if  
--without-python.

..

scons: Use source filters to exclude python source if --without-python.

We were simply not declaring the source files for PySource files if
built --without-python. Instead, we should declare them, but then
explicitly exclude them if that option is set.

Since we're already doing that, we can simply remove the check from the
PySource constructor.

Change-Id: I437ebeee1082fa00065bedd61f91d5721b915ae5
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49389
Maintainer: Gabe Black 
Tested-by: kokoro 
Reviewed-by: Hoa Nguyen 
---
M src/SConscript
1 file changed, 1 insertion(+), 2 deletions(-)

Approvals:
  Hoa Nguyen: Looks good to me, approved
  Gabe Black: Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/SConscript b/src/SConscript
index 2e48048..f4e59a8 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -176,8 +176,7 @@
 MakeAction(embedPyFile, Transform("EMBED PY"),
 varlist=overrides.keys()),
 **overrides)
-if main['USE_PYTHON']:
-Source(cpp, tags=self.tags, add_tags='python')
+Source(cpp, tags=self.tags, add_tags='python')

 class SimObject(PySource):
 '''Add a SimObject python file as a python source object and add

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/49389
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I437ebeee1082fa00065bedd61f91d5721b915ae5
Gerrit-Change-Number: 49389
Gerrit-PatchSet: 12
Gerrit-Owner: Gabe Black 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Hoa Nguyen 
Gerrit-Reviewer: kokoro 
Gerrit-MessageType: merged
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

[gem5-dev] Change in gem5/gem5[develop]: tests: Add a test for forking and switching cpus

2021-09-16 Thread Austin Harris (Gerrit) via gem5-dev
Austin Harris has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/50467 )



Change subject: tests: Add a test for forking and switching cpus
..

tests: Add a test for forking and switching cpus

This tests forking gem5 and simulating the child with a different cpu.
The test boots linux with the KVM cpu, tests instruction scheduling exit
events, and then forks gem5. The child simulation switches to the
specified cpu and simulates to completion while the parents waits for
the child to finish before also simulating to completion.

Change-Id: I68d7515bf125c855eefc62ba4798cd7c745ef2b0
---
A tests/gem5/configs/components-library/boot_kvm_fork_run.py
1 file changed, 300 insertions(+), 0 deletions(-)



diff --git a/tests/gem5/configs/components-library/boot_kvm_fork_run.py  
b/tests/gem5/configs/components-library/boot_kvm_fork_run.py

new file mode 100644
index 000..eaf3aabe
--- /dev/null
+++ b/tests/gem5/configs/components-library/boot_kvm_fork_run.py
@@ -0,0 +1,300 @@
+# Copyright (c) 2021 The University of Texas at Austin
+# 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.
+#
+# Author: Austin Harris
+#
+
+"""
+This script tests forking gem5 with the KVM cores and switching cores in  
the
+child process. First, the test boots linux with KVM and tests  
fast-forwarding
+with instruction exit events. Then the test forks the simulation, waits  
for the

+child to simulate until completion, and then simulates to completion in the
+parent process.
+"""
+
+import argparse
+import os
+import sys
+from textwrap import dedent
+
+import m5
+from m5.objects import Root
+
+# This is a lame hack to get the imports working correctly.
+# TODO: This needs fixed.
+sys.path.append(
+os.path.join(
+os.path.dirname(os.path.abspath(__file__)),
+os.pardir,
+os.pardir,
+os.pardir,
+os.pardir,
+)
+)
+
+from components_library.boards.x86_board import X86Board
+from components_library.coherence_protocol import CoherenceProtocol
+from components_library.isas import ISA
+from components_library.memory.single_channel import SingleChannelDDR3_1600
+from components_library.processors.cpu_types import CPUTypes
+from components_library.processors.simple_switchable_processor import (
+SimpleSwitchableProcessor,
+)
+from components_library.resources.resource import Resource
+from components_library.runtime import (
+get_runtime_coherence_protocol,
+get_runtime_isa
+)
+from components_library.utils.requires import requires
+
+parser = argparse.ArgumentParser(
+description="A script to test forking gem5 and switching cpus."
+)
+parser.add_argument(
+"-m",
+"--mem-system",
+type=str,
+choices=("classic", "mi_example", "mesi_two_level"),
+required=True,
+help="The memory system.",
+)
+parser.add_argument(
+"-n",
+"--num-cpus",
+type=int,
+choices=(1, 2, 4, 8),
+default=4,
+help="The number of CPUs.",
+)
+parser.add_argument(
+"-c",
+"--cpu",
+type=str,
+choices=("kvm", "atomic", "timing", "o3"),
+required=True,
+help="The CPU type.",
+)
+parser.add_argument(
+"-r",
+"--resource-directory",
+type=str,
+required=False,
+help="The directory in which resources will be downloaded or exist.",
+)
+parser.add_argument(
+"-o",
+"--override-download",
+action="store_true",
+help="Override a local resource if the hashes do not match.",
+)

[gem5-dev] Change in gem5/gem5[develop]: python: Fix broken call to m5.fatal in _check_tracing()

2021-09-16 Thread Richard Cooper (Gerrit) via gem5-dev
Richard Cooper has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/50447 )



Change subject: python: Fix broken call to m5.fatal in _check_tracing()
..

python: Fix broken call to m5.fatal in _check_tracing()

The call to m5.fatal in _check_tracing() fails because it has not been
imported at this point.

Change-Id: I60b1de6128d0ffc29e03e9ed98a8f9f679ef0ff9
---
M src/python/m5/main.py
1 file changed, 2 insertions(+), 1 deletion(-)



diff --git a/src/python/m5/main.py b/src/python/m5/main.py
index 92878af..64faba1 100644
--- a/src/python/m5/main.py
+++ b/src/python/m5/main.py
@@ -205,12 +205,13 @@


 def _check_tracing():
+import m5
 import _m5.core

 if _m5.core.TRACING_ON:
 return

-fatal("Tracing is not enabled.  Compile with TRACING_ON")
+m5.fatal("Tracing is not enabled.  Compile with TRACING_ON")

 def main(*args):
 import m5

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/50447
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I60b1de6128d0ffc29e03e9ed98a8f9f679ef0ff9
Gerrit-Change-Number: 50447
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Cooper 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

[gem5-dev] Change in gem5/gem5[develop]: scons: Re-enable TRACING_ON flag

2021-09-16 Thread Richard Cooper (Gerrit) via gem5-dev
Richard Cooper has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/50427 )


Change subject: scons: Re-enable TRACING_ON flag
..

scons: Re-enable TRACING_ON flag

The TRACING_ON flag was removed in a previous commit [1], but is still
used by the _check_tracing() function in main.py. This breaks gem5
simulations when debug flags are enabled.

This patch re-enables the TRACING_ON flag.

[1] https://gem5-review.googlesource.com/c/public/gem5/+/48379

Change-Id: I90ed8a46938fa2748b96c1b378329a4ba1ef047e
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/50427
Reviewed-by: Jason Lowe-Power 
Maintainer: Jason Lowe-Power 
Tested-by: kokoro 
---
M src/python/m5/main.py
M src/python/pybind11/core.cc
2 files changed, 4 insertions(+), 2 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/python/m5/main.py b/src/python/m5/main.py
index a4af295..92878af 100644
--- a/src/python/m5/main.py
+++ b/src/python/m5/main.py
@@ -205,9 +205,9 @@


 def _check_tracing():
-from . import defines
+import _m5.core

-if defines.TRACING_ON:
+if _m5.core.TRACING_ON:
 return

 fatal("Tracing is not enabled.  Compile with TRACING_ON")
diff --git a/src/python/pybind11/core.cc b/src/python/pybind11/core.cc
index 965160f..6fe2efd 100644
--- a/src/python/pybind11/core.cc
+++ b/src/python/pybind11/core.cc
@@ -289,6 +289,8 @@
 m_core.attr("compileDate") = py::cast(compileDate);
 m_core.attr("gem5Version") = py::cast(gem5Version);

+m_core.attr("TRACING_ON") = py::cast(TRACING_ON);
+
 m_core.attr("MaxTick") = py::cast(MaxTick);

 /*

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/50427
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I90ed8a46938fa2748b96c1b378329a4ba1ef047e
Gerrit-Change-Number: 50427
Gerrit-PatchSet: 2
Gerrit-Owner: Richard Cooper 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: Richard Cooper 
Gerrit-Reviewer: kokoro 
Gerrit-MessageType: merged
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

[gem5-dev] Change in gem5/gem5[develop]: python: Remove unnecessary Python 2.x workaround

2021-09-16 Thread Andreas Sandberg (Gerrit) via gem5-dev
Andreas Sandberg has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/50407 )


Change subject: python: Remove unnecessary Python 2.x workaround
..

python: Remove unnecessary Python 2.x workaround

We needed to explicitly cast the return value from getCode() to int to
avoid a Python 2.x issue where sys.exit() got confused by an
unexpected long argument. This isn't an issue in Python 3 since long
has been removed as a separate type.

Change-Id: I7770d0f180e826ac7e6c92c13bc6a61447e3f851
Signed-off-by: Andreas Sandberg 
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/50407
Reviewed-by: Jason Lowe-Power 
Maintainer: Jason Lowe-Power 
Tested-by: kokoro 
---
M src/python/pybind11/event.cc
1 file changed, 0 insertions(+), 11 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/python/pybind11/event.cc b/src/python/pybind11/event.cc
index 794b6e3..aefe50a 100644
--- a/src/python/pybind11/event.cc
+++ b/src/python/pybind11/event.cc
@@ -134,18 +134,7 @@
std::unique_ptr>(
m, "GlobalSimLoopExitEvent")
 .def("getCause", ::getCause)
-#if PY_MAJOR_VERSION >= 3
 .def("getCode", ::getCode)
-#else
-// Workaround for an issue where PyBind11 converts the exit
-// code to a long. This is normally fine, but sys.exit treats
-// any non-int type as an error and exits with status 1 if it
-// is passed a long.
-.def("getCode", [](GlobalSimLoopExitEvent *e) {
-return py::reinterpret_steal(
-PyInt_FromLong(e->getCode()));
-})
-#endif
 ;

 // Event base class. These should never be returned directly to

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/50407
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I7770d0f180e826ac7e6c92c13bc6a61447e3f851
Gerrit-Change-Number: 50407
Gerrit-PatchSet: 2
Gerrit-Owner: Andreas Sandberg 
Gerrit-Reviewer: Andreas Sandberg 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: kokoro 
Gerrit-MessageType: merged
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s