Mercurial > pygar
view scripts/setup-mit-6.375-bmark-audio-core~ @ 48:a139cc07b773 pygar svn.49
[svn r49] moved memory into core
author | punk |
---|---|
date | Wed, 05 May 2010 13:42:07 -0400 |
parents | 0c775e733b81 |
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 $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 object112 print "data: $data\n";113 symlink("${srcdir}/${data}", "input.wav") or die("Failed to link to $data");114 }116 # Copy input data files117 if (defined($data)) {118 if ($data =~ /\.tar\.gz$/) {119 system("tar xzf ${data}");120 }121 elsif ($data =~ /\.tar$/) {122 system("tar xf ${data}");123 }124 }126 # Link to files or directories127 if (defined($linkto)) {128 foreach my $tgt (split(':', $linkto)) {129 if ($tgt =~ /\/$/) {130 # Trailing slash means link to all the files individually within131 # a directory.132 if (-d $tgt) {133 opendir(DIR, $tgt) || die("Cannot open directory for --linkto $tgt\n");134 my @tgt_objs = readdir(DIR);135 closedir(DIR);136 foreach my $t (@tgt_objs) {137 if (! (($t eq '.') || ($t eq '..'))) {138 symlink("${tgt}${t}", basename($t)) or die("Failed to link to ${tgt}${t}");139 }140 }141 }142 }143 else {144 # No trailing slash. Just link to a single object145 symlink($tgt, basename($tgt)) or die("Failed to link to $tgt");146 }147 }148 }150 # Back to main workload directory151 chdir("..");152 }154 $context += 1;155 }157 # Store compare rules to config158 open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh");159 print ENV "ISA=\"${isa}\"\n";160 if ($numContexts != 0) {161 print ENV "workloadContexts=\"${numContexts}\"\n";162 }163 if (defined($compare)) {164 print ENV "compare=\"${compare}\"\n";165 }166 close(ENV);168 # Set up m5 environment169 if ($feeder eq 'm5') {170 system("(cd $srcdir; tar cf - ./m5_configs) | tar xf -");171 }173 system("cp -f ${srcdir}/run.bmark run");174 chmod(0755, "run");176 exit(0);180 sub Usage() {181 print STDERR "Usage: setup-bmark [--binary <name>]\n";182 print STDERR " [--compare <compare commands>]\n";183 print STDERR " [--contexts <num workload contexts>]\n";184 print STDERR " [--data <tar file>]\n";185 print STDERR " [--group <name>]\n";186 print STDERR " [--isa <name>]\n";187 print STDERR " [--linkto <target0>:...:<targetN>]\n";188 print STDERR " <bmark> <srcdir> <dstdir>\n";189 exit(1);190 }193 sub ErrorExit($) {194 print STDERR @_ . "\n";195 exit(1);196 }