diff scripts/setup-mit-6.375-bmark-processor @ 23:90197e3375e2 pygar svn.24

[svn r24] added testing, but something is wrong with our c++ file.
author rlm
date Wed, 28 Apr 2010 08:19:09 -0400
parents
children 0c775e733b81
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/scripts/setup-mit-6.375-bmark-processor	Wed Apr 28 08:19:09 2010 -0400
     1.3 @@ -0,0 +1,186 @@
     1.4 +#!/usr/bin/env perl
     1.5 +# -*- perl -*-
     1.6 +
     1.7 +##############################################################
     1.8 +#
     1.9 +# Benchmark setup for HAsim
    1.10 +#
    1.11 +# Usage: setup-bmark <bmark> <srcdir> <destdir>
    1.12 +#
    1.13 +# Setup benchmark to run in <destdir>
    1.14 +#
    1.15 +##############################################################
    1.16 +
    1.17 +use strict;
    1.18 +use warnings;
    1.19 +use File::Basename;
    1.20 +use Getopt::Long;
    1.21 +
    1.22 +sub Usage();
    1.23 +sub ErrorExit($);
    1.24 +
    1.25 +#
    1.26 +# Turn on warnings
    1.27 +#
    1.28 +$^W = 1;
    1.29 +
    1.30 +my $binary = undef;
    1.31 +my $compare = undef;
    1.32 +my $data = undef;
    1.33 +my $feeder = '';
    1.34 +my $group = undef;
    1.35 +my $isa = "unknown_ISA";
    1.36 +my $linkto = undef;
    1.37 +my $numContexts = 1;
    1.38 +
    1.39 +#
    1.40 +# Find the root of the benchmarks directory tree.
    1.41 +#
    1.42 +my $benchmark_root = `awb-resolver --config=benchmarkdir`;
    1.43 +chomp($benchmark_root);
    1.44 +ErrorExit("Can't find benchmark root") if ($benchmark_root eq '');
    1.45 +
    1.46 +#
    1.47 +# Parse the command line switches
    1.48 +#
    1.49 +if (! GetOptions('binary=s' => \$binary,
    1.50 +                 'compare=s' => \$compare,
    1.51 +                 'data=s' => \$data,
    1.52 +                 'feeder=s' => \$feeder,
    1.53 +                 'group=s' => \$group,
    1.54 +                 'isa=s' => \$isa,
    1.55 +                 'linkto=s' => \$linkto,
    1.56 +                 'contexts=i' => \$numContexts,
    1.57 +                )) {
    1.58 +    Usage();
    1.59 +}
    1.60 +
    1.61 +if ($#ARGV != 2) {
    1.62 +    Usage();
    1.63 +}
    1.64 +
    1.65 +my $bmark = $ARGV[0];
    1.66 +my $srcdir = $ARGV[1];
    1.67 +my $dstdir = $ARGV[2];
    1.68 +
    1.69 +print "BMARK: $bmark\n";
    1.70 +print "SRC: $srcdir\n";
    1.71 +print "DST: $dstdir\n";
    1.72 +
    1.73 +if (! defined($group)) {
    1.74 +    $group = $bmark;
    1.75 +}
    1.76 +
    1.77 +chdir($dstdir) or ErrorExit("Failed to cd to $dstdir");
    1.78 +
    1.79 +mkdir('hasim_debug') or ErrorExit("Failed to make 'hasim_debug' directory");
    1.80 +
    1.81 +# Set up benchmark for non-null feeders
    1.82 +my $context = 0;
    1.83 +while ($context < $numContexts) {
    1.84 +    if ($feeder ne "none") {
    1.85 +        my $src_prog;
    1.86 +
    1.87 +        mkdir("program.${context}") or ErrorExit("Failed to make program directory");
    1.88 +        chdir("program.${context}") or ErrorExit("Failed to cd to program directory");
    1.89 +
    1.90 +        if (defined($binary)) {
    1.91 +            $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${binary}";
    1.92 +        }
    1.93 +        elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin") {
    1.94 +            $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin";
    1.95 +        }
    1.96 +        elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh") {
    1.97 +            $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh";
    1.98 +        }
    1.99 +        else {
   1.100 +            print STDERR "Can't find binary in ${benchmark_root}/hasim/${isa}/${group}\n";
   1.101 +            exit(1);
   1.102 +        }
   1.103 +
   1.104 +        my $dst_prog = basename($src_prog);
   1.105 +
   1.106 +        unlink($dst_prog);
   1.107 +        symlink($src_prog, $dst_prog) or ErrorExit("Failed to symlink $dst_prog => $src_prog");
   1.108 +
   1.109 +        # Copy input data files
   1.110 +        if (defined($data)) {
   1.111 +            if ($data =~ /\.tar\.gz$/) {
   1.112 +                system("tar xzf ${data}");
   1.113 +            }
   1.114 +            elsif ($data =~ /\.tar$/) {
   1.115 +                system("tar xf ${data}");
   1.116 +            }
   1.117 +        }
   1.118 +
   1.119 +        # Link to files or directories
   1.120 +        if (defined($linkto)) {
   1.121 +            foreach my $tgt (split(':', $linkto)) {
   1.122 +                if ($tgt =~ /\/$/) {
   1.123 +                    # Trailing slash means link to all the files individually within
   1.124 +                    # a directory.
   1.125 +                    if (-d $tgt) {
   1.126 +                        opendir(DIR, $tgt) || die("Cannot open directory for --linkto $tgt\n");
   1.127 +                        my @tgt_objs = readdir(DIR);
   1.128 +                        closedir(DIR);
   1.129 +                        foreach my $t (@tgt_objs) {
   1.130 +                            if (! (($t eq '.') || ($t eq '..'))) {
   1.131 +                                symlink("${tgt}${t}", basename($t)) or die("Failed to link to ${tgt}${t}");
   1.132 +                            }
   1.133 +                        }
   1.134 +                    }
   1.135 +                }
   1.136 +                else {
   1.137 +                    # No trailing slash. Just link to a single object
   1.138 +                    symlink($tgt, basename($tgt)) or die("Failed to link to $tgt");
   1.139 +                }
   1.140 +            }
   1.141 +        }
   1.142 +
   1.143 +        # Back to main workload directory
   1.144 +        chdir("..");
   1.145 +    }
   1.146 +
   1.147 +    $context += 1;
   1.148 +}
   1.149 +
   1.150 +# Store compare rules to config
   1.151 +open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh");
   1.152 +print ENV "ISA=\"${isa}\"\n";
   1.153 +if ($numContexts != 0) {
   1.154 +    print ENV "workloadContexts=\"${numContexts}\"\n";
   1.155 +}
   1.156 +if (defined($compare)) {
   1.157 +    print ENV "compare=\"${compare}\"\n";
   1.158 +}
   1.159 +close(ENV);
   1.160 +
   1.161 +# Set up m5 environment
   1.162 +if ($feeder eq 'm5') {
   1.163 +    system("(cd $srcdir; tar cf - ./m5_configs) | tar xf -");
   1.164 +}
   1.165 +
   1.166 +system("cp -f ${srcdir}/run.bmark run");
   1.167 +chmod(0755, "run");
   1.168 +
   1.169 +exit(0);
   1.170 +
   1.171 +
   1.172 +
   1.173 +sub Usage() {
   1.174 +    print STDERR "Usage: setup-bmark [--binary <name>]\n";
   1.175 +    print STDERR "                   [--compare <compare commands>]\n";
   1.176 +    print STDERR "                   [--contexts <num workload contexts>]\n";
   1.177 +    print STDERR "                   [--data <tar file>]\n";
   1.178 +    print STDERR "                   [--group <name>]\n";
   1.179 +    print STDERR "                   [--isa <name>]\n";
   1.180 +    print STDERR "                   [--linkto <target0>:...:<targetN>]\n";
   1.181 +    print STDERR "                   <bmark> <srcdir> <dstdir>\n";
   1.182 +    exit(1);
   1.183 +}
   1.184 +
   1.185 +
   1.186 +sub ErrorExit($) {
   1.187 +    print STDERR @_ . "\n";
   1.188 +    exit(1);
   1.189 +}