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