Mercurial > pygar
view scripts/setup-mit-6.375-bmark @ 36:99519a031813 pygar svn.37
[svn r37] moved the server into audioCorePipeline
author | punk |
---|---|
date | Tue, 04 May 2010 18:54:54 -0400 |
parents | 90197e3375e2 |
children |
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 $silent = undef;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 'silent=s' => \$silent,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 }78 chdir($dstdir) or ErrorExit("Failed to cd to $dstdir");80 mkdir('hasim_debug') or ErrorExit("Failed to make 'hasim_debug' directory");82 # Set up benchmark for non-null feeders83 if ($feeder ne "none") {84 my $src_prog;86 mkdir('program') or ErrorExit("Failed to make 'program' directory");88 if (defined($binary)) {89 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${binary}";90 }91 elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin") {92 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin";93 }94 elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh") {95 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh";96 }97 else {98 print STDERR "Can't find binary in ${benchmark_root}/hasim/${isa}/${group}\n";99 exit(1);100 }102 my $dst_prog = "program/" . basename($src_prog);104 unlink($dst_prog);105 symlink($src_prog, $dst_prog) or ErrorExit("Failed to symlink $dst_prog => $src_prog");106 }108 # Copy input data files109 if (defined($data)) {110 # No trailing slash. Just link to a single object111 print "data: $data\n";112 symlink("${srcdir}/${data}", "input.wav") or die("Failed to link to $data");113 }115 # Link to files or directories116 if (defined($linkto)) {117 foreach my $tgt (split(':', $linkto)) {118 if ($tgt =~ /\/$/) {119 # Trailing slash means link to all the files individually within120 # a directory.121 if (-d $tgt) {122 opendir(DIR, $tgt) || die("Cannot open directory for --linkto $tgt\n");123 my @tgt_objs = readdir(DIR);124 closedir(DIR);125 foreach my $t (@tgt_objs) {126 if (! (($t eq '.') || ($t eq '..'))) {127 symlink("${srcdir}/${tgt}${t}", basename($t)) or die("Failed to link to ${tgt}${t}");128 }129 }130 }131 }132 else {133 # No trailing slash. Just link to a single object134 symlink("${srcdir}/${tgt}", basename($tgt)) or die("Failed to link to $tgt");135 }136 }137 }139 # Store compare rules to config140 open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh");141 print ENV "ISA=\"${isa}\"\n";142 if (defined($compare)) {143 print ENV "compare=\"${compare}\"\n";144 }145 close(ENV);147 #store silent mode to config148 open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh");149 if (defined($silent)) {150 print ENV "silent=1\n";151 }152 close(ENV);154 # Set up m5 environment155 if ($feeder eq 'm5') {156 system("(cd $srcdir; tar cf - ./m5_configs) | tar xf -");157 }159 system("cp -f ${srcdir}/run.bmark run");160 chmod(0755, "run");162 exit(0);166 sub Usage() {167 print STDERR "Usage: setup-bmark [--binary <name>]\n";168 print STDERR " [--compare <compare commands>]\n";169 print STDERR " [--data <tar file>]\n";170 print STDERR " [--group <name>]\n";171 print STDERR " [--isa <name>]\n";172 print STDERR " [--linkto <target0>:...:<targetN>]\n";173 print STDERR " [--silent] \n";174 print STDERR " <bmark> <srcdir> <dstdir>\n";175 exit(1);176 }179 sub ErrorExit($) {180 print STDERR @_ . "\n";181 exit(1);182 }