Mercurial > pygar
view scripts/setup-mit-6.375-bmark-processor @ 76:8bd0e4d37ad2 pygar svn.77 tip
[svn r77] I don't know why my last change didn't go through grumble grumble....
author | rlm |
---|---|
date | Wed, 12 May 2010 08:58:23 -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 if ($data =~ /\.tar\.gz$/) {112 system("tar xzf ${data}");113 }114 elsif ($data =~ /\.tar$/) {115 system("tar xf ${data}");116 }117 }119 # Link to files or directories120 if (defined($linkto)) {121 foreach my $tgt (split(':', $linkto)) {122 if ($tgt =~ /\/$/) {123 # Trailing slash means link to all the files individually within124 # a directory.125 if (-d $tgt) {126 opendir(DIR, $tgt) || die("Cannot open directory for --linkto $tgt\n");127 my @tgt_objs = readdir(DIR);128 closedir(DIR);129 foreach my $t (@tgt_objs) {130 if (! (($t eq '.') || ($t eq '..'))) {131 symlink("${tgt}${t}", basename($t)) or die("Failed to link to ${tgt}${t}");132 }133 }134 }135 }136 else {137 # No trailing slash. Just link to a single object138 symlink($tgt, basename($tgt)) or die("Failed to link to $tgt");139 }140 }141 }143 # Back to main workload directory144 chdir("..");145 }147 $context += 1;148 }150 # Store compare rules to config151 open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh");152 print ENV "ISA=\"${isa}\"\n";153 if ($numContexts != 0) {154 print ENV "workloadContexts=\"${numContexts}\"\n";155 }156 if (defined($compare)) {157 print ENV "compare=\"${compare}\"\n";158 }159 close(ENV);161 # Set up m5 environment162 if ($feeder eq 'm5') {163 system("(cd $srcdir; tar cf - ./m5_configs) | tar xf -");164 }166 system("cp -f ${srcdir}/run.bmark run");167 chmod(0755, "run");169 exit(0);173 sub Usage() {174 print STDERR "Usage: setup-bmark [--binary <name>]\n";175 print STDERR " [--compare <compare commands>]\n";176 print STDERR " [--contexts <num workload contexts>]\n";177 print STDERR " [--data <tar file>]\n";178 print STDERR " [--group <name>]\n";179 print STDERR " [--isa <name>]\n";180 print STDERR " [--linkto <target0>:...:<targetN>]\n";181 print STDERR " <bmark> <srcdir> <dstdir>\n";182 exit(1);183 }186 sub ErrorExit($) {187 print STDERR @_ . "\n";188 exit(1);189 }