Mercurial > pygar
diff scripts/setup-mit-6.375-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 |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/scripts/setup-mit-6.375-bmark Wed Apr 28 08:19:09 2010 -0400 1.3 @@ -0,0 +1,182 @@ 1.4 +#!/usr/bin/env perl 1.5 +# -*- perl -*- 1.6 + 1.7 +############################################################## 1.8 +# 1.9 +# Benchmark setup for HAsim 1.10 +# 1.11 +# Usage: setup-bmark <bmark> <srcdir> <destdir> 1.12 +# 1.13 +# Setup benchmark to run in <destdir> 1.14 +# 1.15 +############################################################## 1.16 + 1.17 +use strict; 1.18 +use warnings; 1.19 +use File::Basename; 1.20 +use Getopt::Long; 1.21 + 1.22 +sub Usage(); 1.23 +sub ErrorExit($); 1.24 + 1.25 +# 1.26 +# Turn on warnings 1.27 +# 1.28 +$^W = 1; 1.29 + 1.30 +my $binary = undef; 1.31 +my $compare = undef; 1.32 +my $data = undef; 1.33 +my $feeder = ''; 1.34 +my $group = undef; 1.35 +my $isa = "unknown_ISA"; 1.36 +my $linkto = undef; 1.37 +my $silent = undef; 1.38 + 1.39 +# 1.40 +# Find the root of the benchmarks directory tree. 1.41 +# 1.42 +my $benchmark_root = `awb-resolver --config=benchmarkdir`; 1.43 +chomp($benchmark_root); 1.44 +ErrorExit("Can't find benchmark root") if ($benchmark_root eq ''); 1.45 + 1.46 +# 1.47 +# Parse the command line switches 1.48 +# 1.49 +if (! GetOptions('binary=s' => \$binary, 1.50 + 'compare=s' => \$compare, 1.51 + 'data=s' => \$data, 1.52 + 'feeder=s' => \$feeder, 1.53 + 'group=s' => \$group, 1.54 + 'isa=s' => \$isa, 1.55 + 'linkto=s' => \$linkto, 1.56 + 'silent=s' => \$silent, 1.57 + )) { 1.58 + Usage(); 1.59 +} 1.60 + 1.61 +if ($#ARGV != 2) { 1.62 + Usage(); 1.63 +} 1.64 + 1.65 +my $bmark = $ARGV[0]; 1.66 +my $srcdir = $ARGV[1]; 1.67 +my $dstdir = $ARGV[2]; 1.68 +my $basedir = `pwd`; 1.69 +chomp($basedir); 1.70 + 1.71 +print "BMARK: $bmark\n"; 1.72 +print "SRC: $srcdir\n"; 1.73 +print "DST: $dstdir\n"; 1.74 +print "BASE: $basedir\n"; 1.75 + 1.76 +if (! defined($group)) { 1.77 + $group = $bmark; 1.78 +} 1.79 + 1.80 + 1.81 +chdir($dstdir) or ErrorExit("Failed to cd to $dstdir"); 1.82 + 1.83 +mkdir('hasim_debug') or ErrorExit("Failed to make 'hasim_debug' directory"); 1.84 + 1.85 +# Set up benchmark for non-null feeders 1.86 +if ($feeder ne "none") { 1.87 + my $src_prog; 1.88 + 1.89 + mkdir('program') or ErrorExit("Failed to make 'program' directory"); 1.90 + 1.91 + if (defined($binary)) { 1.92 + $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${binary}"; 1.93 + } 1.94 + elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin") { 1.95 + $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin"; 1.96 + } 1.97 + elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh") { 1.98 + $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh"; 1.99 + } 1.100 + else { 1.101 + print STDERR "Can't find binary in ${benchmark_root}/hasim/${isa}/${group}\n"; 1.102 + exit(1); 1.103 + } 1.104 + 1.105 + my $dst_prog = "program/" . basename($src_prog); 1.106 + 1.107 + unlink($dst_prog); 1.108 + symlink($src_prog, $dst_prog) or ErrorExit("Failed to symlink $dst_prog => $src_prog"); 1.109 +} 1.110 + 1.111 +# Copy input data files 1.112 +if (defined($data)) { 1.113 + # No trailing slash. Just link to a single object 1.114 + print "data: $data\n"; 1.115 + symlink("${srcdir}/${data}", "input.wav") or die("Failed to link to $data"); 1.116 +} 1.117 + 1.118 +# Link to files or directories 1.119 +if (defined($linkto)) { 1.120 + foreach my $tgt (split(':', $linkto)) { 1.121 + if ($tgt =~ /\/$/) { 1.122 + # Trailing slash means link to all the files individually within 1.123 + # a directory. 1.124 + if (-d $tgt) { 1.125 + opendir(DIR, $tgt) || die("Cannot open directory for --linkto $tgt\n"); 1.126 + my @tgt_objs = readdir(DIR); 1.127 + closedir(DIR); 1.128 + foreach my $t (@tgt_objs) { 1.129 + if (! (($t eq '.') || ($t eq '..'))) { 1.130 + symlink("${srcdir}/${tgt}${t}", basename($t)) or die("Failed to link to ${tgt}${t}"); 1.131 + } 1.132 + } 1.133 + } 1.134 + } 1.135 + else { 1.136 + # No trailing slash. Just link to a single object 1.137 + symlink("${srcdir}/${tgt}", basename($tgt)) or die("Failed to link to $tgt"); 1.138 + } 1.139 + } 1.140 +} 1.141 + 1.142 +# Store compare rules to config 1.143 +open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh"); 1.144 +print ENV "ISA=\"${isa}\"\n"; 1.145 +if (defined($compare)) { 1.146 + print ENV "compare=\"${compare}\"\n"; 1.147 +} 1.148 +close(ENV); 1.149 + 1.150 +#store silent mode to config 1.151 +open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh"); 1.152 +if (defined($silent)) { 1.153 + print ENV "silent=1\n"; 1.154 +} 1.155 +close(ENV); 1.156 + 1.157 +# Set up m5 environment 1.158 +if ($feeder eq 'm5') { 1.159 + system("(cd $srcdir; tar cf - ./m5_configs) | tar xf -"); 1.160 +} 1.161 + 1.162 +system("cp -f ${srcdir}/run.bmark run"); 1.163 +chmod(0755, "run"); 1.164 + 1.165 +exit(0); 1.166 + 1.167 + 1.168 + 1.169 +sub Usage() { 1.170 + print STDERR "Usage: setup-bmark [--binary <name>]\n"; 1.171 + print STDERR " [--compare <compare commands>]\n"; 1.172 + print STDERR " [--data <tar file>]\n"; 1.173 + print STDERR " [--group <name>]\n"; 1.174 + print STDERR " [--isa <name>]\n"; 1.175 + print STDERR " [--linkto <target0>:...:<targetN>]\n"; 1.176 + print STDERR " [--silent] \n"; 1.177 + print STDERR " <bmark> <srcdir> <dstdir>\n"; 1.178 + exit(1); 1.179 +} 1.180 + 1.181 + 1.182 +sub ErrorExit($) { 1.183 + print STDERR @_ . "\n"; 1.184 + exit(1); 1.185 +}