se.py (3180:664fe611de8e) se.py (3223:a2b6fa575c05)
1# Copyright (c) 2006 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright
9# notice, this list of conditions and the following disclaimer in the
10# documentation and/or other materials provided with the distribution;
11# neither the name of the copyright holders nor the names of its
12# contributors may be used to endorse or promote products derived from
13# this software without specific prior written permission.
14#
15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26#
27# Authors: Steve Reinhardt
28
29# Simple test script
30#
31# "m5 test.py"
32
33import m5
34from m5.objects import *
35import os, optparse, sys
36m5.AddToPath('../common')
1# Copyright (c) 2006 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright
9# notice, this list of conditions and the following disclaimer in the
10# documentation and/or other materials provided with the distribution;
11# neither the name of the copyright holders nor the names of its
12# contributors may be used to endorse or promote products derived from
13# this software without specific prior written permission.
14#
15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26#
27# Authors: Steve Reinhardt
28
29# Simple test script
30#
31# "m5 test.py"
32
33import m5
34from m5.objects import *
35import os, optparse, sys
36m5.AddToPath('../common')
37from FullO3Config import *
38
39parser = optparse.OptionParser()
40
41parser.add_option("-c", "--cmd",
42 default="../../tests/test-progs/hello/bin/alpha/linux/hello",
43 help="The binary to run in syscall emulation mode.")
44parser.add_option("-o", "--options", default="",
45 help="The options to pass to the binary, use \" \" around the entire\
46 string.")
47parser.add_option("-i", "--input", default="",
48 help="A file of input to give to the binary.")
49parser.add_option("-d", "--detailed", action="store_true")
50parser.add_option("-t", "--timing", action="store_true")
51parser.add_option("-m", "--maxtick", type="int")
52
53(options, args) = parser.parse_args()
54
55if args:
56 print "Error: script doesn't take any positional arguments"
57 sys.exit(1)
58
59process = LiveProcess()
60process.executable = options.cmd
61process.cmd = options.cmd + " " + options.options
62if options.input != "":
63 process.input = options.input
64
65if options.detailed:
66 #check for SMT workload
67 workloads = options.cmd.split(';')
68 if len(workloads) > 1:
69 process = []
70 smt_idx = 0
71 inputs = []
72
73 if options.input != "":
74 inputs = options.input.split(';')
75
76 for wrkld in workloads:
77 smt_process = LiveProcess()
78 smt_process.executable = wrkld
79 smt_process.cmd = wrkld + " " + options.options
80 if inputs and inputs[smt_idx]:
81 smt_process.input = inputs[smt_idx]
82 process += [smt_process, ]
83 smt_idx += 1
84
85
86if options.timing:
87 cpu = TimingSimpleCPU()
88elif options.detailed:
37
38parser = optparse.OptionParser()
39
40parser.add_option("-c", "--cmd",
41 default="../../tests/test-progs/hello/bin/alpha/linux/hello",
42 help="The binary to run in syscall emulation mode.")
43parser.add_option("-o", "--options", default="",
44 help="The options to pass to the binary, use \" \" around the entire\
45 string.")
46parser.add_option("-i", "--input", default="",
47 help="A file of input to give to the binary.")
48parser.add_option("-d", "--detailed", action="store_true")
49parser.add_option("-t", "--timing", action="store_true")
50parser.add_option("-m", "--maxtick", type="int")
51
52(options, args) = parser.parse_args()
53
54if args:
55 print "Error: script doesn't take any positional arguments"
56 sys.exit(1)
57
58process = LiveProcess()
59process.executable = options.cmd
60process.cmd = options.cmd + " " + options.options
61if options.input != "":
62 process.input = options.input
63
64if options.detailed:
65 #check for SMT workload
66 workloads = options.cmd.split(';')
67 if len(workloads) > 1:
68 process = []
69 smt_idx = 0
70 inputs = []
71
72 if options.input != "":
73 inputs = options.input.split(';')
74
75 for wrkld in workloads:
76 smt_process = LiveProcess()
77 smt_process.executable = wrkld
78 smt_process.cmd = wrkld + " " + options.options
79 if inputs and inputs[smt_idx]:
80 smt_process.input = inputs[smt_idx]
81 process += [smt_process, ]
82 smt_idx += 1
83
84
85if options.timing:
86 cpu = TimingSimpleCPU()
87elif options.detailed:
89 cpu = DetailedO3CPU()
88 cpu = DerivO3CPU()
90else:
91 cpu = AtomicSimpleCPU()
92
93cpu.workload = process
89else:
90 cpu = AtomicSimpleCPU()
91
92cpu.workload = process
94cpu.cpu_id = 0
95
96system = System(cpu = cpu,
97 physmem = PhysicalMemory(),
98 membus = Bus())
99system.physmem.port = system.membus.port
100system.cpu.connectMemPorts(system.membus)
101system.cpu.mem = system.physmem
102
103root = Root(system = system)
104
105if options.timing or options.detailed:
106 root.system.mem_mode = 'timing'
107
108# instantiate configuration
109m5.instantiate(root)
110
111# simulate until program terminates
112if options.maxtick:
113 exit_event = m5.simulate(options.maxtick)
114else:
115 exit_event = m5.simulate()
116
117print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
118
93
94system = System(cpu = cpu,
95 physmem = PhysicalMemory(),
96 membus = Bus())
97system.physmem.port = system.membus.port
98system.cpu.connectMemPorts(system.membus)
99system.cpu.mem = system.physmem
100
101root = Root(system = system)
102
103if options.timing or options.detailed:
104 root.system.mem_mode = 'timing'
105
106# instantiate configuration
107m5.instantiate(root)
108
109# simulate until program terminates
110if options.maxtick:
111 exit_event = m5.simulate(options.maxtick)
112else:
113 exit_event = m5.simulate()
114
115print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
116