annotate scripts/setup-mit-6.375-bmark-processor @ 31:f41eef1bebfc pygar svn.32

[svn r32] Attempting to run soft core and audio
author punk
date Sat, 01 May 2010 11:50:20 -0400
parents 90197e3375e2
children 0c775e733b81
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];
rlm@23 65
rlm@23 66 print "BMARK: $bmark\n";
rlm@23 67 print "SRC: $srcdir\n";
rlm@23 68 print "DST: $dstdir\n";
rlm@23 69
rlm@23 70 if (! defined($group)) {
rlm@23 71 $group = $bmark;
rlm@23 72 }
rlm@23 73
rlm@23 74 chdir($dstdir) or ErrorExit("Failed to cd to $dstdir");
rlm@23 75
rlm@23 76 mkdir('hasim_debug') or ErrorExit("Failed to make 'hasim_debug' directory");
rlm@23 77
rlm@23 78 # Set up benchmark for non-null feeders
rlm@23 79 my $context = 0;
rlm@23 80 while ($context < $numContexts) {
rlm@23 81 if ($feeder ne "none") {
rlm@23 82 my $src_prog;
rlm@23 83
rlm@23 84 mkdir("program.${context}") or ErrorExit("Failed to make program directory");
rlm@23 85 chdir("program.${context}") or ErrorExit("Failed to cd to program directory");
rlm@23 86
rlm@23 87 if (defined($binary)) {
rlm@23 88 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${binary}";
rlm@23 89 }
rlm@23 90 elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin") {
rlm@23 91 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin";
rlm@23 92 }
rlm@23 93 elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh") {
rlm@23 94 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh";
rlm@23 95 }
rlm@23 96 else {
rlm@23 97 print STDERR "Can't find binary in ${benchmark_root}/hasim/${isa}/${group}\n";
rlm@23 98 exit(1);
rlm@23 99 }
rlm@23 100
rlm@23 101 my $dst_prog = basename($src_prog);
rlm@23 102
rlm@23 103 unlink($dst_prog);
rlm@23 104 symlink($src_prog, $dst_prog) or ErrorExit("Failed to symlink $dst_prog => $src_prog");
rlm@23 105
rlm@23 106 # Copy input data files
rlm@23 107 if (defined($data)) {
rlm@23 108 if ($data =~ /\.tar\.gz$/) {
rlm@23 109 system("tar xzf ${data}");
rlm@23 110 }
rlm@23 111 elsif ($data =~ /\.tar$/) {
rlm@23 112 system("tar xf ${data}");
rlm@23 113 }
rlm@23 114 }
rlm@23 115
rlm@23 116 # Link to files or directories
rlm@23 117 if (defined($linkto)) {
rlm@23 118 foreach my $tgt (split(':', $linkto)) {
rlm@23 119 if ($tgt =~ /\/$/) {
rlm@23 120 # Trailing slash means link to all the files individually within
rlm@23 121 # a directory.
rlm@23 122 if (-d $tgt) {
rlm@23 123 opendir(DIR, $tgt) || die("Cannot open directory for --linkto $tgt\n");
rlm@23 124 my @tgt_objs = readdir(DIR);
rlm@23 125 closedir(DIR);
rlm@23 126 foreach my $t (@tgt_objs) {
rlm@23 127 if (! (($t eq '.') || ($t eq '..'))) {
rlm@23 128 symlink("${tgt}${t}", basename($t)) or die("Failed to link to ${tgt}${t}");
rlm@23 129 }
rlm@23 130 }
rlm@23 131 }
rlm@23 132 }
rlm@23 133 else {
rlm@23 134 # No trailing slash. Just link to a single object
rlm@23 135 symlink($tgt, basename($tgt)) or die("Failed to link to $tgt");
rlm@23 136 }
rlm@23 137 }
rlm@23 138 }
rlm@23 139
rlm@23 140 # Back to main workload directory
rlm@23 141 chdir("..");
rlm@23 142 }
rlm@23 143
rlm@23 144 $context += 1;
rlm@23 145 }
rlm@23 146
rlm@23 147 # Store compare rules to config
rlm@23 148 open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh");
rlm@23 149 print ENV "ISA=\"${isa}\"\n";
rlm@23 150 if ($numContexts != 0) {
rlm@23 151 print ENV "workloadContexts=\"${numContexts}\"\n";
rlm@23 152 }
rlm@23 153 if (defined($compare)) {
rlm@23 154 print ENV "compare=\"${compare}\"\n";
rlm@23 155 }
rlm@23 156 close(ENV);
rlm@23 157
rlm@23 158 # Set up m5 environment
rlm@23 159 if ($feeder eq 'm5') {
rlm@23 160 system("(cd $srcdir; tar cf - ./m5_configs) | tar xf -");
rlm@23 161 }
rlm@23 162
rlm@23 163 system("cp -f ${srcdir}/run.bmark run");
rlm@23 164 chmod(0755, "run");
rlm@23 165
rlm@23 166 exit(0);
rlm@23 167
rlm@23 168
rlm@23 169
rlm@23 170 sub Usage() {
rlm@23 171 print STDERR "Usage: setup-bmark [--binary <name>]\n";
rlm@23 172 print STDERR " [--compare <compare commands>]\n";
rlm@23 173 print STDERR " [--contexts <num workload contexts>]\n";
rlm@23 174 print STDERR " [--data <tar file>]\n";
rlm@23 175 print STDERR " [--group <name>]\n";
rlm@23 176 print STDERR " [--isa <name>]\n";
rlm@23 177 print STDERR " [--linkto <target0>:...:<targetN>]\n";
rlm@23 178 print STDERR " <bmark> <srcdir> <dstdir>\n";
rlm@23 179 exit(1);
rlm@23 180 }
rlm@23 181
rlm@23 182
rlm@23 183 sub ErrorExit($) {
rlm@23 184 print STDERR @_ . "\n";
rlm@23 185 exit(1);
rlm@23 186 }