annotate scripts/setup-mit-6.375-bmark-audio-core~ @ 38:05598d745f99 pygar svn.39

[svn r39] fixed audiocorepipe
author punk
date Tue, 04 May 2010 19:27:38 -0400
parents 0c775e733b81
children
rev   line source
punk@32 1 #!/usr/bin/env perl
punk@32 2 # -*- perl -*-
punk@32 3
punk@32 4 ##############################################################
punk@32 5 #
punk@32 6 # Benchmark setup for HAsim
punk@32 7 #
punk@32 8 # Usage: setup-bmark <bmark> <srcdir> <destdir>
punk@32 9 #
punk@32 10 # Setup benchmark to run in <destdir>
punk@32 11 #
punk@32 12 ##############################################################
punk@32 13
punk@32 14 use strict;
punk@32 15 use warnings;
punk@32 16 use File::Basename;
punk@32 17 use Getopt::Long;
punk@32 18
punk@32 19 sub Usage();
punk@32 20 sub ErrorExit($);
punk@32 21
punk@32 22 #
punk@32 23 # Turn on warnings
punk@32 24 #
punk@32 25 $^W = 1;
punk@32 26
punk@32 27 my $binary = undef;
punk@32 28 my $compare = undef;
punk@32 29 my $data = undef;
punk@32 30 my $feeder = '';
punk@32 31 my $group = undef;
punk@32 32 my $isa = "unknown_ISA";
punk@32 33 my $linkto = undef;
punk@32 34 my $numContexts = 1;
punk@32 35
punk@32 36 #
punk@32 37 # Find the root of the benchmarks directory tree.
punk@32 38 #
punk@32 39 my $benchmark_root = `awb-resolver --config=benchmarkdir`;
punk@32 40 chomp($benchmark_root);
punk@32 41 ErrorExit("Can't find benchmark root") if ($benchmark_root eq '');
punk@32 42
punk@32 43 #
punk@32 44 # Parse the command line switches
punk@32 45 #
punk@32 46 if (! GetOptions('binary=s' => \$binary,
punk@32 47 'compare=s' => \$compare,
punk@32 48 'data=s' => \$data,
punk@32 49 'feeder=s' => \$feeder,
punk@32 50 'group=s' => \$group,
punk@32 51 'isa=s' => \$isa,
punk@32 52 'linkto=s' => \$linkto,
punk@32 53 'contexts=i' => \$numContexts,
punk@32 54 )) {
punk@32 55 Usage();
punk@32 56 }
punk@32 57
punk@32 58 if ($#ARGV != 2) {
punk@32 59 Usage();
punk@32 60 }
punk@32 61
punk@32 62 my $bmark = $ARGV[0];
punk@32 63 my $srcdir = $ARGV[1];
punk@32 64 my $dstdir = $ARGV[2];
punk@32 65 my $basedir = `pwd`;
punk@32 66 chomp($basedir);
punk@32 67
punk@32 68 print "BMARK: $bmark\n";
punk@32 69 print "SRC: $srcdir\n";
punk@32 70 print "DST: $dstdir\n";
punk@32 71 print "BASE: $basedir\n";
punk@32 72
punk@32 73 if (! defined($group)) {
punk@32 74 $group = $bmark;
punk@32 75 }
punk@32 76
punk@32 77 chdir($dstdir) or ErrorExit("Failed to cd to $dstdir");
punk@32 78
punk@32 79 mkdir('hasim_debug') or ErrorExit("Failed to make 'hasim_debug' directory");
punk@32 80
punk@32 81 # Set up benchmark for non-null feeders
punk@32 82 my $context = 0;
punk@32 83 while ($context < $numContexts) {
punk@32 84 if ($feeder ne "none") {
punk@32 85 my $src_prog;
punk@32 86
punk@32 87 mkdir("program.${context}") or ErrorExit("Failed to make program directory");
punk@32 88 chdir("program.${context}") or ErrorExit("Failed to cd to program directory");
punk@32 89
punk@32 90 if (defined($binary)) {
punk@32 91 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${binary}";
punk@32 92 }
punk@32 93 elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin") {
punk@32 94 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin";
punk@32 95 }
punk@32 96 elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh") {
punk@32 97 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh";
punk@32 98 }
punk@32 99 else {
punk@32 100 print STDERR "Can't find binary in ${benchmark_root}/hasim/${isa}/${group}\n";
punk@32 101 exit(1);
punk@32 102 }
punk@32 103
punk@32 104 my $dst_prog = basename($src_prog);
punk@32 105
punk@32 106 unlink($dst_prog);
punk@32 107 symlink($src_prog, $dst_prog) or ErrorExit("Failed to symlink $dst_prog => $src_prog");
punk@32 108
punk@32 109 # Copy input data files
punk@32 110 if (defined($data)) {
punk@32 111 # No trailing slash. Just link to a single object
punk@32 112 print "data: $data\n";
punk@32 113 symlink("${srcdir}/${data}", "input.wav") or die("Failed to link to $data");
punk@32 114 }
punk@32 115
punk@32 116 # Copy input data files
punk@32 117 if (defined($data)) {
punk@32 118 if ($data =~ /\.tar\.gz$/) {
punk@32 119 system("tar xzf ${data}");
punk@32 120 }
punk@32 121 elsif ($data =~ /\.tar$/) {
punk@32 122 system("tar xf ${data}");
punk@32 123 }
punk@32 124 }
punk@32 125
punk@32 126 # Link to files or directories
punk@32 127 if (defined($linkto)) {
punk@32 128 foreach my $tgt (split(':', $linkto)) {
punk@32 129 if ($tgt =~ /\/$/) {
punk@32 130 # Trailing slash means link to all the files individually within
punk@32 131 # a directory.
punk@32 132 if (-d $tgt) {
punk@32 133 opendir(DIR, $tgt) || die("Cannot open directory for --linkto $tgt\n");
punk@32 134 my @tgt_objs = readdir(DIR);
punk@32 135 closedir(DIR);
punk@32 136 foreach my $t (@tgt_objs) {
punk@32 137 if (! (($t eq '.') || ($t eq '..'))) {
punk@32 138 symlink("${tgt}${t}", basename($t)) or die("Failed to link to ${tgt}${t}");
punk@32 139 }
punk@32 140 }
punk@32 141 }
punk@32 142 }
punk@32 143 else {
punk@32 144 # No trailing slash. Just link to a single object
punk@32 145 symlink($tgt, basename($tgt)) or die("Failed to link to $tgt");
punk@32 146 }
punk@32 147 }
punk@32 148 }
punk@32 149
punk@32 150 # Back to main workload directory
punk@32 151 chdir("..");
punk@32 152 }
punk@32 153
punk@32 154 $context += 1;
punk@32 155 }
punk@32 156
punk@32 157 # Store compare rules to config
punk@32 158 open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh");
punk@32 159 print ENV "ISA=\"${isa}\"\n";
punk@32 160 if ($numContexts != 0) {
punk@32 161 print ENV "workloadContexts=\"${numContexts}\"\n";
punk@32 162 }
punk@32 163 if (defined($compare)) {
punk@32 164 print ENV "compare=\"${compare}\"\n";
punk@32 165 }
punk@32 166 close(ENV);
punk@32 167
punk@32 168 # Set up m5 environment
punk@32 169 if ($feeder eq 'm5') {
punk@32 170 system("(cd $srcdir; tar cf - ./m5_configs) | tar xf -");
punk@32 171 }
punk@32 172
punk@32 173 system("cp -f ${srcdir}/run.bmark run");
punk@32 174 chmod(0755, "run");
punk@32 175
punk@32 176 exit(0);
punk@32 177
punk@32 178
punk@32 179
punk@32 180 sub Usage() {
punk@32 181 print STDERR "Usage: setup-bmark [--binary <name>]\n";
punk@32 182 print STDERR " [--compare <compare commands>]\n";
punk@32 183 print STDERR " [--contexts <num workload contexts>]\n";
punk@32 184 print STDERR " [--data <tar file>]\n";
punk@32 185 print STDERR " [--group <name>]\n";
punk@32 186 print STDERR " [--isa <name>]\n";
punk@32 187 print STDERR " [--linkto <target0>:...:<targetN>]\n";
punk@32 188 print STDERR " <bmark> <srcdir> <dstdir>\n";
punk@32 189 exit(1);
punk@32 190 }
punk@32 191
punk@32 192
punk@32 193 sub ErrorExit($) {
punk@32 194 print STDERR @_ . "\n";
punk@32 195 exit(1);
punk@32 196 }