fs.py (3133:ad45cbafebdd) fs.py (3143:76c70c8bc5c8)
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: Ali Saidi
28
29import optparse, os, sys
30
31import m5
32from m5.objects import *
33m5.AddToPath('../common')
34from FSConfig import *
35from SysPaths import *
36from Benchmarks import *
37
38if not m5.build_env['FULL_SYSTEM']:
39 m5.panic("This script requires full-system mode (ALPHA_FS).")
40
41parser = optparse.OptionParser()
42
43parser.add_option("-d", "--detailed", action="store_true")
44parser.add_option("-t", "--timing", action="store_true")
45parser.add_option("-m", "--maxtick", type="int")
46parser.add_option("--maxtime", type="float")
47parser.add_option("--dual", action="store_true",
48 help="Simulate two systems attached with an ethernet link")
49parser.add_option("-b", "--benchmark", action="store", type="string",
50 dest="benchmark",
51 help="Specify the benchmark to run. Available benchmarks: %s"\
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: Ali Saidi
28
29import optparse, os, sys
30
31import m5
32from m5.objects import *
33m5.AddToPath('../common')
34from FSConfig import *
35from SysPaths import *
36from Benchmarks import *
37
38if not m5.build_env['FULL_SYSTEM']:
39 m5.panic("This script requires full-system mode (ALPHA_FS).")
40
41parser = optparse.OptionParser()
42
43parser.add_option("-d", "--detailed", action="store_true")
44parser.add_option("-t", "--timing", action="store_true")
45parser.add_option("-m", "--maxtick", type="int")
46parser.add_option("--maxtime", type="float")
47parser.add_option("--dual", action="store_true",
48 help="Simulate two systems attached with an ethernet link")
49parser.add_option("-b", "--benchmark", action="store", type="string",
50 dest="benchmark",
51 help="Specify the benchmark to run. Available benchmarks: %s"\
52 % DefinedBenchmarks)
52 % DefinedBenchmarks)
53parser.add_option("--etherdump", action="store", type="string", dest="etherdump",
53parser.add_option("--etherdump", action="store", type="string", dest="etherdump",
54 help="Specify the filename to dump a pcap capture of the ethernet"
55 "traffic")
54 help="Specify the filename to dump a pcap capture of the" \
55 "ethernet traffic")
56parser.add_option("--checkpoint_dir", action="store", type="string",
57 help="Place all checkpoints in this absolute directory")
56
57(options, args) = parser.parse_args()
58
59if args:
60 print "Error: script doesn't take any positional arguments"
61 sys.exit(1)
62
63if options.detailed:
64 cpu = DetailedO3CPU()
65 cpu2 = DetailedO3CPU()
66 mem_mode = 'timing'
67elif options.timing:
68 cpu = TimingSimpleCPU()
69 cpu2 = TimingSimpleCPU()
70 mem_mode = 'timing'
71else:
72 cpu = AtomicSimpleCPU()
73 cpu2 = AtomicSimpleCPU()
74 mem_mode = 'atomic'
75
76cpu.clock = '2GHz'
77cpu2.clock = '2GHz'
78
79if options.benchmark:
80 if options.benchmark not in Benchmarks:
81 print "Error benchmark %s has not been defined." % options.benchmark
82 print "Valid benchmarks are: %s" % DefinedBenchmarks
83 sys.exit(1)
84
85 bm = Benchmarks[options.benchmark]
86else:
87 if options.dual:
88 bm = [Machine(), Machine()]
89 else:
90 bm = [Machine()]
91
92if len(bm) == 2:
93 s1 = makeLinuxAlphaSystem(mem_mode, bm[0])
94 s1.cpu = cpu
95 cpu.connectMemPorts(s1.membus)
96 cpu.mem = s1.physmem
97 s2 = makeLinuxAlphaSystem(mem_mode, bm[1])
98 s2.cpu = cpu2
99 cpu2.connectMemPorts(s2.membus)
100 cpu2.mem = s2.physmem
101 root = makeDualRoot(s1, s2, options.etherdump)
102elif len(bm) == 1:
103 root = Root(clock = '1THz',
104 system = makeLinuxAlphaSystem(mem_mode, bm[0]))
105 root.system.cpu = cpu
106 cpu.connectMemPorts(root.system.membus)
107 cpu.mem = root.system.physmem
108else:
109 print "Error I don't know how to create more than 2 systems."
110 sys.exit(1)
111
112m5.instantiate(root)
113
114if options.maxtick:
115 maxtick = options.maxtick
116elif options.maxtime:
117 simtime = int(options.maxtime * root.clock.value)
118 print "simulating for: ", simtime
119 maxtick = simtime
120else:
121 maxtick = -1
122
123exit_event = m5.simulate(maxtick)
124
125while exit_event.getCause() == "checkpoint":
58
59(options, args) = parser.parse_args()
60
61if args:
62 print "Error: script doesn't take any positional arguments"
63 sys.exit(1)
64
65if options.detailed:
66 cpu = DetailedO3CPU()
67 cpu2 = DetailedO3CPU()
68 mem_mode = 'timing'
69elif options.timing:
70 cpu = TimingSimpleCPU()
71 cpu2 = TimingSimpleCPU()
72 mem_mode = 'timing'
73else:
74 cpu = AtomicSimpleCPU()
75 cpu2 = AtomicSimpleCPU()
76 mem_mode = 'atomic'
77
78cpu.clock = '2GHz'
79cpu2.clock = '2GHz'
80
81if options.benchmark:
82 if options.benchmark not in Benchmarks:
83 print "Error benchmark %s has not been defined." % options.benchmark
84 print "Valid benchmarks are: %s" % DefinedBenchmarks
85 sys.exit(1)
86
87 bm = Benchmarks[options.benchmark]
88else:
89 if options.dual:
90 bm = [Machine(), Machine()]
91 else:
92 bm = [Machine()]
93
94if len(bm) == 2:
95 s1 = makeLinuxAlphaSystem(mem_mode, bm[0])
96 s1.cpu = cpu
97 cpu.connectMemPorts(s1.membus)
98 cpu.mem = s1.physmem
99 s2 = makeLinuxAlphaSystem(mem_mode, bm[1])
100 s2.cpu = cpu2
101 cpu2.connectMemPorts(s2.membus)
102 cpu2.mem = s2.physmem
103 root = makeDualRoot(s1, s2, options.etherdump)
104elif len(bm) == 1:
105 root = Root(clock = '1THz',
106 system = makeLinuxAlphaSystem(mem_mode, bm[0]))
107 root.system.cpu = cpu
108 cpu.connectMemPorts(root.system.membus)
109 cpu.mem = root.system.physmem
110else:
111 print "Error I don't know how to create more than 2 systems."
112 sys.exit(1)
113
114m5.instantiate(root)
115
116if options.maxtick:
117 maxtick = options.maxtick
118elif options.maxtime:
119 simtime = int(options.maxtime * root.clock.value)
120 print "simulating for: ", simtime
121 maxtick = simtime
122else:
123 maxtick = -1
124
125exit_event = m5.simulate(maxtick)
126
127while exit_event.getCause() == "checkpoint":
126 m5.checkpoint(root, "cpt.%d")
128 if options.checkpoint_dir:
129 m5.checkpoint(root, "/".join([options.checkpoint_dir, "cpt.%d"]))
130 else:
131 m5.checkpoint(root, "cpt.%d")
132
127 if maxtick == -1:
128 exit_event = m5.simulate(maxtick)
129 else:
130 exit_event = m5.simulate(maxtick - m5.curTick())
131
132print 'Exiting @ cycle', m5.curTick(), 'because', exit_event.getCause()
133 if maxtick == -1:
134 exit_event = m5.simulate(maxtick)
135 else:
136 exit_event = m5.simulate(maxtick - m5.curTick())
137
138print 'Exiting @ cycle', m5.curTick(), 'because', exit_event.getCause()