1 # Copyright (c) 2006 The Regents of The University of Michigan
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.
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.
27 # Authors: Nathan Binkert
31 from os
.path
import basename
, exists
, join
as joinpath
, normpath
32 from os
.path
import isdir
, isfile
, islink
34 spec_dist
= '/dist/m5/cpu2000'
36 def copyfiles(srcdir
, dstdir
):
37 from filecmp
import cmp as filecmp
38 from shutil
import copyfile
40 srcdir
= normpath(srcdir
)
41 dstdir
= normpath(dstdir
)
46 for root
, dirs
, files
in os
.walk(srcdir
):
48 prefix
= os
.path
.commonprefix([root
, srcdir
])
50 root
= root
[len(prefix
):]
51 if root
.startswith('/'):
55 newdir
= joinpath(dstdir
, root
, entry
)
60 dest
= normpath(joinpath(dstdir
, root
, entry
))
61 src
= normpath(joinpath(srcdir
, root
, entry
))
62 if not isfile(dest
) or not filecmp(src
, dest
):
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
)
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
__
79 if not hasattr(self
.__class
__, 'binary'):
80 self
.binary
= self
.name
82 if not hasattr(self
.__class
__, 'args'):
85 if not hasattr(self
.__class
__, 'output'):
86 self
.output
= '%s.out' % self
.name
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
)
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
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')
108 if not isdir(inputs_dir
):
109 raise AttributeError, '%s not found' % inputs_dir
111 self
.inputs_dir
= [ inputs_dir
]
113 self
.inputs_dir
+= [ joinpath(all_dir
, 'input') ]
114 if isdir(outputs_dir
):
115 self
.outputs_dir
= outputs_dir
117 if not hasattr(self
.__class
__, 'stdin'):
118 self
.stdin
= joinpath(inputs_dir
, '%s.in' % self
.name
)
119 if not isfile(self
.stdin
):
122 if not hasattr(self
.__class
__, 'stdout'):
123 self
.stdout
= joinpath(outputs_dir
, '%s.out' % self
.name
)
124 if not isfile(self
.stdout
):
129 def makeLiveProcessArgs(self
, **kwargs
):
130 # set up default args for LiveProcess object
132 process_args
['cmd'] = self
.name
+ ' ' + ' '.join(self
.args
)
133 process_args
['executable'] = self
.executable
135 process_args
['input'] = self
.stdin
137 process_args
['output'] = self
.stdout
139 # explicit keywords override defaults
140 process_args
.update(kwargs
)
144 def makeLiveProcess(self
, **kwargs
):
145 process_args
= self
.makeLiveProcessArgs(**kwargs
)
147 # figure out working directory: use m5's outdir unless
148 # overridden by LiveProcess's cwd param
149 cwd
= process_args
.get('cwd')
151 from m5
.main
import options
153 process_args
['cwd'] = cwd
156 # copy input files to working directory
157 for d
in self
.inputs_dir
:
159 # generate LiveProcess object
160 from m5
.objects
import LiveProcess
161 return LiveProcess(**process_args
)
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
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
176 class ammp(MinneDefaultBenchmark
):
181 class applu(MinneDefaultBenchmark
):
186 class apsi(MinneDefaultBenchmark
):
191 class art(DefaultBenchmark
):
196 def test(self
, isa
, os
):
197 self
.args
= [ '-scanfile', 'c756hel.in',
198 '-trainfile1', 'a10.img',
205 self
.output
= 'test.out'
207 def train(self
, isa
, os
):
208 self
.args
= [ '-scanfile', 'c756hel.in',
209 '-trainfile1', 'a10.img',
216 self
.output
= 'train.out'
218 def lgred(self
, isa
, os
):
219 self
.args
= ['-scanfile', 'c756hel.in',
220 '-trainfile1', 'a10.img',
227 self
.output
= 'lgred.out'
231 def ref(self
, isa
, os
):
232 self
.args
= [ '-scanfile', 'c756hel.in',
233 '-trainfile1', 'a10.img',
234 '-trainfile2', 'hc.img',
241 self
.output
= 'ref.1.out'
244 def ref(self
, isa
, os
):
245 self
.args
= [ '-scanfile', 'c756hel.in',
246 '-trainfile1', 'a10.img',
247 '-trainfile2', 'hc.img',
254 self
.output
= 'ref.2.out'
256 class equake(DefaultBenchmark
):
261 def lgred(self
, isa
, os
): pass
263 class facerec(MinneDefaultBenchmark
):
268 class fma3d(MinneDefaultBenchmark
):
273 class galgel(MinneDefaultBenchmark
):
278 class lucas(MinneDefaultBenchmark
):
283 class mesa(Benchmark
):
289 def __set_args(self
, frames
):
290 self
.args
= [ '-frames', frames
, '-meshfile', '%s.in' % self
.name
,
291 '-ppmfile', '%s.ppm' % self
.name
]
293 def test(self
, isa
, os
):
294 self
.__set
_args
('10')
296 def train(self
, isa
, os
):
297 self
.__set
_args
('500')
299 def ref(self
, isa
, os
):
300 self
.__set
_args
('1000')
302 def lgred(self
, isa
, os
):
305 class mgrid(MinneDefaultBenchmark
):
310 class sixtrack(DefaultBenchmark
):
315 def lgred(self
, isa
, os
): pass
317 class swim(MinneDefaultBenchmark
):
322 class wupwise(DefaultBenchmark
):
327 def lgred(self
, isa
, os
): pass
329 class bzip2(DefaultBenchmark
):
334 def test(self
, isa
, os
):
335 self
.args
= [ 'input.random' ]
337 def train(self
, isa
, os
):
338 self
.args
= [ 'input.compressed' ]
340 class bzip2_source(bzip2
):
341 def ref(self
, isa
, os
):
342 self
.args
= [ 'input.source', '58' ]
344 def lgred(self
, isa
, os
):
345 self
.args
= [ 'input.source', '1' ]
347 class bzip2_graphic(bzip2
):
348 def ref(self
, isa
, os
):
349 self
.args
= [ 'input.graphic', '58' ]
351 def lgred(self
, isa
, os
):
352 self
.args
= [ 'input.graphic', '1' ]
354 class bzip2_program(bzip2
):
355 def ref(self
, isa
, os
):
356 self
.args
= [ 'input.program', '58' ]
358 def lgred(self
, isa
, os
):
359 self
.args
= [ 'input.program', '1' ]
361 class crafty(MinneDefaultBenchmark
):
366 class eon(MinneDefaultBenchmark
):
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'
379 args
= [ 'chair.control.cook', 'chair.camera', 'chair.surfaces',
380 'chair.cook.ppm', 'ppm', 'pixels_out.cook' ]
381 output
= 'cook_log.out'
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'
388 class gap(DefaultBenchmark
):
393 def __set_args(self
, size
):
394 self
.args
= [ '-l', './', '-q', '-m', size
]
396 def test(self
, isa
, os
):
397 self
.__set
_args
('64M')
399 def train(self
, isa
, os
):
400 self
.__set
_args
('128M')
402 def ref(self
, isa
, os
):
403 self
.__set
_args
('192M')
405 def lgred(self
, isa
, os
):
406 self
.__set
_args
('64M')
408 def mdred(self
, isa
, os
):
409 self
.__set
_args
('64M')
411 def smred(self
, isa
, os
):
412 self
.__set
_args
('64M')
414 class gcc(DefaultBenchmark
):
419 def test(self
, isa
, os
):
420 self
.args
= [ 'cccp.i', '-o', 'cccp.s' ]
422 def train(self
, isa
, os
):
423 self
.args
= [ 'cp-decl.i', '-o', 'cp-decl.s' ]
425 def smred(self
, isa
, os
):
426 self
.args
= [ 'c-iterate.i', '-o', 'c-iterate.s' ]
428 def mdred(self
, isa
, os
):
429 self
.args
= [ 'rdlanal.i', '-o', 'rdlanal.s' ]
431 def lgred(self
, isa
, os
):
432 self
.args
= [ 'cp-decl.i', '-o', 'cp-decl.s' ]
435 def ref(self
, isa
, os
):
436 self
.args
= [ '166.i', '-o', '166.s' ]
439 def ref(self
, isa
, os
):
440 self
.args
= [ '200.i', '-o', '200.s' ]
443 def ref(self
, isa
, os
):
444 self
.args
= [ 'expr.i', '-o', 'expr.s' ]
446 class gcc_integrate(gcc
):
447 def ref(self
, isa
, os
):
448 self
.args
= [ 'integrate.i', '-o', 'integrate.s' ]
450 class gcc_scilab(gcc
):
451 def ref(self
, isa
, os
):
452 self
.args
= [ 'scilab.i', '-o', 'scilab.s' ]
454 class gzip(DefaultBenchmark
):
459 def test(self
, isa
, os
):
460 self
.args
= [ 'input.compressed', '2' ]
462 def train(self
, isa
, os
):
463 self
.args
= [ 'input.combined', '32' ]
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' ]
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' ]
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' ]
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' ]
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' ]
515 class mcf(MinneDefaultBenchmark
):
520 class parser(MinneDefaultBenchmark
):
524 args
= [ '2.1.dict', '-batch' ]
526 class perlbmk(DefaultBenchmark
):
531 def test(self
, isa
, os
):
532 self
.args
= [ '-I.', '-I', 'lib', 'test.pl' ]
533 self
.stdin
= 'test.in'
535 class perlbmk_diffmail(perlbmk
):
536 def ref(self
, isa
, os
):
537 self
.args
= [ '-I', 'lib', 'diffmail.pl', '2', '550', '15', '24',
540 def train(self
, isa
, os
):
541 self
.args
= [ '-I', 'lib', 'diffmail.pl', '2', '350', '15', '24',
544 class perlbmk_scrabbl(perlbmk
):
545 def train(self
, isa
, os
):
546 self
.args
= [ '-I.', '-I', 'lib', 'scrabbl.pl' ]
547 self
.stdin
= 'scrabbl.in'
549 class perlbmk_makerand(perlbmk
):
550 def ref(self
, isa
, os
):
551 self
.args
= [ '-I', 'lib', 'makerand.pl' ]
553 def lgred(self
, isa
, os
):
554 self
.args
= [ '-I.', '-I', 'lib', 'lgred.makerand.pl' ]
556 def mdred(self
, isa
, os
):
557 self
.args
= [ '-I.', '-I', 'lib', 'mdred.makerand.pl' ]
559 def smred(self
, isa
, os
):
560 self
.args
= [ '-I.', '-I', 'lib', 'smred.makerand.pl' ]
562 class perlbmk_perfect(perlbmk
):
563 def ref(self
, isa
, os
):
564 self
.args
= [ '-I', 'lib', 'perfect.pl', 'b', '3', 'm', '4' ]
566 def train(self
, isa
, os
):
567 self
.args
= [ '-I', 'lib', 'perfect.pl', 'b', '3' ]
569 class perlbmk_splitmail1(perlbmk
):
570 def ref(self
, isa
, os
):
571 self
.args
= [ '-I', 'lib', 'splitmail.pl', '850', '5', '19',
574 class perlbmk_splitmail2(perlbmk
):
575 def ref(self
, isa
, os
):
576 self
.args
= [ '-I', 'lib', 'splitmail.pl', '704', '12', '26',
579 class perlbmk_splitmail3(perlbmk
):
580 def ref(self
, isa
, os
):
581 self
.args
= [ '-I', 'lib', 'splitmail.pl', '535', '13', '25',
584 class perlbmk_splitmail4(perlbmk
):
585 def ref(self
, isa
, os
):
586 self
.args
= [ '-I', 'lib', 'splitmail.pl', '957', '12', '23',
589 class twolf(Benchmark
):
595 def test(self
, isa
, os
):
596 self
.args
= [ 'test' ]
598 def train(self
, isa
, os
):
599 self
.args
= [ 'train' ]
601 def ref(self
, isa
, os
):
602 self
.args
= [ 'ref' ]
604 def smred(self
, isa
, os
):
605 self
.args
= [ 'smred' ]
607 def mdred(self
, isa
, os
):
608 self
.args
= [ 'mdred' ]
610 def lgred(self
, isa
, os
):
611 self
.args
= [ 'lgred' ]
613 class vortex(Benchmark
):
619 def __init__(self
, isa
, os
, input_set
):
621 self
.endian
= 'lendian'
623 raise AttributeError, "unknown ISA %s" % isa
625 super(vortex
, self
).__init
__(isa
, os
, input_set
)
627 def test(self
, isa
, os
):
628 self
.args
= [ '%s.raw' % self
.endian
]
629 self
.output
= 'vortex.out'
631 def train(self
, isa
, os
):
632 self
.args
= [ '%s.raw' % self
.endian
]
633 self
.output
= 'vortex.out'
635 def smred(self
, isa
, os
):
636 self
.args
= [ '%s.raw' % self
.endian
]
637 self
.output
= 'vortex.out'
639 def mdred(self
, isa
, os
):
640 self
.args
= [ '%s.raw' % self
.endian
]
641 self
.output
= 'vortex.out'
643 def lgred(self
, isa
, os
):
644 self
.args
= [ '%s.raw' % self
.endian
]
645 self
.output
= 'vortex.out'
647 class vortex1(vortex
):
648 def ref(self
, isa
, os
):
649 self
.args
= [ '%s1.raw' % self
.endian
]
650 self
.output
= 'vortex1.out'
653 class vortex2(vortex
):
654 def ref(self
, isa
, os
):
655 self
.args
= [ '%s2.raw' % self
.endian
]
656 self
.output
= 'vortex2.out'
658 class vortex3(vortex
):
659 def ref(self
, isa
, os
):
660 self
.args
= [ '%s3.raw' % self
.endian
]
661 self
.output
= 'vortex3.out'
663 class vpr(MinneDefaultBenchmark
):
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'
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'
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
]
692 __all__
= [ x
.__name
__ for x
in all
]
694 if __name__
== '__main__':
695 from pprint
import pprint
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())