view scripts/setup-mit-6.375-bmark-processor @ 25:220c14f5963c pygar svn.26

[svn r26] Not fully connected but passes audio successfully
author punk
date Wed, 28 Apr 2010 12:01:37 -0400
parents 90197e3375e2
children 0c775e733b81
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];
66 print "BMARK: $bmark\n";
67 print "SRC: $srcdir\n";
68 print "DST: $dstdir\n";
70 if (! defined($group)) {
71 $group = $bmark;
72 }
74 chdir($dstdir) or ErrorExit("Failed to cd to $dstdir");
76 mkdir('hasim_debug') or ErrorExit("Failed to make 'hasim_debug' directory");
78 # Set up benchmark for non-null feeders
79 my $context = 0;
80 while ($context < $numContexts) {
81 if ($feeder ne "none") {
82 my $src_prog;
84 mkdir("program.${context}") or ErrorExit("Failed to make program directory");
85 chdir("program.${context}") or ErrorExit("Failed to cd to program directory");
87 if (defined($binary)) {
88 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${binary}";
89 }
90 elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin") {
91 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.bin";
92 }
93 elsif (-f "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh") {
94 $src_prog = "${benchmark_root}/hasim/${isa}/${group}/${bmark}.${isa}.vmh";
95 }
96 else {
97 print STDERR "Can't find binary in ${benchmark_root}/hasim/${isa}/${group}\n";
98 exit(1);
99 }
101 my $dst_prog = basename($src_prog);
103 unlink($dst_prog);
104 symlink($src_prog, $dst_prog) or ErrorExit("Failed to symlink $dst_prog => $src_prog");
106 # Copy input data files
107 if (defined($data)) {
108 if ($data =~ /\.tar\.gz$/) {
109 system("tar xzf ${data}");
110 }
111 elsif ($data =~ /\.tar$/) {
112 system("tar xf ${data}");
113 }
114 }
116 # Link to files or directories
117 if (defined($linkto)) {
118 foreach my $tgt (split(':', $linkto)) {
119 if ($tgt =~ /\/$/) {
120 # Trailing slash means link to all the files individually within
121 # a directory.
122 if (-d $tgt) {
123 opendir(DIR, $tgt) || die("Cannot open directory for --linkto $tgt\n");
124 my @tgt_objs = readdir(DIR);
125 closedir(DIR);
126 foreach my $t (@tgt_objs) {
127 if (! (($t eq '.') || ($t eq '..'))) {
128 symlink("${tgt}${t}", basename($t)) or die("Failed to link to ${tgt}${t}");
129 }
130 }
131 }
132 }
133 else {
134 # No trailing slash. Just link to a single object
135 symlink($tgt, basename($tgt)) or die("Failed to link to $tgt");
136 }
137 }
138 }
140 # Back to main workload directory
141 chdir("..");
142 }
144 $context += 1;
145 }
147 # Store compare rules to config
148 open(ENV, '>>config/env.sh') or die("Failed to open config/env.sh");
149 print ENV "ISA=\"${isa}\"\n";
150 if ($numContexts != 0) {
151 print ENV "workloadContexts=\"${numContexts}\"\n";
152 }
153 if (defined($compare)) {
154 print ENV "compare=\"${compare}\"\n";
155 }
156 close(ENV);
158 # Set up m5 environment
159 if ($feeder eq 'm5') {
160 system("(cd $srcdir; tar cf - ./m5_configs) | tar xf -");
161 }
163 system("cp -f ${srcdir}/run.bmark run");
164 chmod(0755, "run");
166 exit(0);
170 sub Usage() {
171 print STDERR "Usage: setup-bmark [--binary <name>]\n";
172 print STDERR " [--compare <compare commands>]\n";
173 print STDERR " [--contexts <num workload contexts>]\n";
174 print STDERR " [--data <tar file>]\n";
175 print STDERR " [--group <name>]\n";
176 print STDERR " [--isa <name>]\n";
177 print STDERR " [--linkto <target0>:...:<targetN>]\n";
178 print STDERR " <bmark> <srcdir> <dstdir>\n";
179 exit(1);
180 }
183 sub ErrorExit($) {
184 print STDERR @_ . "\n";
185 exit(1);
186 }