Mercurial > pygar
view 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 |
line wrap: on
line source
1 #!/usr/bin/env perl2 # -*- perl -*-4 ##############################################################5 #6 # Benchmark setup for HAsim7 #8 # Usage: setup-bmark <bmark> <srcdir> <destdir>9 #10 # Setup benchmark to run in <destdir>11 #12 ##############################################################14 #use strict;15 use warnings;16 use File::Basename;17 use Getopt::Long;19 sub Usage();20 sub ErrorExit($);22 #23 # Turn on warnings24 #25 $^W = 1;27 my $binary = undef;28 my $compare = undef;29 my $data = undef;30 my $feeder = '';31 my $group = undef;32 my $isa = "unknown_ISA";33 my $linkto = undef;34 my $numContexts = 1;36 #37 # Find the root of the benchmarks directory tree.38 #39 my $benchmark_root = `awb-resolver --config=benchmarkdir`;40 chomp($benchmark_root);41 ErrorExit("Can't find benchmark root") if ($benchmark_root eq '');43 #44 # Parse the command line switches45 #46 if (! GetOptions('binary=s' => \$binary,47 'compare=s' => \$compare,48 'data=s' => \$data,49 'feeder=s' => \$feeder,50 'group=s' => \$group,51 'isa=s' => \$isa,52 'linkto=s' => \$linkto,53 'contexts=i' => \$numContexts,54 )) {55 Usage();56 }58 if ($#ARGV != 2) {59 Usage();60 }62 my $bmark = $ARGV[0];63 my $srcdir = $ARGV[1];64 my $dstdir = $ARGV[2];65 my $basedir = `pwd`;66 chomp($basedir);68 print "BMARK: $bmark\n";69 print "SRC: $srcdir\n";70 print "DST: $dstdir\n";71 print "BASE: $basedir\n";73 if (! defined($group)) {74 $group = $bmark;75 }77 chdir($dstdir) or ErrorExit("Failed to cd to $dstdir");79 mkdir('hasim_debug') or ErrorExit("Failed to make 'hasim_debug' directory");81 # Set up benchmark for non-null feeders82 my $context = 0;83 while ($context < $numContexts) {84 if ($feeder ne "none") {85 my $src_prog;87 mkdir("program.${context}") or ErrorExit("Failed to make program directory");88 chdir("program.${context}") or ErrorExit("Failed to cd to program directory");90 if (defined($binary)) {91 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${binary}";92 }93 elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin") {94 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin";95 }96 elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh") {97 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh";98 }99 else {100 print STDERR "Can't find binary in ${benchmark_root}/hasim/${isa}/${group}\n";101 exit(1);102 }104 my $dst_prog = basename($src_prog);106 unlink($dst_prog);108 print "\n\nRLM: putting $src_prog in $dst_prog, and also program.vmh\n";110 symlink($src_prog, $dst_prog) or ErrorExit("Failed to symlink $dst_prog => $src_prog");111 symlink($src_prog, "program.vmh") or ErrorExit("Failed to symlink $dst_prog => $src_prog");113 # Copy input data files114 if (defined($data)) {115 # No trailing slash. Just link to a single object118 # rlm: oh my gosh here we go with TWO files!119 print "\nRLM: moving TWO files:\n";120 print "OHYEAH:: $data\n\n";121 $data =~ m#^.*/([^/]*)\.wav$#;122 #print "OHYYYYYYEAH::: $1\n\n\n!!!";123 $newFile = $1."1.wav";124 print "data: $data\n";125 print "rlm: data2: $newFile\n";126 print "\nrlm: move ${srcdir}/${data} to input.wav\n\n";128 symlink("${srcdir}/${data}", "../input.wav") or die("Failed to link to $data");129 symlink("${srcdir}/../benchmarks/audio_processor_test/$newFile", "../input1.wav") or die("Failed to link to $newFile");132 }133 # this came from processor bit and not sure what it is expecting134 # Copy input data files135 # if (defined($data)) {136 # if ($data =~ /\.tar\.gz$/) {137 # system("tar xzf ${data}");138 # }139 # elsif ($data =~ /\.tar$/) {140 # system("tar xf ${data}");141 # }142 # }144 # Link to files or directories145 if (defined($linkto)) {146 foreach my $tgt (split(':', $linkto)) {147 if ($tgt =~ /\/$/) {148 # Trailing slash means link to all the files individually within149 # a directory.150 if (-d $tgt) {151 opendir(DIR, $tgt) || die("Cannot open directory for --linkto $tgt\n");152 my @tgt_objs = readdir(DIR);153 closedir(DIR);154 foreach my $t (@tgt_objs) {155 if (! (($t eq '.') || ($t eq '..'))) {156 symlink("${tgt}${t}", basename($t)) or die("Failed to link to ${tgt}${t}");157 }158 }159 }160 }161 else {162 # No trailing slash. Just link to a single object163 symlink($tgt, basename($tgt)) or die("Failed to link to $tgt");164 }165 }166 }168 # Back to main workload directory169 chdir("..");170 }172 $context += 1;173 }175 # Store compare rules to config176 open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh");177 print ENV "ISA=\"${isa}\"\n";178 if ($numContexts != 0) {179 print ENV "workloadContexts=\"${numContexts}\"\n";180 }181 if (defined($compare)) {182 print ENV "compare=\"${compare}\"\n";183 #print ENV "compare=\"ls\"\n";184 }185 close(ENV);187 # Set up m5 environment188 if ($feeder eq 'm5') {189 system("(cd $srcdir; tar cf - ./m5_configs) | tar xf -");190 }192 system("cp -f ${srcdir}/run.bmark run");193 chmod(0755, "run");195 exit(0);199 sub Usage() {200 print STDERR "Usage: setup-bmark [--binary <name>]\n";201 print STDERR " [--compare <compare commands>]\n";202 print STDERR " [--contexts <num workload contexts>]\n";203 print STDERR " [--data <tar file>]\n";204 print STDERR " [--group <name>]\n";205 print STDERR " [--isa <name>]\n";206 print STDERR " [--linkto <target0>:...:<targetN>]\n";207 print STDERR " <bmark> <srcdir> <dstdir>\n";208 exit(1);209 }212 sub ErrorExit($) {213 print STDERR @_ . "\n";214 exit(1);215 }