diff scripts/setup-mit-6.375-bmark-audio-core~ @ 32:0c775e733b81 pygar svn.33

[svn r33] audio core benchmark script added and the benchmark setup is half-way to working
author punk
date Mon, 03 May 2010 09:53:56 -0400
parents
children
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-audio-core~	Mon May 03 09:53:56 2010 -0400
     1.3 @@ -0,0 +1,196 @@
     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 +my $basedir = `pwd`;
    1.69 +chomp($basedir);
    1.70 +
    1.71 +print "BMARK: $bmark\n";
    1.72 +print "SRC: $srcdir\n";
    1.73 +print "DST: $dstdir\n";
    1.74 +print "BASE: $basedir\n";
    1.75 + 
    1.76 +if (! defined($group)) {
    1.77 +    $group = $bmark;
    1.78 +}
    1.79 +
    1.80 +chdir($dstdir) or ErrorExit("Failed to cd to $dstdir");
    1.81 +
    1.82 +mkdir('hasim_debug') or ErrorExit("Failed to make 'hasim_debug' directory");
    1.83 +
    1.84 +# Set up benchmark for non-null feeders
    1.85 +my $context = 0;
    1.86 +while ($context < $numContexts) {
    1.87 +    if ($feeder ne "none") {
    1.88 +        my $src_prog;
    1.89 +
    1.90 +        mkdir("program.${context}") or ErrorExit("Failed to make program directory");
    1.91 +        chdir("program.${context}") or ErrorExit("Failed to cd to program directory");
    1.92 +
    1.93 +        if (defined($binary)) {
    1.94 +            $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${binary}";
    1.95 +        }
    1.96 +        elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin") {
    1.97 +            $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin";
    1.98 +        }
    1.99 +        elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh") {
   1.100 +            $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh";
   1.101 +        }
   1.102 +        else {
   1.103 +            print STDERR "Can't find binary in ${benchmark_root}/hasim/${isa}/${group}\n";
   1.104 +            exit(1);
   1.105 +        }
   1.106 +
   1.107 +        my $dst_prog = basename($src_prog);
   1.108 +
   1.109 +        unlink($dst_prog);
   1.110 +        symlink($src_prog, $dst_prog) or ErrorExit("Failed to symlink $dst_prog => $src_prog");
   1.111 +
   1.112 +# Copy input data files
   1.113 +if (defined($data)) {
   1.114 +   # No trailing slash. Just link to a single object
   1.115 +   print "data: $data\n";
   1.116 +   symlink("${srcdir}/${data}", "input.wav") or die("Failed to link to $data");
   1.117 +}
   1.118 +
   1.119 +        # Copy input data files
   1.120 +        if (defined($data)) {
   1.121 +            if ($data =~ /\.tar\.gz$/) {
   1.122 +                system("tar xzf ${data}");
   1.123 +            }
   1.124 +            elsif ($data =~ /\.tar$/) {
   1.125 +                system("tar xf ${data}");
   1.126 +            }
   1.127 +        }
   1.128 +
   1.129 +        # Link to files or directories
   1.130 +        if (defined($linkto)) {
   1.131 +            foreach my $tgt (split(':', $linkto)) {
   1.132 +                if ($tgt =~ /\/$/) {
   1.133 +                    # Trailing slash means link to all the files individually within
   1.134 +                    # a directory.
   1.135 +                    if (-d $tgt) {
   1.136 +                        opendir(DIR, $tgt) || die("Cannot open directory for --linkto $tgt\n");
   1.137 +                        my @tgt_objs = readdir(DIR);
   1.138 +                        closedir(DIR);
   1.139 +                        foreach my $t (@tgt_objs) {
   1.140 +                            if (! (($t eq '.') || ($t eq '..'))) {
   1.141 +                                symlink("${tgt}${t}", basename($t)) or die("Failed to link to ${tgt}${t}");
   1.142 +                            }
   1.143 +                        }
   1.144 +                    }
   1.145 +                }
   1.146 +                else {
   1.147 +                    # No trailing slash. Just link to a single object
   1.148 +                    symlink($tgt, basename($tgt)) or die("Failed to link to $tgt");
   1.149 +                }
   1.150 +            }
   1.151 +        }
   1.152 +
   1.153 +        # Back to main workload directory
   1.154 +        chdir("..");
   1.155 +    }
   1.156 +
   1.157 +    $context += 1;
   1.158 +}
   1.159 +
   1.160 +# Store compare rules to config
   1.161 +open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh");
   1.162 +print ENV "ISA=\"${isa}\"\n";
   1.163 +if ($numContexts != 0) {
   1.164 +    print ENV "workloadContexts=\"${numContexts}\"\n";
   1.165 +}
   1.166 +if (defined($compare)) {
   1.167 +    print ENV "compare=\"${compare}\"\n";
   1.168 +}
   1.169 +close(ENV);
   1.170 +
   1.171 +# Set up m5 environment
   1.172 +if ($feeder eq 'm5') {
   1.173 +    system("(cd $srcdir; tar cf - ./m5_configs) | tar xf -");
   1.174 +}
   1.175 +
   1.176 +system("cp -f ${srcdir}/run.bmark run");
   1.177 +chmod(0755, "run");
   1.178 +
   1.179 +exit(0);
   1.180 +
   1.181 +
   1.182 +
   1.183 +sub Usage() {
   1.184 +    print STDERR "Usage: setup-bmark [--binary <name>]\n";
   1.185 +    print STDERR "                   [--compare <compare commands>]\n";
   1.186 +    print STDERR "                   [--contexts <num workload contexts>]\n";
   1.187 +    print STDERR "                   [--data <tar file>]\n";
   1.188 +    print STDERR "                   [--group <name>]\n";
   1.189 +    print STDERR "                   [--isa <name>]\n";
   1.190 +    print STDERR "                   [--linkto <target0>:...:<targetN>]\n";
   1.191 +    print STDERR "                   <bmark> <srcdir> <dstdir>\n";
   1.192 +    exit(1);
   1.193 +}
   1.194 +
   1.195 +
   1.196 +sub ErrorExit($) {
   1.197 +    print STDERR @_ . "\n";
   1.198 +    exit(1);
   1.199 +}