Mercurial > pygar
comparison scripts/setup-mit-6.375-bmark-audio-core~ @ 32:0c775e733b81 pygar svn.33
[svn r33] audio core benchmark script added and the benchmark setup is half-way to working
author | punk |
---|---|
date | Mon, 03 May 2010 09:53:56 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
31:f41eef1bebfc | 32:0c775e733b81 |
---|---|
1 #!/usr/bin/env perl | |
2 # -*- perl -*- | |
3 | |
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 ############################################################## | |
13 | |
14 use strict; | |
15 use warnings; | |
16 use File::Basename; | |
17 use Getopt::Long; | |
18 | |
19 sub Usage(); | |
20 sub ErrorExit($); | |
21 | |
22 # | |
23 # Turn on warnings | |
24 # | |
25 $^W = 1; | |
26 | |
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; | |
35 | |
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 ''); | |
42 | |
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 } | |
57 | |
58 if ($#ARGV != 2) { | |
59 Usage(); | |
60 } | |
61 | |
62 my $bmark = $ARGV[0]; | |
63 my $srcdir = $ARGV[1]; | |
64 my $dstdir = $ARGV[2]; | |
65 my $basedir = `pwd`; | |
66 chomp($basedir); | |
67 | |
68 print "BMARK: $bmark\n"; | |
69 print "SRC: $srcdir\n"; | |
70 print "DST: $dstdir\n"; | |
71 print "BASE: $basedir\n"; | |
72 | |
73 if (! defined($group)) { | |
74 $group = $bmark; | |
75 } | |
76 | |
77 chdir($dstdir) or ErrorExit("Failed to cd to $dstdir"); | |
78 | |
79 mkdir('hasim_debug') or ErrorExit("Failed to make 'hasim_debug' directory"); | |
80 | |
81 # Set up benchmark for non-null feeders | |
82 my $context = 0; | |
83 while ($context < $numContexts) { | |
84 if ($feeder ne "none") { | |
85 my $src_prog; | |
86 | |
87 mkdir("program.${context}") or ErrorExit("Failed to make program directory"); | |
88 chdir("program.${context}") or ErrorExit("Failed to cd to program directory"); | |
89 | |
90 if (defined($binary)) { | |
91 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${binary}"; | |
92 } | |
93 elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin") { | |
94 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin"; | |
95 } | |
96 elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh") { | |
97 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh"; | |
98 } | |
99 else { | |
100 print STDERR "Can't find binary in ${benchmark_root}/hasim/${isa}/${group}\n"; | |
101 exit(1); | |
102 } | |
103 | |
104 my $dst_prog = basename($src_prog); | |
105 | |
106 unlink($dst_prog); | |
107 symlink($src_prog, $dst_prog) or ErrorExit("Failed to symlink $dst_prog => $src_prog"); | |
108 | |
109 # Copy input data files | |
110 if (defined($data)) { | |
111 # No trailing slash. Just link to a single object | |
112 print "data: $data\n"; | |
113 symlink("${srcdir}/${data}", "input.wav") or die("Failed to link to $data"); | |
114 } | |
115 | |
116 # Copy input data files | |
117 if (defined($data)) { | |
118 if ($data =~ /\.tar\.gz$/) { | |
119 system("tar xzf ${data}"); | |
120 } | |
121 elsif ($data =~ /\.tar$/) { | |
122 system("tar xf ${data}"); | |
123 } | |
124 } | |
125 | |
126 # Link to files or directories | |
127 if (defined($linkto)) { | |
128 foreach my $tgt (split(':', $linkto)) { | |
129 if ($tgt =~ /\/$/) { | |
130 # Trailing slash means link to all the files individually within | |
131 # a directory. | |
132 if (-d $tgt) { | |
133 opendir(DIR, $tgt) || die("Cannot open directory for --linkto $tgt\n"); | |
134 my @tgt_objs = readdir(DIR); | |
135 closedir(DIR); | |
136 foreach my $t (@tgt_objs) { | |
137 if (! (($t eq '.') || ($t eq '..'))) { | |
138 symlink("${tgt}${t}", basename($t)) or die("Failed to link to ${tgt}${t}"); | |
139 } | |
140 } | |
141 } | |
142 } | |
143 else { | |
144 # No trailing slash. Just link to a single object | |
145 symlink($tgt, basename($tgt)) or die("Failed to link to $tgt"); | |
146 } | |
147 } | |
148 } | |
149 | |
150 # Back to main workload directory | |
151 chdir(".."); | |
152 } | |
153 | |
154 $context += 1; | |
155 } | |
156 | |
157 # Store compare rules to config | |
158 open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh"); | |
159 print ENV "ISA=\"${isa}\"\n"; | |
160 if ($numContexts != 0) { | |
161 print ENV "workloadContexts=\"${numContexts}\"\n"; | |
162 } | |
163 if (defined($compare)) { | |
164 print ENV "compare=\"${compare}\"\n"; | |
165 } | |
166 close(ENV); | |
167 | |
168 # Set up m5 environment | |
169 if ($feeder eq 'm5') { | |
170 system("(cd $srcdir; tar cf - ./m5_configs) | tar xf -"); | |
171 } | |
172 | |
173 system("cp -f ${srcdir}/run.bmark run"); | |
174 chmod(0755, "run"); | |
175 | |
176 exit(0); | |
177 | |
178 | |
179 | |
180 sub Usage() { | |
181 print STDERR "Usage: setup-bmark [--binary <name>]\n"; | |
182 print STDERR " [--compare <compare commands>]\n"; | |
183 print STDERR " [--contexts <num workload contexts>]\n"; | |
184 print STDERR " [--data <tar file>]\n"; | |
185 print STDERR " [--group <name>]\n"; | |
186 print STDERR " [--isa <name>]\n"; | |
187 print STDERR " [--linkto <target0>:...:<targetN>]\n"; | |
188 print STDERR " <bmark> <srcdir> <dstdir>\n"; | |
189 exit(1); | |
190 } | |
191 | |
192 | |
193 sub ErrorExit($) { | |
194 print STDERR @_ . "\n"; | |
195 exit(1); | |
196 } |