111935Sandreas.sandberg@arm.com# Copyright (c) 2016-2017 ARM Limited
211845Sgabor.dozsa@arm.com# All rights reserved.
311845Sgabor.dozsa@arm.com#
411845Sgabor.dozsa@arm.com# The license below extends only to copyright in the software and shall
511845Sgabor.dozsa@arm.com# not be construed as granting a license to any other intellectual
611845Sgabor.dozsa@arm.com# property including but not limited to intellectual property relating
711845Sgabor.dozsa@arm.com# to a hardware implementation of the functionality of the software
811845Sgabor.dozsa@arm.com# licensed hereunder.  You may use the software subject to the license
911845Sgabor.dozsa@arm.com# terms below provided that you ensure that this notice is replicated
1011845Sgabor.dozsa@arm.com# unmodified and in its entirety in all distributions of the software,
1111845Sgabor.dozsa@arm.com# modified or unmodified, in source code or in binary form.
1211845Sgabor.dozsa@arm.com#
1311845Sgabor.dozsa@arm.com# Redistribution and use in source and binary forms, with or without
1411845Sgabor.dozsa@arm.com# modification, are permitted provided that the following conditions are
1511845Sgabor.dozsa@arm.com# met: redistributions of source code must retain the above copyright
1611845Sgabor.dozsa@arm.com# notice, this list of conditions and the following disclaimer;
1711845Sgabor.dozsa@arm.com# redistributions in binary form must reproduce the above copyright
1811845Sgabor.dozsa@arm.com# notice, this list of conditions and the following disclaimer in the
1911845Sgabor.dozsa@arm.com# documentation and/or other materials provided with the distribution;
2011845Sgabor.dozsa@arm.com# neither the name of the copyright holders nor the names of its
2111845Sgabor.dozsa@arm.com# contributors may be used to endorse or promote products derived from
2211845Sgabor.dozsa@arm.com# this software without specific prior written permission.
2311845Sgabor.dozsa@arm.com#
2411845Sgabor.dozsa@arm.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2511845Sgabor.dozsa@arm.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2611845Sgabor.dozsa@arm.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2711845Sgabor.dozsa@arm.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2811845Sgabor.dozsa@arm.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2911845Sgabor.dozsa@arm.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3011845Sgabor.dozsa@arm.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3111845Sgabor.dozsa@arm.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3211845Sgabor.dozsa@arm.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3311845Sgabor.dozsa@arm.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3411845Sgabor.dozsa@arm.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3511845Sgabor.dozsa@arm.com#
3611845Sgabor.dozsa@arm.com# Authors: Gabor Dozsa
3711845Sgabor.dozsa@arm.com
3811845Sgabor.dozsa@arm.com# This configuration file extends the example ARM big.LITTLE(tm)
3911845Sgabor.dozsa@arm.com# configuration to enabe dist-gem5 siulations of big.LITTLE systems.
4011845Sgabor.dozsa@arm.com
4113774Sandreas.sandberg@arm.comfrom __future__ import print_function
4213774Sandreas.sandberg@arm.comfrom __future__ import absolute_import
4313774Sandreas.sandberg@arm.com
4411845Sgabor.dozsa@arm.comimport argparse
4511845Sgabor.dozsa@arm.comimport os
4611845Sgabor.dozsa@arm.com
4711845Sgabor.dozsa@arm.comimport m5
4811845Sgabor.dozsa@arm.comfrom m5.objects import *
4911845Sgabor.dozsa@arm.com
5011845Sgabor.dozsa@arm.comimport fs_bigLITTLE as bL
5111845Sgabor.dozsa@arm.comm5.util.addToPath("../../dist")
5211845Sgabor.dozsa@arm.comimport sw
5311845Sgabor.dozsa@arm.com
5411845Sgabor.dozsa@arm.com
5511845Sgabor.dozsa@arm.comdef addOptions(parser):
5611845Sgabor.dozsa@arm.com   # Options for distributed simulation (i.e. dist-gem5)
5711845Sgabor.dozsa@arm.com    parser.add_argument("--dist", action="store_true", help="Distributed gem5"\
5811845Sgabor.dozsa@arm.com                      " simulation.")
5911845Sgabor.dozsa@arm.com    parser.add_argument("--is-switch", action="store_true",
6011845Sgabor.dozsa@arm.com                        help="Select the network switch simulator process for"\
6111845Sgabor.dozsa@arm.com                      " a distributed gem5 run.")
6211845Sgabor.dozsa@arm.com    parser.add_argument("--dist-rank", default=0, action="store", type=int,
6311845Sgabor.dozsa@arm.com                      help="Rank of this system within the dist gem5 run.")
6411845Sgabor.dozsa@arm.com    parser.add_argument("--dist-size", default=0, action="store", type=int,
6511845Sgabor.dozsa@arm.com                      help="Number of gem5 processes within the dist gem5"\
6611845Sgabor.dozsa@arm.com                      " run.")
6711845Sgabor.dozsa@arm.com    parser.add_argument("--dist-server-name",
6811845Sgabor.dozsa@arm.com                      default="127.0.0.1",
6911845Sgabor.dozsa@arm.com                      action="store", type=str,
7011845Sgabor.dozsa@arm.com                      help="Name of the message server host\nDEFAULT:"\
7111845Sgabor.dozsa@arm.com                      " localhost")
7211845Sgabor.dozsa@arm.com    parser.add_argument("--dist-server-port",
7311845Sgabor.dozsa@arm.com                      default=2200,
7411845Sgabor.dozsa@arm.com                      action="store", type=int,
7511845Sgabor.dozsa@arm.com                      help="Message server listen port\nDEFAULT: 2200")
7611845Sgabor.dozsa@arm.com    parser.add_argument("--dist-sync-repeat",
7711845Sgabor.dozsa@arm.com                      default="0us",
7811845Sgabor.dozsa@arm.com                      action="store", type=str,
7911845Sgabor.dozsa@arm.com                      help="Repeat interval for synchronisation barriers"\
8011845Sgabor.dozsa@arm.com                      " among dist-gem5 processes\nDEFAULT:"\
8111845Sgabor.dozsa@arm.com                      " --ethernet-linkdelay")
8211845Sgabor.dozsa@arm.com    parser.add_argument("--dist-sync-start",
8311845Sgabor.dozsa@arm.com                      default="1000000000000t",
8411845Sgabor.dozsa@arm.com                      action="store", type=str,
8511845Sgabor.dozsa@arm.com                      help="Time to schedule the first dist synchronisation"\
8611845Sgabor.dozsa@arm.com                      " barrier\nDEFAULT:1000000000000t")
8711845Sgabor.dozsa@arm.com    parser.add_argument("--ethernet-linkspeed", default="10Gbps",
8811845Sgabor.dozsa@arm.com                        action="store", type=str,
8911845Sgabor.dozsa@arm.com                        help="Link speed in bps\nDEFAULT: 10Gbps")
9011845Sgabor.dozsa@arm.com    parser.add_argument("--ethernet-linkdelay", default="10us",
9111845Sgabor.dozsa@arm.com                      action="store", type=str,
9211845Sgabor.dozsa@arm.com                      help="Link delay in seconds\nDEFAULT: 10us")
9311845Sgabor.dozsa@arm.com    parser.add_argument("--etherdump", action="store", type=str, default="",
9411845Sgabor.dozsa@arm.com                        help="Specify the filename to dump a pcap capture of"\
9511845Sgabor.dozsa@arm.com                        " the ethernet traffic")
9611845Sgabor.dozsa@arm.com    # Used by util/dist/gem5-dist.sh
9711845Sgabor.dozsa@arm.com    parser.add_argument("--checkpoint-dir", type=str,
9811845Sgabor.dozsa@arm.com                        default=m5.options.outdir,
9911845Sgabor.dozsa@arm.com                        help="Directory to save/read checkpoints")
10011845Sgabor.dozsa@arm.com
10111845Sgabor.dozsa@arm.com
10211845Sgabor.dozsa@arm.comdef addEthernet(system, options):
10311845Sgabor.dozsa@arm.com    # create NIC
10411845Sgabor.dozsa@arm.com    dev = IGbE_e1000()
10511845Sgabor.dozsa@arm.com    system.attach_pci(dev)
10611845Sgabor.dozsa@arm.com    system.ethernet = dev
10711845Sgabor.dozsa@arm.com
10811845Sgabor.dozsa@arm.com    # create distributed ethernet link
10911845Sgabor.dozsa@arm.com    system.etherlink = DistEtherLink(speed = options.ethernet_linkspeed,
11011845Sgabor.dozsa@arm.com                                     delay = options.ethernet_linkdelay,
11111845Sgabor.dozsa@arm.com                                     dist_rank = options.dist_rank,
11211845Sgabor.dozsa@arm.com                                     dist_size = options.dist_size,
11311845Sgabor.dozsa@arm.com                                     server_name = options.dist_server_name,
11411845Sgabor.dozsa@arm.com                                     server_port = options.dist_server_port,
11511845Sgabor.dozsa@arm.com                                     sync_start = options.dist_sync_start,
11611845Sgabor.dozsa@arm.com                                     sync_repeat = options.dist_sync_repeat)
11711845Sgabor.dozsa@arm.com    system.etherlink.int0 = Parent.system.ethernet.interface
11811845Sgabor.dozsa@arm.com    if options.etherdump:
11911845Sgabor.dozsa@arm.com        system.etherdump = EtherDump(file=options.etherdump)
12011845Sgabor.dozsa@arm.com        system.etherlink.dump = system.etherdump
12111845Sgabor.dozsa@arm.com
12211845Sgabor.dozsa@arm.com
12311845Sgabor.dozsa@arm.comdef main():
12411845Sgabor.dozsa@arm.com    parser = argparse.ArgumentParser(
12511845Sgabor.dozsa@arm.com        description="Generic ARM big.LITTLE configuration with "\
12611845Sgabor.dozsa@arm.com        "dist-gem5 support")
12711845Sgabor.dozsa@arm.com    bL.addOptions(parser)
12811845Sgabor.dozsa@arm.com    addOptions(parser)
12911845Sgabor.dozsa@arm.com    options = parser.parse_args()
13011845Sgabor.dozsa@arm.com
13111845Sgabor.dozsa@arm.com    if options.is_switch:
13211845Sgabor.dozsa@arm.com        root = Root(full_system = True,
13311845Sgabor.dozsa@arm.com                    system = sw.build_switch(options))
13411845Sgabor.dozsa@arm.com    else:
13511845Sgabor.dozsa@arm.com        root = bL.build(options)
13611845Sgabor.dozsa@arm.com        addEthernet(root.system, options)
13711845Sgabor.dozsa@arm.com
13811935Sandreas.sandberg@arm.com    bL.instantiate(options, checkpoint_dir=options.checkpoint_dir)
13911845Sgabor.dozsa@arm.com    bL.run(options.checkpoint_dir)
14011845Sgabor.dozsa@arm.com
14111845Sgabor.dozsa@arm.com
14211845Sgabor.dozsa@arm.comif __name__ == "__m5_main__":
14311845Sgabor.dozsa@arm.com    main()
144