annotate scripts/setup-mit-6.375-bmark-audio-core @ 44:9b0dfce52c29 pygar svn.45

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