annotate scripts/setup-null-bmark @ 23:90197e3375e2 pygar svn.24

[svn r24] added testing, but something is wrong with our c++ file.
author rlm
date Wed, 28 Apr 2010 08:19:09 -0400
parents
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 $silent = undef;
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 'silent=s' => \$silent,
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 my $basedir = `pwd`;
rlm@23 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";
rlm@23 71 print "BASE: $basedir\n";
rlm@23 72
rlm@23 73 if (! defined($group)) {
rlm@23 74 $group = $bmark;
rlm@23 75 }
rlm@23 76
rlm@23 77
rlm@23 78 chdir($dstdir) or ErrorExit("Failed to cd to $dstdir");
rlm@23 79
rlm@23 80 mkdir('hasim_debug') or ErrorExit("Failed to make 'hasim_debug' directory");
rlm@23 81
rlm@23 82 # Set up benchmark for non-null feeders
rlm@23 83 if ($feeder ne "none") {
rlm@23 84 my $src_prog;
rlm@23 85
rlm@23 86 mkdir('program') or ErrorExit("Failed to make 'program' directory");
rlm@23 87
rlm@23 88 if (defined($binary)) {
rlm@23 89 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${binary}";
rlm@23 90 }
rlm@23 91 elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin") {
rlm@23 92 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin";
rlm@23 93 }
rlm@23 94 elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh") {
rlm@23 95 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh";
rlm@23 96 }
rlm@23 97 else {
rlm@23 98 print STDERR "Can't find binary in ${benchmark_root}/hasim/${isa}/${group}\n";
rlm@23 99 exit(1);
rlm@23 100 }
rlm@23 101
rlm@23 102 my $dst_prog = "program/" . basename($src_prog);
rlm@23 103
rlm@23 104 unlink($dst_prog);
rlm@23 105 symlink($src_prog, $dst_prog) or ErrorExit("Failed to symlink $dst_prog => $src_prog");
rlm@23 106 }
rlm@23 107
rlm@23 108 # Copy input data files
rlm@23 109 if (defined($data)) {
rlm@23 110 # No trailing slash. Just link to a single object
rlm@23 111 print "data: $data\n";
rlm@23 112 symlink("${srcdir}/${data}", "input.wav") or die("Failed to link to $data");
rlm@23 113 }
rlm@23 114
rlm@23 115 # Link to files or directories
rlm@23 116 if (defined($linkto)) {
rlm@23 117 foreach my $tgt (split(':', $linkto)) {
rlm@23 118 if ($tgt =~ /\/$/) {
rlm@23 119 # Trailing slash means link to all the files individually within
rlm@23 120 # a directory.
rlm@23 121 if (-d $tgt) {
rlm@23 122 opendir(DIR, $tgt) || die("Cannot open directory for --linkto $tgt\n");
rlm@23 123 my @tgt_objs = readdir(DIR);
rlm@23 124 closedir(DIR);
rlm@23 125 foreach my $t (@tgt_objs) {
rlm@23 126 if (! (($t eq '.') || ($t eq '..'))) {
rlm@23 127 symlink("${srcdir}/${tgt}${t}", basename($t)) or die("Failed to link to ${tgt}${t}");
rlm@23 128 }
rlm@23 129 }
rlm@23 130 }
rlm@23 131 }
rlm@23 132 else {
rlm@23 133 # No trailing slash. Just link to a single object
rlm@23 134 symlink("${srcdir}/${tgt}", basename($tgt)) or die("Failed to link to $tgt");
rlm@23 135 }
rlm@23 136 }
rlm@23 137 }
rlm@23 138
rlm@23 139 # Store compare rules to config
rlm@23 140 open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh");
rlm@23 141 print ENV "ISA=\"${isa}\"\n";
rlm@23 142 if (defined($compare)) {
rlm@23 143 print ENV "compare=\"${compare}\"\n";
rlm@23 144 }
rlm@23 145 close(ENV);
rlm@23 146
rlm@23 147 #store silent mode to config
rlm@23 148 open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh");
rlm@23 149 if (defined($silent)) {
rlm@23 150 print ENV "silent=1\n";
rlm@23 151 }
rlm@23 152 close(ENV);
rlm@23 153
rlm@23 154 # Set up m5 environment
rlm@23 155 if ($feeder eq 'm5') {
rlm@23 156 system("(cd $srcdir; tar cf - ./m5_configs) | tar xf -");
rlm@23 157 }
rlm@23 158
rlm@23 159 system("cp -f ${srcdir}/run-null.bmark run");
rlm@23 160 chmod(0755, "run");
rlm@23 161
rlm@23 162 exit(0);
rlm@23 163
rlm@23 164
rlm@23 165
rlm@23 166 sub Usage() {
rlm@23 167 print STDERR "Usage: setup-bmark [--binary <name>]\n";
rlm@23 168 print STDERR " [--compare <compare commands>]\n";
rlm@23 169 print STDERR " [--data <tar file>]\n";
rlm@23 170 print STDERR " [--group <name>]\n";
rlm@23 171 print STDERR " [--isa <name>]\n";
rlm@23 172 print STDERR " [--linkto <target0>:...:<targetN>]\n";
rlm@23 173 print STDERR " [--silent] \n";
rlm@23 174 print STDERR " <bmark> <srcdir> <dstdir>\n";
rlm@23 175 exit(1);
rlm@23 176 }
rlm@23 177
rlm@23 178
rlm@23 179 sub ErrorExit($) {
rlm@23 180 print STDERR @_ . "\n";
rlm@23 181 exit(1);
rlm@23 182 }