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