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 1a21b4cd85ee
children 7ac38b0f93fa
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
rlm@34 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
rlm@34 112
rlm@34 113
rlm@34 114 # rlm: oh my gosh here we go with TWO files!
rlm@34 115 print "\nRLM: moving TWO files:\n";
rlm@34 116 print "OHYEAH:: $data\n\n";
rlm@34 117 $data =~ m#^.*/([^/]*)\.wav$#;
rlm@34 118 #print "OHYYYYYYEAH::: $1\n\n\n!!!";
rlm@34 119 $newFile = $1."1.wav";
punk@32 120 print "data: $data\n";
rlm@34 121 print "rlm: data2: $newFile\n";
rlm@34 122 print "\nrlm: move ${srcdir}/${data} to input.wav\n\n";
rlm@34 123
rlm@34 124 symlink("${srcdir}/${data}", "../input.wav") or die("Failed to link to $data");
rlm@34 125 symlink("${srcdir}/../benchmarks/audio_processor_test/$newFile", "../input1.wav") or die("Failed to link to $newFile");
rlm@34 126
rlm@34 127
punk@32 128 }
punk@32 129 # this came from processor bit and not sure what it is expecting
punk@32 130 # Copy input data files
punk@32 131 # if (defined($data)) {
punk@32 132 # if ($data =~ /\.tar\.gz$/) {
punk@32 133 # system("tar xzf ${data}");
punk@32 134 # }
punk@32 135 # elsif ($data =~ /\.tar$/) {
punk@32 136 # system("tar xf ${data}");
punk@32 137 # }
punk@32 138 # }
punk@32 139
punk@32 140 # Link to files or directories
punk@32 141 if (defined($linkto)) {
punk@32 142 foreach my $tgt (split(':', $linkto)) {
punk@32 143 if ($tgt =~ /\/$/) {
punk@32 144 # Trailing slash means link to all the files individually within
punk@32 145 # a directory.
punk@32 146 if (-d $tgt) {
punk@32 147 opendir(DIR, $tgt) || die("Cannot open directory for --linkto $tgt\n");
punk@32 148 my @tgt_objs = readdir(DIR);
punk@32 149 closedir(DIR);
punk@32 150 foreach my $t (@tgt_objs) {
punk@32 151 if (! (($t eq '.') || ($t eq '..'))) {
punk@32 152 symlink("${tgt}${t}", basename($t)) or die("Failed to link to ${tgt}${t}");
punk@32 153 }
punk@32 154 }
punk@32 155 }
punk@32 156 }
punk@32 157 else {
punk@32 158 # No trailing slash. Just link to a single object
punk@32 159 symlink($tgt, basename($tgt)) or die("Failed to link to $tgt");
punk@32 160 }
punk@32 161 }
punk@32 162 }
punk@32 163
punk@32 164 # Back to main workload directory
punk@32 165 chdir("..");
punk@32 166 }
punk@32 167
punk@32 168 $context += 1;
punk@32 169 }
punk@32 170
punk@32 171 # Store compare rules to config
punk@32 172 open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh");
punk@32 173 print ENV "ISA=\"${isa}\"\n";
punk@32 174 if ($numContexts != 0) {
punk@32 175 print ENV "workloadContexts=\"${numContexts}\"\n";
punk@32 176 }
punk@32 177 if (defined($compare)) {
punk@32 178 print ENV "compare=\"${compare}\"\n";
punk@32 179 }
punk@32 180 close(ENV);
punk@32 181
punk@32 182 # Set up m5 environment
punk@32 183 if ($feeder eq 'm5') {
punk@32 184 system("(cd $srcdir; tar cf - ./m5_configs) | tar xf -");
punk@32 185 }
punk@32 186
punk@32 187 system("cp -f ${srcdir}/run.bmark run");
punk@32 188 chmod(0755, "run");
punk@32 189
punk@32 190 exit(0);
punk@32 191
punk@32 192
punk@32 193
punk@32 194 sub Usage() {
punk@32 195 print STDERR "Usage: setup-bmark [--binary <name>]\n";
punk@32 196 print STDERR " [--compare <compare commands>]\n";
punk@32 197 print STDERR " [--contexts <num workload contexts>]\n";
punk@32 198 print STDERR " [--data <tar file>]\n";
punk@32 199 print STDERR " [--group <name>]\n";
punk@32 200 print STDERR " [--isa <name>]\n";
punk@32 201 print STDERR " [--linkto <target0>:...:<targetN>]\n";
punk@32 202 print STDERR " <bmark> <srcdir> <dstdir>\n";
punk@32 203 exit(1);
punk@32 204 }
punk@32 205
punk@32 206
punk@32 207 sub ErrorExit($) {
punk@32 208 print STDERR @_ . "\n";
punk@32 209 exit(1);
punk@32 210 }