113540Sandrea.mondelli@ucf.edu#! /usr/bin/env python2.7
210750Sandreas.hansson@arm.com
310750Sandreas.hansson@arm.com# Copyright (c) 2015 ARM Limited
410750Sandreas.hansson@arm.com# All rights reserved
510750Sandreas.hansson@arm.com#
610750Sandreas.hansson@arm.com# The license below extends only to copyright in the software and shall
710750Sandreas.hansson@arm.com# not be construed as granting a license to any other intellectual
810750Sandreas.hansson@arm.com# property including but not limited to intellectual property relating
910750Sandreas.hansson@arm.com# to a hardware implementation of the functionality of the software
1010750Sandreas.hansson@arm.com# licensed hereunder.  You may use the software subject to the license
1110750Sandreas.hansson@arm.com# terms below provided that you ensure that this notice is replicated
1210750Sandreas.hansson@arm.com# unmodified and in its entirety in all distributions of the software,
1310750Sandreas.hansson@arm.com# modified or unmodified, in source code or in binary form.
1410750Sandreas.hansson@arm.com#
1510750Sandreas.hansson@arm.com# Redistribution and use in source and binary forms, with or without
1610750Sandreas.hansson@arm.com# modification, are permitted provided that the following conditions are
1710750Sandreas.hansson@arm.com# met: redistributions of source code must retain the above copyright
1810750Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer;
1910750Sandreas.hansson@arm.com# redistributions in binary form must reproduce the above copyright
2010750Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer in the
2110750Sandreas.hansson@arm.com# documentation and/or other materials provided with the distribution;
2210750Sandreas.hansson@arm.com# neither the name of the copyright holders nor the names of its
2310750Sandreas.hansson@arm.com# contributors may be used to endorse or promote products derived from
2410750Sandreas.hansson@arm.com# this software without specific prior written permission.
2510750Sandreas.hansson@arm.com#
2610750Sandreas.hansson@arm.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2710750Sandreas.hansson@arm.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2810750Sandreas.hansson@arm.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2910750Sandreas.hansson@arm.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3010750Sandreas.hansson@arm.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3110750Sandreas.hansson@arm.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3210750Sandreas.hansson@arm.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3310750Sandreas.hansson@arm.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3410750Sandreas.hansson@arm.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3510750Sandreas.hansson@arm.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3610750Sandreas.hansson@arm.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3710750Sandreas.hansson@arm.com#
3810750Sandreas.hansson@arm.com# Authors: Andreas Hansson
3910750Sandreas.hansson@arm.com
4010750Sandreas.hansson@arm.comimport optparse
4110750Sandreas.hansson@arm.comimport subprocess
4210750Sandreas.hansson@arm.comimport sys
4310750Sandreas.hansson@arm.com
4410750Sandreas.hansson@arm.comparser = optparse.OptionParser()
4510750Sandreas.hansson@arm.com
4610750Sandreas.hansson@arm.com# This script lets the user run a soak test using the false-sharing
4710750Sandreas.hansson@arm.com# memtest.py example script. It runs a number of iterations with
4810750Sandreas.hansson@arm.com# random tree topologies generated for each run, and runs for a number
4910750Sandreas.hansson@arm.com# of ticks. Both the iteration count and the ticks for each run can be
5010750Sandreas.hansson@arm.com# set on the command line.
5110750Sandreas.hansson@arm.com
5210750Sandreas.hansson@arm.comparser.add_option('-c', '--count', type='int', default=100)
5310750Sandreas.hansson@arm.comparser.add_option('-t', '--ticks', type='int', default=100000000000)
5410750Sandreas.hansson@arm.com
5510750Sandreas.hansson@arm.com(options, args) = parser.parse_args()
5610750Sandreas.hansson@arm.com
5710750Sandreas.hansson@arm.comif len(args) != 1:
5810750Sandreas.hansson@arm.com    print "Error: Expecting a single argument specifying the gem5 binary"
5910750Sandreas.hansson@arm.com    sys.exit(1)
6010750Sandreas.hansson@arm.com
6110750Sandreas.hansson@arm.comgem5_binary = args[0]
6210750Sandreas.hansson@arm.com
6310750Sandreas.hansson@arm.comfor i in range(options.count):
6410750Sandreas.hansson@arm.com    status = subprocess.call([gem5_binary, 'configs/example/memtest.py',
6510750Sandreas.hansson@arm.com                              '-r', '-m %d' % (options.ticks)])
6610750Sandreas.hansson@arm.com    if status != 0:
6710750Sandreas.hansson@arm.com        print "Error: memtest run failed\n"
6810750Sandreas.hansson@arm.com        sys.exit(1)
6910750Sandreas.hansson@arm.com
7010750Sandreas.hansson@arm.comprint "memtest soak finished without errors"
71