tracediff revision 3362
1247Sstever@eecs.umich.edu#! /usr/bin/env perl 22783Sktlim@umich.edu# Copyright (c) 2003-2006 The Regents of The University of Michigan 3247Sstever@eecs.umich.edu# All rights reserved. 4247Sstever@eecs.umich.edu# 5247Sstever@eecs.umich.edu# Redistribution and use in source and binary forms, with or without 6247Sstever@eecs.umich.edu# modification, are permitted provided that the following conditions are 7247Sstever@eecs.umich.edu# met: redistributions of source code must retain the above copyright 8247Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 9247Sstever@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 10247Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 11247Sstever@eecs.umich.edu# documentation and/or other materials provided with the distribution; 12247Sstever@eecs.umich.edu# neither the name of the copyright holders nor the names of its 13247Sstever@eecs.umich.edu# contributors may be used to endorse or promote products derived from 14247Sstever@eecs.umich.edu# this software without specific prior written permission. 15247Sstever@eecs.umich.edu# 16247Sstever@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17247Sstever@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18247Sstever@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19247Sstever@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20247Sstever@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21247Sstever@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22247Sstever@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23247Sstever@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24247Sstever@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25247Sstever@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26247Sstever@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27247Sstever@eecs.umich.edu# 28247Sstever@eecs.umich.edu# Authors: Steve Reinhardt 29247Sstever@eecs.umich.edu 301123Sstever@eecs.umich.edu# Script to simplify using rundiff on trace outputs from two 311123Sstever@eecs.umich.edu# invocations of m5. 321123Sstever@eecs.umich.edu# 331746Shsul@eecs.umich.edu# ******Note that you need to enable some trace flags in the args in order 341746Shsul@eecs.umich.edu# to do anything useful!****** 351123Sstever@eecs.umich.edu# 363362Sstever@eecs.umich.edu# Script arguments are handled uniformly as follows: 373362Sstever@eecs.umich.edu# - If the argument does not contain a '|' character, it is appended 383362Sstever@eecs.umich.edu# to both command lines. 393362Sstever@eecs.umich.edu# - If the argument has a '|' character in it, the text on either side 403362Sstever@eecs.umich.edu# of the '|' is appended to the respective command lines. Note that 413362Sstever@eecs.umich.edu# you'll have to quote the arg or escape the '|' with a backslash 423362Sstever@eecs.umich.edu# so that the shell doesn't think you're doing a pipe. 431123Sstever@eecs.umich.edu# 443362Sstever@eecs.umich.edu# For example: 453362Sstever@eecs.umich.edu# 463362Sstever@eecs.umich.edu# % tracediff m5.opt --opt1 "--opt2|--opt3" --opt4 473362Sstever@eecs.umich.edu# would compare these two runs: 483362Sstever@eecs.umich.edu# m5.opt --opt1 --opt2 --opt4 493362Sstever@eecs.umich.edu# m5.opt --opt1 --opt3 --opt4 503362Sstever@eecs.umich.edu# 513362Sstever@eecs.umich.edu# If you want to compare two different simulator binaries, put a '|' 523362Sstever@eecs.umich.edu# in the first script argument ("path1/m5.opt|path2/m5.opt"). If you 533362Sstever@eecs.umich.edu# want to add arguments to one run only, just put a '|' in with text 543362Sstever@eecs.umich.edu# only on one side ("--onlyOn1|"). You can do this with multiple 553362Sstever@eecs.umich.edu# arguments together too ("|-a -b -c" adds three args to the second 563362Sstever@eecs.umich.edu# run only). 571123Sstever@eecs.umich.edu# 58247Sstever@eecs.umich.edu 59247Sstever@eecs.umich.eduif (@ARGV < 2) { 603362Sstever@eecs.umich.edu die "Usage: tracediff \"sim1|sim2\" [common-arg \"arg1|arg2\" ...]\n"; 613362Sstever@eecs.umich.edu} 623362Sstever@eecs.umich.edu 633362Sstever@eecs.umich.eduforeach $arg (@ARGV) { 643362Sstever@eecs.umich.edu @pair = split('\|', $arg, -1); # -1 enables null trailing fields 653362Sstever@eecs.umich.edu if ($#pair > 0) { 663362Sstever@eecs.umich.edu push @cmd1, $pair[0]; 673362Sstever@eecs.umich.edu push @cmd2, $pair[1]; 683362Sstever@eecs.umich.edu } else { 693362Sstever@eecs.umich.edu push @cmd1, $arg; 703362Sstever@eecs.umich.edu push @cmd2, $arg; 713362Sstever@eecs.umich.edu } 72247Sstever@eecs.umich.edu} 73247Sstever@eecs.umich.edu 74247Sstever@eecs.umich.edu# First two args are the two simulator binaries to compare 753362Sstever@eecs.umich.edu$sim1 = shift @cmd1; 763362Sstever@eecs.umich.edu$sim2 = shift @cmd2; 77247Sstever@eecs.umich.edu 783362Sstever@eecs.umich.edu# Everything else is a simulator arg. 793362Sstever@eecs.umich.edu$args1 = join(' ', @cmd1); 803362Sstever@eecs.umich.edu$args2 = join(' ', @cmd2); 81247Sstever@eecs.umich.edu 821442Sstever@eecs.umich.edu# Run individual invocations in separate dirs so output and intermediate 831442Sstever@eecs.umich.edu# files (particularly config.py and config.ini) don't conflict. 841442Sstever@eecs.umich.edu$dir1 = "tracediff-$$-1"; 851442Sstever@eecs.umich.edu$dir2 = "tracediff-$$-2"; 861442Sstever@eecs.umich.edumkdir($dir1) or die "Can't create dir $dir1\n"; 871442Sstever@eecs.umich.edumkdir($dir2) or die "Can't create dir $dir2\n"; 881123Sstever@eecs.umich.edu 893362Sstever@eecs.umich.edu$cmd1 = "$sim1 -d $dir1 $args1 2>&1 |"; 903362Sstever@eecs.umich.edu$cmd2 = "$sim2 -d $dir2 $args2 2>&1 |"; 91247Sstever@eecs.umich.edu 92247Sstever@eecs.umich.edu# This only works if you have rundiff in your path. I just edit it 93247Sstever@eecs.umich.edu# with an explicit path if necessary. 94247Sstever@eecs.umich.edu$fullcmd = "rundiff '$cmd1' '$cmd2' 2>&1 > tracediff-$$.out"; 95247Sstever@eecs.umich.edu 96247Sstever@eecs.umich.eduprint "Executing $fullcmd\n"; 97247Sstever@eecs.umich.edusystem($fullcmd); 98247Sstever@eecs.umich.edu 99247Sstever@eecs.umich.edu 100247Sstever@eecs.umich.edu 101