view scripts/setup-mit-6.375-bmark-audio-core @ 71:86360c5ae9f2 pygar svn.72

[svn r72] added config for htg
author punk
date Wed, 12 May 2010 00:21:40 -0400
parents 97d1959f7c5c
children
line wrap: on
line source
1 #!/usr/bin/env perl
2 # -*- perl -*-
4 ##############################################################
5 #
6 # Benchmark setup for HAsim
7 #
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 warnings
24 #
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 switches
45 #
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 $pygarRoot = "$srcdir/..";
76 if (! defined($group)) {
77 $group = $bmark;
78 }
80 chdir($dstdir) or ErrorExit("Failed to cd to $dstdir");
82 mkdir('hasim_debug') or ErrorExit("Failed to make 'hasim_debug' directory");
84 # Set up benchmark for non-null feeders
85 my $context = 0;
86 while ($context < $numContexts) {
87 if ($feeder ne "none") {
88 my $src_prog;
90 mkdir("program.${context}") or ErrorExit("Failed to make program directory");
91 chdir("program.${context}") or ErrorExit("Failed to cd to program directory");
93 #print "***********************\n\n$benchmark_root --- ${benchmark_root}\n\n******************************\n";
95 if (defined($binary)) {
96 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${binary}";
97 }
99 elsif (-f "$pygarRoot/benchProgs/${bmark}.${isa}.vmh"){
100 print"\n*******************\n rlm:using speciel Pygar program\n**************************\n";
101 $src_prog = "$pygarRoot/benchProgs/${bmark}.${isa}.vmh";}
103 elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin") {
104 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin";
105 }
106 elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh") {
107 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh";
108 }
112 else {
113 print STDERR "Can't find binary in ${benchmark_root}/hasim/${isa}/${group}\n";
114 exit(1);
115 }
117 my $dst_prog = basename($src_prog);
119 unlink($dst_prog);
121 print "\n\nRLM: putting $src_prog in $dst_prog, and also program.vmh\n";
123 symlink($src_prog, $dst_prog) or ErrorExit("Failed to symlink $dst_prog => $src_prog");
124 symlink($src_prog, "program.vmh") or ErrorExit("Failed to symlink $dst_prog => $src_prog");
126 # Copy input data files
127 if (defined($data)) {
128 # No trailing slash. Just link to a single object
131 # rlm: oh my gosh here we go with TWO files!
132 print "\nRLM: moving TWO files:\n";
133 print "OHYEAH:: $data\n\n";
134 $data =~ m#^.*/([^/]*)\.wav$#;
135 #print "OHYYYYYYEAH::: $1\n\n\n!!!";
136 $newFile = $1."1.wav";
137 print "data: $data\n";
138 print "rlm: data2: $newFile\n";
139 print "\nrlm: move ${srcdir}/${data} to input.wav\n\n";
141 symlink("${srcdir}/${data}", "../input.wav") or die("Failed to link to $data");
142 symlink("${srcdir}/../benchmarks/audio_processor_test/$newFile", "../input1.wav") or die("Failed to link to $newFile");
145 }
146 # this came from processor bit and not sure what it is expecting
147 # Copy input data files
148 # if (defined($data)) {
149 # if ($data =~ /\.tar\.gz$/) {
150 # system("tar xzf ${data}");
151 # }
152 # elsif ($data =~ /\.tar$/) {
153 # system("tar xf ${data}");
154 # }
155 # }
157 # Link to files or directories
158 if (defined($linkto)) {
159 foreach my $tgt (split(':', $linkto)) {
160 if ($tgt =~ /\/$/) {
161 # Trailing slash means link to all the files individually within
162 # a directory.
163 if (-d $tgt) {
164 opendir(DIR, $tgt) || die("Cannot open directory for --linkto $tgt\n");
165 my @tgt_objs = readdir(DIR);
166 closedir(DIR);
167 foreach my $t (@tgt_objs) {
168 if (! (($t eq '.') || ($t eq '..'))) {
169 symlink("${tgt}${t}", basename($t)) or die("Failed to link to ${tgt}${t}");
170 }
171 }
172 }
173 }
174 else {
175 # No trailing slash. Just link to a single object
176 symlink($tgt, basename($tgt)) or die("Failed to link to $tgt");
177 }
178 }
179 }
181 # Back to main workload directory
182 chdir("..");
183 }
185 $context += 1;
186 }
188 # Store compare rules to config
189 open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh");
190 print ENV "ISA=\"${isa}\"\n";
191 if ($numContexts != 0) {
192 print ENV "workloadContexts=\"${numContexts}\"\n";
193 }
194 if (defined($compare)) {
195 print ENV "compare=\"${compare}\"\n";
196 #print ENV "compare=\"ls\"\n";
197 }
198 close(ENV);
200 # Set up m5 environment
201 if ($feeder eq 'm5') {
202 system("(cd $srcdir; tar cf - ./m5_configs) | tar xf -");
203 }
205 system("cp -f ${srcdir}/run.bmark run");
206 chmod(0755, "run");
208 exit(0);
212 sub Usage() {
213 print STDERR "Usage: setup-bmark [--binary <name>]\n";
214 print STDERR " [--compare <compare commands>]\n";
215 print STDERR " [--contexts <num workload contexts>]\n";
216 print STDERR " [--data <tar file>]\n";
217 print STDERR " [--group <name>]\n";
218 print STDERR " [--isa <name>]\n";
219 print STDERR " [--linkto <target0>:...:<targetN>]\n";
220 print STDERR " <bmark> <srcdir> <dstdir>\n";
221 exit(1);
222 }
225 sub ErrorExit($) {
226 print STDERR @_ . "\n";
227 exit(1);
228 }