Merge zizzer:/bk/sparcfs
[gem5.git] / configs / common / cpu2000.py
1 # Copyright (c) 2006 The Regents of The University of Michigan
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met: redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer;
8 # redistributions in binary form must reproduce the above copyright
9 # notice, this list of conditions and the following disclaimer in the
10 # documentation and/or other materials provided with the distribution;
11 # neither the name of the copyright holders nor the names of its
12 # contributors may be used to endorse or promote products derived from
13 # this software without specific prior written permission.
14 #
15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #
27 # Authors: Nathan Binkert
28
29 import os
30 import sys
31 from os.path import basename, exists, join as joinpath, normpath
32 from os.path import isdir, isfile, islink
33
34 spec_dist = '/dist/m5/cpu2000'
35
36 def copyfiles(srcdir, dstdir):
37 from filecmp import cmp as filecmp
38 from shutil import copyfile
39
40 srcdir = normpath(srcdir)
41 dstdir = normpath(dstdir)
42
43 if not isdir(dstdir):
44 os.mkdir(dstdir)
45
46 for root, dirs, files in os.walk(srcdir):
47 root = normpath(root)
48 prefix = os.path.commonprefix([root, srcdir])
49
50 root = root[len(prefix):]
51 if root.startswith('/'):
52 root = root[1:]
53
54 for entry in dirs:
55 newdir = joinpath(dstdir, root, entry)
56 if not isdir(newdir):
57 os.mkdir(newdir)
58
59 for entry in files:
60 dest = normpath(joinpath(dstdir, root, entry))
61 src = normpath(joinpath(srcdir, root, entry))
62 if not isfile(dest) or not filecmp(src, dest):
63 copyfile(src, dest)
64
65 # some of the spec benchmarks expect to be run from one directory up.
66 # just create some symlinks that solve the problem
67 inlink = joinpath(dstdir, 'input')
68 outlink = joinpath(dstdir, 'output')
69 if not exists(inlink):
70 os.symlink('.', inlink)
71 if not exists(outlink):
72 os.symlink('.', outlink)
73
74 class Benchmark(object):
75 def __init__(self, isa, os, input_set):
76 if not hasattr(self.__class__, 'name'):
77 self.name = self.__class__.__name__
78
79 if not hasattr(self.__class__, 'binary'):
80 self.binary = self.name
81
82 if not hasattr(self.__class__, 'args'):
83 self.args = []
84
85 if not hasattr(self.__class__, 'output'):
86 self.output = '%s.out' % self.name
87
88 try:
89 func = getattr(self.__class__, input_set)
90 except AttributeError:
91 raise AttributeError, \
92 'The benchmark %s does not have the %s input set' % \
93 (self.name, input_set)
94
95 executable = joinpath(spec_dist, 'binaries', isa, os, self.binary)
96 if not isfile(executable):
97 raise AttributeError, '%s not found' % executable
98 self.executable = executable
99
100 # root of tree for input & output data files
101 data_dir = joinpath(spec_dist, 'data', self.name)
102 # optional subtree with files shared across input sets
103 all_dir = joinpath(data_dir, 'all')
104 # dirs for input & output files for this input set
105 inputs_dir = joinpath(data_dir, input_set, 'input')
106 outputs_dir = joinpath(data_dir, input_set, 'output')
107
108 if not isdir(inputs_dir):
109 raise AttributeError, '%s not found' % inputs_dir
110
111 self.inputs_dir = [ inputs_dir ]
112 if isdir(all_dir):
113 self.inputs_dir += [ joinpath(all_dir, 'input') ]
114 if isdir(outputs_dir):
115 self.outputs_dir = outputs_dir
116
117 if not hasattr(self.__class__, 'stdin'):
118 self.stdin = joinpath(inputs_dir, '%s.in' % self.name)
119 if not isfile(self.stdin):
120 self.stdin = None
121
122 if not hasattr(self.__class__, 'stdout'):
123 self.stdout = joinpath(outputs_dir, '%s.out' % self.name)
124 if not isfile(self.stdout):
125 self.stdout = None
126
127 func(self, isa, os)
128
129 def makeLiveProcessArgs(self, **kwargs):
130 # set up default args for LiveProcess object
131 process_args = {}
132 process_args['cmd'] = self.name + ' ' + ' '.join(self.args)
133 process_args['executable'] = self.executable
134 if self.stdin:
135 process_args['input'] = self.stdin
136 if self.stdout:
137 process_args['output'] = self.stdout
138
139 # explicit keywords override defaults
140 process_args.update(kwargs)
141
142 return process_args
143
144 def makeLiveProcess(self, **kwargs):
145 process_args = self.makeLiveProcessArgs(**kwargs)
146
147 # figure out working directory: use m5's outdir unless
148 # overridden by LiveProcess's cwd param
149 cwd = process_args.get('cwd')
150 if not cwd:
151 from m5.main import options
152 cwd = options.outdir
153 process_args['cwd'] = cwd
154 if not isdir(cwd):
155 os.makedirs(cwd)
156 # copy input files to working directory
157 for d in self.inputs_dir:
158 copyfiles(d, cwd)
159 # generate LiveProcess object
160 from m5.objects import LiveProcess
161 return LiveProcess(**process_args)
162
163 def __str__(self):
164 return self.name
165
166 class DefaultBenchmark(Benchmark):
167 def ref(self, isa, os): pass
168 def test(self, isa, os): pass
169 def train(self, isa, os): pass
170
171 class MinneDefaultBenchmark(DefaultBenchmark):
172 def smred(self, isa, os): pass
173 def mdred(self, isa, os): pass
174 def lgred(self, isa, os): pass
175
176 class ammp(MinneDefaultBenchmark):
177 name = 'ammp'
178 number = 188
179 lang = 'C'
180
181 class applu(MinneDefaultBenchmark):
182 name = 'applu'
183 number = 173
184 lang = 'F77'
185
186 class apsi(MinneDefaultBenchmark):
187 name = 'apsi'
188 number = 301
189 lang = 'F77'
190
191 class art(DefaultBenchmark):
192 name = 'art'
193 number = 179
194 lang = 'C'
195
196 def test(self, isa, os):
197 self.args = [ '-scanfile', 'c756hel.in',
198 '-trainfile1', 'a10.img',
199 '-stride', '2',
200 '-startx', '134',
201 '-starty', '220',
202 '-endx', '139',
203 '-endy', '225',
204 '-objects', '1' ]
205 self.output = 'test.out'
206
207 def train(self, isa, os):
208 self.args = [ '-scanfile', 'c756hel.in',
209 '-trainfile1', 'a10.img',
210 '-stride', '2',
211 '-startx', '134',
212 '-starty', '220',
213 '-endx', '184',
214 '-endy', '240',
215 '-objects', '3' ]
216 self.output = 'train.out'
217
218 def lgred(self, isa, os):
219 self.args = ['-scanfile', 'c756hel.in',
220 '-trainfile1', 'a10.img',
221 '-stride', '5',
222 '-startx', '134',
223 '-starty', '220',
224 '-endx', '184',
225 '-endy', '240',
226 '-objects', '1' ]
227 self.output = 'lgred.out'
228
229
230 class art110(art):
231 def ref(self, isa, os):
232 self.args = [ '-scanfile', 'c756hel.in',
233 '-trainfile1', 'a10.img',
234 '-trainfile2', 'hc.img',
235 '-stride', '2',
236 '-startx', '110',
237 '-starty', '200',
238 '-endx', '160',
239 '-endy', '240',
240 '-objects', '10' ]
241 self.output = 'ref.1.out'
242
243 class art470(art):
244 def ref(self, isa, os):
245 self.args = [ '-scanfile', 'c756hel.in',
246 '-trainfile1', 'a10.img',
247 '-trainfile2', 'hc.img',
248 '-stride', '2',
249 '-startx', '470',
250 '-starty', '140',
251 '-endx', '520',
252 '-endy', '180',
253 '-objects', '10' ]
254 self.output = 'ref.2.out'
255
256 class equake(DefaultBenchmark):
257 name = 'equake'
258 number = 183
259 lang = 'C'
260
261 def lgred(self, isa, os): pass
262
263 class facerec(MinneDefaultBenchmark):
264 name = 'facerec'
265 number = 187
266 lang = 'F'
267
268 class fma3d(MinneDefaultBenchmark):
269 name = 'fma3d'
270 number = 191
271 lang = 'F'
272
273 class galgel(MinneDefaultBenchmark):
274 name = 'galgel'
275 number = 178
276 lang = 'F'
277
278 class lucas(MinneDefaultBenchmark):
279 name = 'lucas'
280 number = 189
281 lang = 'F'
282
283 class mesa(Benchmark):
284 name = 'mesa'
285 number = 177
286 lang = 'C'
287 stdin = None
288
289 def __set_args(self, frames):
290 self.args = [ '-frames', frames, '-meshfile', '%s.in' % self.name,
291 '-ppmfile', '%s.ppm' % self.name ]
292
293 def test(self, isa, os):
294 self.__set_args('10')
295
296 def train(self, isa, os):
297 self.__set_args('500')
298
299 def ref(self, isa, os):
300 self.__set_args('1000')
301
302 def lgred(self, isa, os):
303 self.__set_args('1')
304
305 class mgrid(MinneDefaultBenchmark):
306 name = 'mgrid'
307 number = 172
308 lang = 'F77'
309
310 class sixtrack(DefaultBenchmark):
311 name = 'sixtrack'
312 number = 200
313 lang = 'F77'
314
315 def lgred(self, isa, os): pass
316
317 class swim(MinneDefaultBenchmark):
318 name = 'swim'
319 number = 171
320 lang = 'F77'
321
322 class wupwise(DefaultBenchmark):
323 name = 'wupwise'
324 number = 168
325 lang = 'F77'
326
327 def lgred(self, isa, os): pass
328
329 class bzip2(DefaultBenchmark):
330 name = 'bzip2'
331 number = 256
332 lang = 'C'
333
334 def test(self, isa, os):
335 self.args = [ 'input.random' ]
336
337 def train(self, isa, os):
338 self.args = [ 'input.compressed' ]
339
340 class bzip2_source(bzip2):
341 def ref(self, isa, os):
342 self.args = [ 'input.source', '58' ]
343
344 def lgred(self, isa, os):
345 self.args = [ 'input.source', '1' ]
346
347 class bzip2_graphic(bzip2):
348 def ref(self, isa, os):
349 self.args = [ 'input.graphic', '58' ]
350
351 def lgred(self, isa, os):
352 self.args = [ 'input.graphic', '1' ]
353
354 class bzip2_program(bzip2):
355 def ref(self, isa, os):
356 self.args = [ 'input.program', '58' ]
357
358 def lgred(self, isa, os):
359 self.args = [ 'input.program', '1' ]
360
361 class crafty(MinneDefaultBenchmark):
362 name = 'crafty'
363 number = 186
364 lang = 'C'
365
366 class eon(MinneDefaultBenchmark):
367 name = 'eon'
368 number = 252
369 lang = 'CXX'
370 stdin = None
371
372 class eon_kajiya(eon):
373 args = [ 'chair.control.kajiya', 'chair.camera', 'chair.surfaces',
374 'chair.kajiya.ppm', 'ppm', 'pixels_out.kajiya']
375 output = 'kajiya_log.out'
376
377
378 class eon_cook(eon):
379 args = [ 'chair.control.cook', 'chair.camera', 'chair.surfaces',
380 'chair.cook.ppm', 'ppm', 'pixels_out.cook' ]
381 output = 'cook_log.out'
382
383 class eon_rushmeier(eon):
384 args = [ 'chair.control.rushmeier', 'chair.camera', 'chair.surfaces',
385 'chair.rushmeier.ppm', 'ppm', 'pixels_out.rushmeier' ]
386 output = 'rushmeier_log.out'
387
388 class gap(DefaultBenchmark):
389 name = 'gap'
390 number = 254
391 lang = 'C'
392
393 def __set_args(self, size):
394 self.args = [ '-l', './', '-q', '-m', size ]
395
396 def test(self, isa, os):
397 self.__set_args('64M')
398
399 def train(self, isa, os):
400 self.__set_args('128M')
401
402 def ref(self, isa, os):
403 self.__set_args('192M')
404
405 def lgred(self, isa, os):
406 self.__set_args('64M')
407
408 def mdred(self, isa, os):
409 self.__set_args('64M')
410
411 def smred(self, isa, os):
412 self.__set_args('64M')
413
414 class gcc(DefaultBenchmark):
415 name = 'gcc'
416 number = 176
417 lang = 'C'
418
419 def test(self, isa, os):
420 self.args = [ 'cccp.i', '-o', 'cccp.s' ]
421
422 def train(self, isa, os):
423 self.args = [ 'cp-decl.i', '-o', 'cp-decl.s' ]
424
425 def smred(self, isa, os):
426 self.args = [ 'c-iterate.i', '-o', 'c-iterate.s' ]
427
428 def mdred(self, isa, os):
429 self.args = [ 'rdlanal.i', '-o', 'rdlanal.s' ]
430
431 def lgred(self, isa, os):
432 self.args = [ 'cp-decl.i', '-o', 'cp-decl.s' ]
433
434 class gcc_166(gcc):
435 def ref(self, isa, os):
436 self.args = [ '166.i', '-o', '166.s' ]
437
438 class gcc_200(gcc):
439 def ref(self, isa, os):
440 self.args = [ '200.i', '-o', '200.s' ]
441
442 class gcc_expr(gcc):
443 def ref(self, isa, os):
444 self.args = [ 'expr.i', '-o', 'expr.s' ]
445
446 class gcc_integrate(gcc):
447 def ref(self, isa, os):
448 self.args = [ 'integrate.i', '-o', 'integrate.s' ]
449
450 class gcc_scilab(gcc):
451 def ref(self, isa, os):
452 self.args = [ 'scilab.i', '-o', 'scilab.s' ]
453
454 class gzip(DefaultBenchmark):
455 name = 'gzip'
456 number = 164
457 lang = 'C'
458
459 def test(self, isa, os):
460 self.args = [ 'input.compressed', '2' ]
461
462 def train(self, isa, os):
463 self.args = [ 'input.combined', '32' ]
464
465 class gzip_source(gzip):
466 def ref(self, isa, os):
467 self.args = [ 'input.source', '1' ]
468 def smred(self, isa, os):
469 self.args = [ 'input.source', '1' ]
470 def mdred(self, isa, os):
471 self.args = [ 'input.source', '1' ]
472 def lgred(self, isa, os):
473 self.args = [ 'input.source', '1' ]
474
475 class gzip_log(gzip):
476 def ref(self, isa, os):
477 self.args = [ 'input.log', '60' ]
478 def smred(self, isa, os):
479 self.args = [ 'input.log', '1' ]
480 def mdred(self, isa, os):
481 self.args = [ 'input.log', '1' ]
482 def lgred(self, isa, os):
483 self.args = [ 'input.log', '1' ]
484
485 class gzip_graphic(gzip):
486 def ref(self, isa, os):
487 self.args = [ 'input.graphic', '60' ]
488 def smred(self, isa, os):
489 self.args = [ 'input.graphic', '1' ]
490 def mdred(self, isa, os):
491 self.args = [ 'input.graphic', '1' ]
492 def lgred(self, isa, os):
493 self.args = [ 'input.graphic', '1' ]
494
495 class gzip_random(gzip):
496 def ref(self, isa, os):
497 self.args = [ 'input.random', '60' ]
498 def smred(self, isa, os):
499 self.args = [ 'input.random', '1' ]
500 def mdred(self, isa, os):
501 self.args = [ 'input.random', '1' ]
502 def lgred(self, isa, os):
503 self.args = [ 'input.random', '1' ]
504
505 class gzip_program(gzip):
506 def ref(self, isa, os):
507 self.args = [ 'input.program', '60' ]
508 def smred(self, isa, os):
509 self.args = [ 'input.program', '1' ]
510 def mdred(self, isa, os):
511 self.args = [ 'input.program', '1' ]
512 def lgred(self, isa, os):
513 self.args = [ 'input.program', '1' ]
514
515 class mcf(MinneDefaultBenchmark):
516 name = 'mcf'
517 number = 181
518 lang = 'C'
519
520 class parser(MinneDefaultBenchmark):
521 name = 'parser'
522 number = 197
523 lang = 'C'
524 args = [ '2.1.dict', '-batch' ]
525
526 class perlbmk(DefaultBenchmark):
527 name = 'perlbmk'
528 number = 253
529 lang = 'C'
530
531 def test(self, isa, os):
532 self.args = [ '-I.', '-I', 'lib', 'test.pl' ]
533 self.stdin = 'test.in'
534
535 class perlbmk_diffmail(perlbmk):
536 def ref(self, isa, os):
537 self.args = [ '-I', 'lib', 'diffmail.pl', '2', '550', '15', '24',
538 '23', '100' ]
539
540 def train(self, isa, os):
541 self.args = [ '-I', 'lib', 'diffmail.pl', '2', '350', '15', '24',
542 '23', '150' ]
543
544 class perlbmk_scrabbl(perlbmk):
545 def train(self, isa, os):
546 self.args = [ '-I.', '-I', 'lib', 'scrabbl.pl' ]
547 self.stdin = 'scrabbl.in'
548
549 class perlbmk_makerand(perlbmk):
550 def ref(self, isa, os):
551 self.args = [ '-I', 'lib', 'makerand.pl' ]
552
553 def lgred(self, isa, os):
554 self.args = [ '-I.', '-I', 'lib', 'lgred.makerand.pl' ]
555
556 def mdred(self, isa, os):
557 self.args = [ '-I.', '-I', 'lib', 'mdred.makerand.pl' ]
558
559 def smred(self, isa, os):
560 self.args = [ '-I.', '-I', 'lib', 'smred.makerand.pl' ]
561
562 class perlbmk_perfect(perlbmk):
563 def ref(self, isa, os):
564 self.args = [ '-I', 'lib', 'perfect.pl', 'b', '3', 'm', '4' ]
565
566 def train(self, isa, os):
567 self.args = [ '-I', 'lib', 'perfect.pl', 'b', '3' ]
568
569 class perlbmk_splitmail1(perlbmk):
570 def ref(self, isa, os):
571 self.args = [ '-I', 'lib', 'splitmail.pl', '850', '5', '19',
572 '18', '1500' ]
573
574 class perlbmk_splitmail2(perlbmk):
575 def ref(self, isa, os):
576 self.args = [ '-I', 'lib', 'splitmail.pl', '704', '12', '26',
577 '16', '836' ]
578
579 class perlbmk_splitmail3(perlbmk):
580 def ref(self, isa, os):
581 self.args = [ '-I', 'lib', 'splitmail.pl', '535', '13', '25',
582 '24', '1091' ]
583
584 class perlbmk_splitmail4(perlbmk):
585 def ref(self, isa, os):
586 self.args = [ '-I', 'lib', 'splitmail.pl', '957', '12', '23',
587 '26', '1014' ]
588
589 class twolf(Benchmark):
590 name = 'twolf'
591 number = 300
592 lang = 'C'
593 stdin = None
594
595 def test(self, isa, os):
596 self.args = [ 'test' ]
597
598 def train(self, isa, os):
599 self.args = [ 'train' ]
600
601 def ref(self, isa, os):
602 self.args = [ 'ref' ]
603
604 def smred(self, isa, os):
605 self.args = [ 'smred' ]
606
607 def mdred(self, isa, os):
608 self.args = [ 'mdred' ]
609
610 def lgred(self, isa, os):
611 self.args = [ 'lgred' ]
612
613 class vortex(Benchmark):
614 name = 'vortex'
615 number = 255
616 lang = 'C'
617 stdin = None
618
619 def __init__(self, isa, os, input_set):
620 if isa == 'alpha':
621 self.endian = 'lendian'
622 else:
623 raise AttributeError, "unknown ISA %s" % isa
624
625 super(vortex, self).__init__(isa, os, input_set)
626
627 def test(self, isa, os):
628 self.args = [ '%s.raw' % self.endian ]
629 self.output = 'vortex.out'
630
631 def train(self, isa, os):
632 self.args = [ '%s.raw' % self.endian ]
633 self.output = 'vortex.out'
634
635 def smred(self, isa, os):
636 self.args = [ '%s.raw' % self.endian ]
637 self.output = 'vortex.out'
638
639 def mdred(self, isa, os):
640 self.args = [ '%s.raw' % self.endian ]
641 self.output = 'vortex.out'
642
643 def lgred(self, isa, os):
644 self.args = [ '%s.raw' % self.endian ]
645 self.output = 'vortex.out'
646
647 class vortex1(vortex):
648 def ref(self, isa, os):
649 self.args = [ '%s1.raw' % self.endian ]
650 self.output = 'vortex1.out'
651
652
653 class vortex2(vortex):
654 def ref(self, isa, os):
655 self.args = [ '%s2.raw' % self.endian ]
656 self.output = 'vortex2.out'
657
658 class vortex3(vortex):
659 def ref(self, isa, os):
660 self.args = [ '%s3.raw' % self.endian ]
661 self.output = 'vortex3.out'
662
663 class vpr(MinneDefaultBenchmark):
664 name = 'vpr'
665 number = 175
666 lang = 'C'
667
668 # not sure about vpr minnespec place.in
669 class vpr_place(vpr):
670 args = [ 'net.in', 'arch.in', 'place.out', 'dum.out', '-nodisp',
671 '-place_only', '-init_t', '5', '-exit_t', '0.005',
672 '-alpha_t', '0.9412', '-inner_num', '2' ]
673 output = 'place_log.out'
674
675 class vpr_route(vpr):
676 args = [ 'net.in', 'arch.in', 'place.in', 'route.out', '-nodisp',
677 '-route_only', '-route_chan_width', '15',
678 '-pres_fac_mult', '2', '-acc_fac', '1',
679 '-first_iter_pres_fac', '4', '-initial_pres_fac', '8' ]
680 output = 'route_log.out'
681
682 all = [ ammp, applu, apsi, art110, art470, equake, facerec, fma3d, galgel,
683 lucas, mesa, mgrid, sixtrack, swim, wupwise, bzip2_source,
684 bzip2_graphic, bzip2_program, crafty, eon_kajiya, eon_cook,
685 eon_rushmeier, gap, gcc_166, gcc_200, gcc_expr, gcc_integrate,
686 gcc_scilab, gzip_source, gzip_log, gzip_graphic, gzip_random,
687 gzip_program, mcf, parser, perlbmk_diffmail, perlbmk_makerand,
688 perlbmk_perfect, perlbmk_splitmail1, perlbmk_splitmail2,
689 perlbmk_splitmail3, perlbmk_splitmail4, twolf, vortex1, vortex2,
690 vortex3, vpr_place, vpr_route ]
691
692 __all__ = [ x.__name__ for x in all ]
693
694 if __name__ == '__main__':
695 from pprint import pprint
696 for bench in all:
697 for input_set in 'ref', 'test', 'train':
698 print 'class: %s' % bench.__name__
699 x = bench('alpha', 'tru64', input_set)
700 print '%s: %s' % (x, input_set)
701 pprint(x.makeLiveProcessArgs())
702 print