Mercurial > pygar
view scripts/setup-mit-6.375-bmark-audio-core @ 39:5a30f173bbac pygar svn.40
[svn r40] no longer cpu terminating dependent
author | punk |
---|---|
date | Tue, 04 May 2010 19:32:25 -0400 |
parents | 1a21b4cd85ee |
children | 7ac38b0f93fa |
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);107 symlink($src_prog, $dst_prog) or ErrorExit("Failed to symlink $dst_prog => $src_prog");109 # Copy input data files110 if (defined($data)) {111 # No trailing slash. Just link to a single object114 # rlm: oh my gosh here we go with TWO files!115 print "\nRLM: moving TWO files:\n";116 print "OHYEAH:: $data\n\n";117 $data =~ m#^.*/([^/]*)\.wav$#;118 #print "OHYYYYYYEAH::: $1\n\n\n!!!";119 $newFile = $1."1.wav";120 print "data: $data\n";121 print "rlm: data2: $newFile\n";122 print "\nrlm: move ${srcdir}/${data} to input.wav\n\n";124 symlink("${srcdir}/${data}", "../input.wav") or die("Failed to link to $data");125 symlink("${srcdir}/../benchmarks/audio_processor_test/$newFile", "../input1.wav") or die("Failed to link to $newFile");128 }129 # this came from processor bit and not sure what it is expecting130 # Copy input data files131 # if (defined($data)) {132 # if ($data =~ /\.tar\.gz$/) {133 # system("tar xzf ${data}");134 # }135 # elsif ($data =~ /\.tar$/) {136 # system("tar xf ${data}");137 # }138 # }140 # Link to files or directories141 if (defined($linkto)) {142 foreach my $tgt (split(':', $linkto)) {143 if ($tgt =~ /\/$/) {144 # Trailing slash means link to all the files individually within145 # a directory.146 if (-d $tgt) {147 opendir(DIR, $tgt) || die("Cannot open directory for --linkto $tgt\n");148 my @tgt_objs = readdir(DIR);149 closedir(DIR);150 foreach my $t (@tgt_objs) {151 if (! (($t eq '.') || ($t eq '..'))) {152 symlink("${tgt}${t}", basename($t)) or die("Failed to link to ${tgt}${t}");153 }154 }155 }156 }157 else {158 # No trailing slash. Just link to a single object159 symlink($tgt, basename($tgt)) or die("Failed to link to $tgt");160 }161 }162 }164 # Back to main workload directory165 chdir("..");166 }168 $context += 1;169 }171 # Store compare rules to config172 open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh");173 print ENV "ISA=\"${isa}\"\n";174 if ($numContexts != 0) {175 print ENV "workloadContexts=\"${numContexts}\"\n";176 }177 if (defined($compare)) {178 print ENV "compare=\"${compare}\"\n";179 }180 close(ENV);182 # Set up m5 environment183 if ($feeder eq 'm5') {184 system("(cd $srcdir; tar cf - ./m5_configs) | tar xf -");185 }187 system("cp -f ${srcdir}/run.bmark run");188 chmod(0755, "run");190 exit(0);194 sub Usage() {195 print STDERR "Usage: setup-bmark [--binary <name>]\n";196 print STDERR " [--compare <compare commands>]\n";197 print STDERR " [--contexts <num workload contexts>]\n";198 print STDERR " [--data <tar file>]\n";199 print STDERR " [--group <name>]\n";200 print STDERR " [--isa <name>]\n";201 print STDERR " [--linkto <target0>:...:<targetN>]\n";202 print STDERR " <bmark> <srcdir> <dstdir>\n";203 exit(1);204 }207 sub ErrorExit($) {208 print STDERR @_ . "\n";209 exit(1);210 }