dist_bigLITTLE.py revision 11845:afd6aaee268e
1# Copyright (c) 2016 ARM Limited
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder.  You may use the software subject to the license
9# terms below provided that you ensure that this notice is replicated
10# unmodified and in its entirety in all distributions of the software,
11# modified or unmodified, in source code or in binary form.
12#
13# Redistribution and use in source and binary forms, with or without
14# modification, are permitted provided that the following conditions are
15# met: redistributions of source code must retain the above copyright
16# notice, this list of conditions and the following disclaimer;
17# redistributions in binary form must reproduce the above copyright
18# notice, this list of conditions and the following disclaimer in the
19# documentation and/or other materials provided with the distribution;
20# neither the name of the copyright holders nor the names of its
21# contributors may be used to endorse or promote products derived from
22# this software without specific prior written permission.
23#
24# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35#
36# Authors: Gabor Dozsa
37
38# This configuration file extends the example ARM big.LITTLE(tm)
39# configuration to enabe dist-gem5 siulations of big.LITTLE systems.
40
41import argparse
42import os
43
44import m5
45from m5.objects import *
46
47import fs_bigLITTLE as bL
48m5.util.addToPath("../../dist")
49import sw
50
51
52def addOptions(parser):
53   # Options for distributed simulation (i.e. dist-gem5)
54    parser.add_argument("--dist", action="store_true", help="Distributed gem5"\
55                      " simulation.")
56    parser.add_argument("--is-switch", action="store_true",
57                        help="Select the network switch simulator process for"\
58                      " a distributed gem5 run.")
59    parser.add_argument("--dist-rank", default=0, action="store", type=int,
60                      help="Rank of this system within the dist gem5 run.")
61    parser.add_argument("--dist-size", default=0, action="store", type=int,
62                      help="Number of gem5 processes within the dist gem5"\
63                      " run.")
64    parser.add_argument("--dist-server-name",
65                      default="127.0.0.1",
66                      action="store", type=str,
67                      help="Name of the message server host\nDEFAULT:"\
68                      " localhost")
69    parser.add_argument("--dist-server-port",
70                      default=2200,
71                      action="store", type=int,
72                      help="Message server listen port\nDEFAULT: 2200")
73    parser.add_argument("--dist-sync-repeat",
74                      default="0us",
75                      action="store", type=str,
76                      help="Repeat interval for synchronisation barriers"\
77                      " among dist-gem5 processes\nDEFAULT:"\
78                      " --ethernet-linkdelay")
79    parser.add_argument("--dist-sync-start",
80                      default="1000000000000t",
81                      action="store", type=str,
82                      help="Time to schedule the first dist synchronisation"\
83                      " barrier\nDEFAULT:1000000000000t")
84    parser.add_argument("--ethernet-linkspeed", default="10Gbps",
85                        action="store", type=str,
86                        help="Link speed in bps\nDEFAULT: 10Gbps")
87    parser.add_argument("--ethernet-linkdelay", default="10us",
88                      action="store", type=str,
89                      help="Link delay in seconds\nDEFAULT: 10us")
90    parser.add_argument("--etherdump", action="store", type=str, default="",
91                        help="Specify the filename to dump a pcap capture of"\
92                        " the ethernet traffic")
93    # Used by util/dist/gem5-dist.sh
94    parser.add_argument("--checkpoint-dir", type=str,
95                        default=m5.options.outdir,
96                        help="Directory to save/read checkpoints")
97
98
99def addEthernet(system, options):
100    # create NIC
101    dev = IGbE_e1000()
102    system.attach_pci(dev)
103    system.ethernet = dev
104
105    # create distributed ethernet link
106    system.etherlink = DistEtherLink(speed = options.ethernet_linkspeed,
107                                     delay = options.ethernet_linkdelay,
108                                     dist_rank = options.dist_rank,
109                                     dist_size = options.dist_size,
110                                     server_name = options.dist_server_name,
111                                     server_port = options.dist_server_port,
112                                     sync_start = options.dist_sync_start,
113                                     sync_repeat = options.dist_sync_repeat)
114    system.etherlink.int0 = Parent.system.ethernet.interface
115    if options.etherdump:
116        system.etherdump = EtherDump(file=options.etherdump)
117        system.etherlink.dump = system.etherdump
118
119
120def main():
121    parser = argparse.ArgumentParser(
122        description="Generic ARM big.LITTLE configuration with "\
123        "dist-gem5 support")
124    bL.addOptions(parser)
125    addOptions(parser)
126    options = parser.parse_args()
127
128    if options.is_switch:
129        root = Root(full_system = True,
130                    system = sw.build_switch(options))
131    else:
132        root = bL.build(options)
133        addEthernet(root.system, options)
134
135    if options.restore_from:
136        checkpoint_path = os.path.join(options.checkpoint_dir,
137                                       options.restore_from)
138    else:
139        checkpoint_path = None
140    bL.instantiate(checkpoint_path)
141    bL.run(options.checkpoint_dir)
142
143
144if __name__ == "__m5_main__":
145    main()
146