From cc32247ebc7e36fb039620fe9435d4ad70b8ba85 Mon Sep 17 00:00:00 2001 From: "Bobby R. Bruce" Date: Tue, 25 Feb 2020 16:10:25 -0800 Subject: [PATCH] tests: Migrated 40.m5threads-test-atomic scons tests to testlib At present, the 40.m5threads-test-atomic tests fail as the SPARC binary (generated from `tests/test-progs/pthread/src/test_atomic.cpp`) is not present. This has been noted in: https://gem5.atlassian.net/browse/GEM5-368 Change-Id: I7865826388be46cec06a201712081146a58518f2 Jira: https://gem5.atlassian.net/browse/GEM5-109 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/25824 Reviewed-by: Ayaz Akram Maintainer: Bobby R. Bruce Tested-by: kokoro --- tests/gem5/.testignore | 18 ++++ .../m5threads_test_atomic/atomic_system.py | 64 ++++++++++++++ .../ref/sparc/linux/simout | 84 +++++++++++++++++++ tests/gem5/m5threads_test_atomic/test.py | 58 +++++++++++++ 4 files changed, 224 insertions(+) create mode 100644 tests/gem5/m5threads_test_atomic/atomic_system.py create mode 100755 tests/gem5/m5threads_test_atomic/ref/sparc/linux/simout create mode 100644 tests/gem5/m5threads_test_atomic/test.py diff --git a/tests/gem5/.testignore b/tests/gem5/.testignore index 6d52d3fe7..cc61aa613 100644 --- a/tests/gem5/.testignore +++ b/tests/gem5/.testignore @@ -187,3 +187,21 @@ test-hello-linux-DerivO3CPU-MIPS-i386-opt test-hello-linux-TimingSimpleCPU-ALPHA-i386-opt test-hello-linux-AtomicSimpleCPU-ALPHA-i386-opt test-hello-linux-DerivO3CPU-ALPHA-i386-opt +test-atomic-DerivO3CPU-SPARC-x86_64-opt +test-atomic-TimingSimpleCPU-SPARC-x86_64-opt +test-atomic-DerivO3CPU-SPARC-x86_64-debug +test-atomic-TimingSimpleCPU-SPARC-x86_64-debug +test-atomic-DerivO3CPU-SPARC-x86_64-fast +test-atomic-TimingSimpleCPU-SPARC-x86_64-fast +test-atomic-DerivO3CPU-SPARC-arch64-opt +test-atomic-TimingSimpleCPU-SPARC-arch64-opt +test-atomic-DerivO3CPU-SPARC-arch64-debug +test-atomic-TimingSimpleCPU-SPARC-arch64-debug +test-atomic-DerivO3CPU-SPARC-arch64-fast +test-atomic-TimingSimpleCPU-SPARC-arch64-fast +test-atomic-DerivO3CPU-SPARC-i386-opt +test-atomic-TimingSimpleCPU-SPARC-i386-opt +test-atomic-DerivO3CPU-SPARC-i386-debug +test-atomic-TimingSimpleCPU-SPARC-i386-debug +test-atomic-DerivO3CPU-SPARC-i386-fast +test-atomic-TimingSimpleCPU-SPARC-i386-fast diff --git a/tests/gem5/m5threads_test_atomic/atomic_system.py b/tests/gem5/m5threads_test_atomic/atomic_system.py new file mode 100644 index 000000000..2f4ae8ed7 --- /dev/null +++ b/tests/gem5/m5threads_test_atomic/atomic_system.py @@ -0,0 +1,64 @@ +# Copyright (c) 2020 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. + +import m5 +from m5.objects import * +import sys +import argparse + +parser = argparse.ArgumentParser(description='m5threads atomic tester') +parser.add_argument('--cpu-type', default='DerivO3CPU') +parser.add_argument('--num-cores', default='8') +parser.add_argument('--cmd') + +args = parser.parse_args() + +root = Root(full_system = False) +root.system = System() + +root.system.clk_domain = SrcClockDomain() +root.system.clk_domain.clock = '3GHz' +root.system.clk_domain.voltage_domain = VoltageDomain() +root.system.mem_mode = 'timing' + +if args.cpu_type == 'DerivO3CPU': + root.system.cpu = [DerivO3CPU(cpu_id = i) + for i in range (int(args.num_cores))] +elif args.cpu_type == 'TimingSimpleCPU': + root.system.cpu = [TimingSimpleCPU(cpu_id=i) + for i in range(int(args.num_cores))] +else: + print("ERROR: CPU Type '" + args.cpu_type + "' not supported") + sys.exit(1) + +process = Process(executable = args.cmd, + cmd = [args.cmd, str(args.num_cores)]) + +for i in range(int(args.num_cores)): + root.system.cpu[i].workload = process + +m5.instantiate() +exit_event = m5.simulate() diff --git a/tests/gem5/m5threads_test_atomic/ref/sparc/linux/simout b/tests/gem5/m5threads_test_atomic/ref/sparc/linux/simout new file mode 100755 index 000000000..7ee3ff550 --- /dev/null +++ b/tests/gem5/m5threads_test_atomic/ref/sparc/linux/simout @@ -0,0 +1,84 @@ +Redirecting stdout to build/SPARC/tests/opt/quick/se/40.m5threads-test-atomic/sparc/linux/o3-timing-mp/simout +Redirecting stderr to build/SPARC/tests/opt/quick/se/40.m5threads-test-atomic/sparc/linux/o3-timing-mp/simerr +gem5 Simulator System. http://gem5.org +gem5 is copyrighted software; use the --copyright option for details. + +gem5 compiled Mar 29 2017 21:12:17 +gem5 started Mar 29 2017 21:12:27 +gem5 executing on gabeblack-desktop.mtv.corp.google.com, pid 42630 +command line: /usr/local/google/home/gabeblack/gem5/gem5-public/build/SPARC/gem5.opt -d build/SPARC/tests/opt/quick/se/40.m5threads-test-atomic/sparc/linux/o3-timing-mp --stats-file 'text://stats.txt?desc=False' -re /usr/local/google/home/gabeblack/gem5/gem5-public/tests/testing/../run.py quick/se/40.m5threads-test-atomic/sparc/linux/o3-timing-mp + +Global frequency set at 1000000000000 ticks per second +Init done +[Iteration 1, Thread 1] Got lock +[Iteration 1, Thread 1] Critical section done, previously next=0, now next=1 +[Iteration 1, Thread 3] Got lock +[Iteration 1, Thread 3] Critical section done, previously next=1, now next=3 +[Iteration 1, Thread 2] Got lock +[Iteration 1, Thread 2] Critical section done, previously next=3, now next=2 +Iteration 1 completed +[Iteration 2, Thread 3] Got lock +[Iteration 2, Thread 3] Critical section done, previously next=0, now next=3 +[Iteration 2, Thread 2] Got lock +[Iteration 2, Thread 2] Critical section done, previously next=3, now next=2 +[Iteration 2, Thread 1] Got lock +[Iteration 2, Thread 1] Critical section done, previously next=2, now next=1 +Iteration 2 completed +[Iteration 3, Thread 2] Got lock +[Iteration 3, Thread 2] Critical section done, previously next=0, now next=2 +[Iteration 3, Thread 3] Got lock +[Iteration 3, Thread 3] Critical section done, previously next=2, now next=3 +[Iteration 3, Thread 1] Got lock +[Iteration 3, Thread 1] Critical section done, previously next=3, now next=1 +Iteration 3 completed +[Iteration 4, Thread 1] Got lock +[Iteration 4, Thread 1] Critical section done, previously next=0, now next=1 +[Iteration 4, Thread 3] Got lock +[Iteration 4, Thread 3] Critical section done, previously next=1, now next=3 +[Iteration 4, Thread 2] Got lock +[Iteration 4, Thread 2] Critical section done, previously next=3, now next=2 +Iteration 4 completed +[Iteration 5, Thread 1] Got lock +[Iteration 5, Thread 1] Critical section done, previously next=0, now next=1 +[Iteration 5, Thread 2] Got lock +[Iteration 5, Thread 2] Critical section done, previously next=1, now next=2 +[Iteration 5, Thread 3] Got lock +[Iteration 5, Thread 3] Critical section done, previously next=2, now next=3 +Iteration 5 completed +[Iteration 6, Thread 3] Got lock +[Iteration 6, Thread 3] Critical section done, previously next=0, now next=3 +[Iteration 6, Thread 2] Got lock +[Iteration 6, Thread 2] Critical section done, previously next=3, now next=2 +[Iteration 6, Thread 1] Got lock +[Iteration 6, Thread 1] Critical section done, previously next=2, now next=1 +Iteration 6 completed +[Iteration 7, Thread 3] Got lock +[Iteration 7, Thread 3] Critical section done, previously next=0, now next=3 +[Iteration 7, Thread 2] Got lock +[Iteration 7, Thread 2] Critical section done, previously next=3, now next=2 +[Iteration 7, Thread 1] Got lock +[Iteration 7, Thread 1] Critical section done, previously next=2, now next=1 +Iteration 7 completed +[Iteration 8, Thread 3] Got lock +[Iteration 8, Thread 3] Critical section done, previously next=0, now next=3 +[Iteration 8, Thread 2] Got lock +[Iteration 8, Thread 2] Critical section done, previously next=3, now next=2 +[Iteration 8, Thread 1] Got lock +[Iteration 8, Thread 1] Critical section done, previously next=2, now next=1 +Iteration 8 completed +[Iteration 9, Thread 1] Got lock +[Iteration 9, Thread 1] Critical section done, previously next=0, now next=1 +[Iteration 9, Thread 2] Got lock +[Iteration 9, Thread 2] Critical section done, previously next=1, now next=2 +[Iteration 9, Thread 3] Got lock +[Iteration 9, Thread 3] Critical section done, previously next=2, now next=3 +Iteration 9 completed +[Iteration 10, Thread 3] Got lock +[Iteration 10, Thread 3] Critical section done, previously next=0, now next=3 +[Iteration 10, Thread 2] Got lock +[Iteration 10, Thread 2] Critical section done, previously next=3, now next=2 +[Iteration 10, Thread 1] Got lock +[Iteration 10, Thread 1] Critical section done, previously next=2, now next=1 +Iteration 10 completed +PASSED :-) +Exiting @ tick 126524000 because exiting with last active thread context diff --git a/tests/gem5/m5threads_test_atomic/test.py b/tests/gem5/m5threads_test_atomic/test.py new file mode 100644 index 000000000..64af6364c --- /dev/null +++ b/tests/gem5/m5threads_test_atomic/test.py @@ -0,0 +1,58 @@ +# Copyright (c) 2020 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. + +''' +Test file for the m5threads atomic test +''' +from testlib import * + +cpu_types = ('DerivO3CPU', 'TimingSimpleCPU') + +if config.bin_path: + base_path = config.bin_path +else: + base_path = joinpath(absdirpath(__file__), '..', 'test-progs', + 'test_atomic', 'bin') + +binary = 'test_atomic' +url = 'http://dist.gem5.org/dist/current/test-progs/pthread/bin/' + binary +DownloadedProgram(url, base_path, binary) + +verifiers = ( + verifier.MatchStdoutNoPerf(joinpath(getcwd(), 'ref/sparc/linux/simout')), +) + +for cpu in cpu_types: + gem5_verify_config( + name='test-atomic-' + cpu, + verifiers=verifiers, + config=joinpath(getcwd(), 'atomic_system.py'), + config_args=['--cpu-type', cpu, + '--num-cores', '8', + '--cmd', joinpath(base_path, binary)], + valid_isas=('SPARC',), + valid_hosts=constants.supported_hosts, + ) -- 2.30.2