annotate scripts/setup-mit-6.375-bmark-processor @ 65:cf8bb3038cbd pygar svn.66

[svn r66] sim passes
author punk
date Tue, 11 May 2010 09:05:22 -0400
parents 0c775e733b81
children
rev   line source
rlm@23 1 #!/usr/bin/env perl
rlm@23 2 # -*- perl -*-
rlm@23 3
rlm@23 4 ##############################################################
rlm@23 5 #
rlm@23 6 # Benchmark setup for HAsim
rlm@23 7 #
rlm@23 8 # Usage: setup-bmark <bmark> <srcdir> <destdir>
rlm@23 9 #
rlm@23 10 # Setup benchmark to run in <destdir>
rlm@23 11 #
rlm@23 12 ##############################################################
rlm@23 13
rlm@23 14 use strict;
rlm@23 15 use warnings;
rlm@23 16 use File::Basename;
rlm@23 17 use Getopt::Long;
rlm@23 18
rlm@23 19 sub Usage();
rlm@23 20 sub ErrorExit($);
rlm@23 21
rlm@23 22 #
rlm@23 23 # Turn on warnings
rlm@23 24 #
rlm@23 25 $^W = 1;
rlm@23 26
rlm@23 27 my $binary = undef;
rlm@23 28 my $compare = undef;
rlm@23 29 my $data = undef;
rlm@23 30 my $feeder = '';
rlm@23 31 my $group = undef;
rlm@23 32 my $isa = "unknown_ISA";
rlm@23 33 my $linkto = undef;
rlm@23 34 my $numContexts = 1;
rlm@23 35
rlm@23 36 #
rlm@23 37 # Find the root of the benchmarks directory tree.
rlm@23 38 #
rlm@23 39 my $benchmark_root = `awb-resolver --config=benchmarkdir`;
rlm@23 40 chomp($benchmark_root);
rlm@23 41 ErrorExit("Can't find benchmark root") if ($benchmark_root eq '');
rlm@23 42
rlm@23 43 #
rlm@23 44 # Parse the command line switches
rlm@23 45 #
rlm@23 46 if (! GetOptions('binary=s' => \$binary,
rlm@23 47 'compare=s' => \$compare,
rlm@23 48 'data=s' => \$data,
rlm@23 49 'feeder=s' => \$feeder,
rlm@23 50 'group=s' => \$group,
rlm@23 51 'isa=s' => \$isa,
rlm@23 52 'linkto=s' => \$linkto,
rlm@23 53 'contexts=i' => \$numContexts,
rlm@23 54 )) {
rlm@23 55 Usage();
rlm@23 56 }
rlm@23 57
rlm@23 58 if ($#ARGV != 2) {
rlm@23 59 Usage();
rlm@23 60 }
rlm@23 61
rlm@23 62 my $bmark = $ARGV[0];
rlm@23 63 my $srcdir = $ARGV[1];
rlm@23 64 my $dstdir = $ARGV[2];
punk@32 65 my $basedir = `pwd`;
punk@32 66 chomp($basedir);
rlm@23 67
rlm@23 68 print "BMARK: $bmark\n";
rlm@23 69 print "SRC: $srcdir\n";
rlm@23 70 print "DST: $dstdir\n";
punk@32 71 print "BASE: $basedir\n";
punk@32 72
rlm@23 73 if (! defined($group)) {
rlm@23 74 $group = $bmark;
rlm@23 75 }
rlm@23 76
rlm@23 77 chdir($dstdir) or ErrorExit("Failed to cd to $dstdir");
rlm@23 78
rlm@23 79 mkdir('hasim_debug') or ErrorExit("Failed to make 'hasim_debug' directory");
rlm@23 80
rlm@23 81 # Set up benchmark for non-null feeders
rlm@23 82 my $context = 0;
rlm@23 83 while ($context < $numContexts) {
rlm@23 84 if ($feeder ne "none") {
rlm@23 85 my $src_prog;
rlm@23 86
rlm@23 87 mkdir("program.${context}") or ErrorExit("Failed to make program directory");
rlm@23 88 chdir("program.${context}") or ErrorExit("Failed to cd to program directory");
rlm@23 89
rlm@23 90 if (defined($binary)) {
rlm@23 91 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${binary}";
rlm@23 92 }
rlm@23 93 elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin") {
rlm@23 94 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin";
rlm@23 95 }
rlm@23 96 elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh") {
rlm@23 97 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh";
rlm@23 98 }
rlm@23 99 else {
rlm@23 100 print STDERR "Can't find binary in ${benchmark_root}/hasim/${isa}/${group}\n";
rlm@23 101 exit(1);
rlm@23 102 }
rlm@23 103
rlm@23 104 my $dst_prog = basename($src_prog);
rlm@23 105
rlm@23 106 unlink($dst_prog);
rlm@23 107 symlink($src_prog, $dst_prog) or ErrorExit("Failed to symlink $dst_prog => $src_prog");
rlm@23 108
rlm@23 109 # Copy input data files
rlm@23 110 if (defined($data)) {
rlm@23 111 if ($data =~ /\.tar\.gz$/) {
rlm@23 112 system("tar xzf ${data}");
rlm@23 113 }
rlm@23 114 elsif ($data =~ /\.tar$/) {
rlm@23 115 system("tar xf ${data}");
rlm@23 116 }
rlm@23 117 }
rlm@23 118
rlm@23 119 # Link to files or directories
rlm@23 120 if (defined($linkto)) {
rlm@23 121 foreach my $tgt (split(':', $linkto)) {
rlm@23 122 if ($tgt =~ /\/$/) {
rlm@23 123 # Trailing slash means link to all the files individually within
rlm@23 124 # a directory.
rlm@23 125 if (-d $tgt) {
rlm@23 126 opendir(DIR, $tgt) || die("Cannot open directory for --linkto $tgt\n");
rlm@23 127 my @tgt_objs = readdir(DIR);
rlm@23 128 closedir(DIR);
rlm@23 129 foreach my $t (@tgt_objs) {
rlm@23 130 if (! (($t eq '.') || ($t eq '..'))) {
rlm@23 131 symlink("${tgt}${t}", basename($t)) or die("Failed to link to ${tgt}${t}");
rlm@23 132 }
rlm@23 133 }
rlm@23 134 }
rlm@23 135 }
rlm@23 136 else {
rlm@23 137 # No trailing slash. Just link to a single object
rlm@23 138 symlink($tgt, basename($tgt)) or die("Failed to link to $tgt");
rlm@23 139 }
rlm@23 140 }
rlm@23 141 }
rlm@23 142
rlm@23 143 # Back to main workload directory
rlm@23 144 chdir("..");
rlm@23 145 }
rlm@23 146
rlm@23 147 $context += 1;
rlm@23 148 }
rlm@23 149
rlm@23 150 # Store compare rules to config
rlm@23 151 open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh");
rlm@23 152 print ENV "ISA=\"${isa}\"\n";
rlm@23 153 if ($numContexts != 0) {
rlm@23 154 print ENV "workloadContexts=\"${numContexts}\"\n";
rlm@23 155 }
rlm@23 156 if (defined($compare)) {
rlm@23 157 print ENV "compare=\"${compare}\"\n";
rlm@23 158 }
rlm@23 159 close(ENV);
rlm@23 160
rlm@23 161 # Set up m5 environment
rlm@23 162 if ($feeder eq 'm5') {
rlm@23 163 system("(cd $srcdir; tar cf - ./m5_configs) | tar xf -");
rlm@23 164 }
rlm@23 165
rlm@23 166 system("cp -f ${srcdir}/run.bmark run");
rlm@23 167 chmod(0755, "run");
rlm@23 168
rlm@23 169 exit(0);
rlm@23 170
rlm@23 171
rlm@23 172
rlm@23 173 sub Usage() {
rlm@23 174 print STDERR "Usage: setup-bmark [--binary <name>]\n";
rlm@23 175 print STDERR " [--compare <compare commands>]\n";
rlm@23 176 print STDERR " [--contexts <num workload contexts>]\n";
rlm@23 177 print STDERR " [--data <tar file>]\n";
rlm@23 178 print STDERR " [--group <name>]\n";
rlm@23 179 print STDERR " [--isa <name>]\n";
rlm@23 180 print STDERR " [--linkto <target0>:...:<targetN>]\n";
rlm@23 181 print STDERR " <bmark> <srcdir> <dstdir>\n";
rlm@23 182 exit(1);
rlm@23 183 }
rlm@23 184
rlm@23 185
rlm@23 186 sub ErrorExit($) {
rlm@23 187 print STDERR @_ . "\n";
rlm@23 188 exit(1);
rlm@23 189 }