1 # Copyright (c) 2006-2007 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')
107 # keep around which input set was specified
108 self
.input_set
= input_set
110 if not isdir(inputs_dir
):
111 raise AttributeError, '%s not found' % inputs_dir
113 self
.inputs_dir
= [ inputs_dir
]
115 self
.inputs_dir
+= [ joinpath(all_dir
, 'input') ]
116 if isdir(outputs_dir
):
117 self
.outputs_dir
= outputs_dir
119 if not hasattr(self
.__class
__, 'stdin'):
120 self
.stdin
= joinpath(inputs_dir
, '%s.in' % self
.name
)
121 if not isfile(self
.stdin
):
124 if not hasattr(self
.__class
__, 'stdout'):
125 self
.stdout
= joinpath(outputs_dir
, '%s.out' % self
.name
)
126 if not isfile(self
.stdout
):
131 def makeLiveProcessArgs(self
, **kwargs
):
132 # set up default args for LiveProcess object
134 process_args
['cmd'] = [ self
.name
] + self
.args
135 process_args
['executable'] = self
.executable
137 process_args
['input'] = self
.stdin
139 process_args
['output'] = self
.stdout
141 # explicit keywords override defaults
142 process_args
.update(kwargs
)
146 def makeLiveProcess(self
, **kwargs
):
147 process_args
= self
.makeLiveProcessArgs(**kwargs
)
149 # figure out working directory: use m5's outdir unless
150 # overridden by LiveProcess's cwd param
151 cwd
= process_args
.get('cwd')
153 from m5
.main
import options
155 process_args
['cwd'] = cwd
158 # copy input files to working directory
159 for d
in self
.inputs_dir
:
161 # generate LiveProcess object
162 from m5
.objects
import LiveProcess
163 return LiveProcess(**process_args
)
168 class DefaultBenchmark(Benchmark
):
169 def ref(self
, isa
, os
): pass
170 def test(self
, isa
, os
): pass
171 def train(self
, isa
, os
): pass
173 class MinneDefaultBenchmark(DefaultBenchmark
):
174 def smred(self
, isa
, os
): pass
175 def mdred(self
, isa
, os
): pass
176 def lgred(self
, isa
, os
): pass
178 class ammp(MinneDefaultBenchmark
):
183 class applu(MinneDefaultBenchmark
):
188 class apsi(MinneDefaultBenchmark
):
193 class art(DefaultBenchmark
):
198 def test(self
, isa
, os
):
199 self
.args
= [ '-scanfile', 'c756hel.in',
200 '-trainfile1', 'a10.img',
207 self
.output
= 'test.out'
209 def train(self
, isa
, os
):
210 self
.args
= [ '-scanfile', 'c756hel.in',
211 '-trainfile1', 'a10.img',
218 self
.output
= 'train.out'
220 def lgred(self
, isa
, os
):
221 self
.args
= ['-scanfile', 'c756hel.in',
222 '-trainfile1', 'a10.img',
229 self
.output
= 'lgred.out'
233 def ref(self
, isa
, os
):
234 self
.args
= [ '-scanfile', 'c756hel.in',
235 '-trainfile1', 'a10.img',
236 '-trainfile2', 'hc.img',
243 self
.output
= 'ref.1.out'
246 def ref(self
, isa
, os
):
247 self
.args
= [ '-scanfile', 'c756hel.in',
248 '-trainfile1', 'a10.img',
249 '-trainfile2', 'hc.img',
256 self
.output
= 'ref.2.out'
258 class equake(DefaultBenchmark
):
263 def lgred(self
, isa
, os
): pass
265 class facerec(MinneDefaultBenchmark
):
270 class fma3d(MinneDefaultBenchmark
):
275 class galgel(MinneDefaultBenchmark
):
280 class lucas(MinneDefaultBenchmark
):
285 class mesa(Benchmark
):
291 def __set_args(self
, frames
):
292 self
.args
= [ '-frames', frames
, '-meshfile', '%s.in' % self
.name
,
293 '-ppmfile', '%s.ppm' % self
.name
]
295 def test(self
, isa
, os
):
296 self
.__set
_args
('10')
298 def train(self
, isa
, os
):
299 self
.__set
_args
('500')
301 def ref(self
, isa
, os
):
302 self
.__set
_args
('1000')
304 def lgred(self
, isa
, os
):
307 class mgrid(MinneDefaultBenchmark
):
312 class sixtrack(DefaultBenchmark
):
317 def lgred(self
, isa
, os
): pass
319 class swim(MinneDefaultBenchmark
):
324 class wupwise(DefaultBenchmark
):
329 def lgred(self
, isa
, os
): pass
331 class bzip2(DefaultBenchmark
):
336 def test(self
, isa
, os
):
337 self
.args
= [ 'input.random' ]
339 def train(self
, isa
, os
):
340 self
.args
= [ 'input.compressed' ]
342 class bzip2_source(bzip2
):
343 def ref(self
, isa
, os
):
344 self
.args
= [ 'input.source', '58' ]
346 def lgred(self
, isa
, os
):
347 self
.args
= [ 'input.source', '1' ]
349 class bzip2_graphic(bzip2
):
350 def ref(self
, isa
, os
):
351 self
.args
= [ 'input.graphic', '58' ]
353 def lgred(self
, isa
, os
):
354 self
.args
= [ 'input.graphic', '1' ]
356 class bzip2_program(bzip2
):
357 def ref(self
, isa
, os
):
358 self
.args
= [ 'input.program', '58' ]
360 def lgred(self
, isa
, os
):
361 self
.args
= [ 'input.program', '1' ]
363 class crafty(MinneDefaultBenchmark
):
368 class eon(MinneDefaultBenchmark
):
374 class eon_kajiya(eon
):
375 args
= [ 'chair.control.kajiya', 'chair.camera', 'chair.surfaces',
376 'chair.kajiya.ppm', 'ppm', 'pixels_out.kajiya']
377 output
= 'kajiya_log.out'
381 args
= [ 'chair.control.cook', 'chair.camera', 'chair.surfaces',
382 'chair.cook.ppm', 'ppm', 'pixels_out.cook' ]
383 output
= 'cook_log.out'
385 class eon_rushmeier(eon
):
386 args
= [ 'chair.control.rushmeier', 'chair.camera', 'chair.surfaces',
387 'chair.rushmeier.ppm', 'ppm', 'pixels_out.rushmeier' ]
388 output
= 'rushmeier_log.out'
390 class gap(DefaultBenchmark
):
395 def __set_args(self
, size
):
396 self
.args
= [ '-l', './', '-q', '-m', size
]
398 def test(self
, isa
, os
):
399 self
.__set
_args
('64M')
401 def train(self
, isa
, os
):
402 self
.__set
_args
('128M')
404 def ref(self
, isa
, os
):
405 self
.__set
_args
('192M')
407 def lgred(self
, isa
, os
):
408 self
.__set
_args
('64M')
410 def mdred(self
, isa
, os
):
411 self
.__set
_args
('64M')
413 def smred(self
, isa
, os
):
414 self
.__set
_args
('64M')
416 class gcc(DefaultBenchmark
):
421 def test(self
, isa
, os
):
422 self
.args
= [ 'cccp.i', '-o', 'cccp.s' ]
424 def train(self
, isa
, os
):
425 self
.args
= [ 'cp-decl.i', '-o', 'cp-decl.s' ]
427 def smred(self
, isa
, os
):
428 self
.args
= [ 'c-iterate.i', '-o', 'c-iterate.s' ]
430 def mdred(self
, isa
, os
):
431 self
.args
= [ 'rdlanal.i', '-o', 'rdlanal.s' ]
433 def lgred(self
, isa
, os
):
434 self
.args
= [ 'cp-decl.i', '-o', 'cp-decl.s' ]
437 def ref(self
, isa
, os
):
438 self
.args
= [ '166.i', '-o', '166.s' ]
441 def ref(self
, isa
, os
):
442 self
.args
= [ '200.i', '-o', '200.s' ]
445 def ref(self
, isa
, os
):
446 self
.args
= [ 'expr.i', '-o', 'expr.s' ]
448 class gcc_integrate(gcc
):
449 def ref(self
, isa
, os
):
450 self
.args
= [ 'integrate.i', '-o', 'integrate.s' ]
452 class gcc_scilab(gcc
):
453 def ref(self
, isa
, os
):
454 self
.args
= [ 'scilab.i', '-o', 'scilab.s' ]
456 class gzip(DefaultBenchmark
):
461 def test(self
, isa
, os
):
462 self
.args
= [ 'input.compressed', '2' ]
464 def train(self
, isa
, os
):
465 self
.args
= [ 'input.combined', '32' ]
467 class gzip_source(gzip
):
468 def ref(self
, isa
, os
):
469 self
.args
= [ 'input.source', '1' ]
470 def smred(self
, isa
, os
):
471 self
.args
= [ 'input.source', '1' ]
472 def mdred(self
, isa
, os
):
473 self
.args
= [ 'input.source', '1' ]
474 def lgred(self
, isa
, os
):
475 self
.args
= [ 'input.source', '1' ]
477 class gzip_log(gzip
):
478 def ref(self
, isa
, os
):
479 self
.args
= [ 'input.log', '60' ]
480 def smred(self
, isa
, os
):
481 self
.args
= [ 'input.log', '1' ]
482 def mdred(self
, isa
, os
):
483 self
.args
= [ 'input.log', '1' ]
484 def lgred(self
, isa
, os
):
485 self
.args
= [ 'input.log', '1' ]
487 class gzip_graphic(gzip
):
488 def ref(self
, isa
, os
):
489 self
.args
= [ 'input.graphic', '60' ]
490 def smred(self
, isa
, os
):
491 self
.args
= [ 'input.graphic', '1' ]
492 def mdred(self
, isa
, os
):
493 self
.args
= [ 'input.graphic', '1' ]
494 def lgred(self
, isa
, os
):
495 self
.args
= [ 'input.graphic', '1' ]
497 class gzip_random(gzip
):
498 def ref(self
, isa
, os
):
499 self
.args
= [ 'input.random', '60' ]
500 def smred(self
, isa
, os
):
501 self
.args
= [ 'input.random', '1' ]
502 def mdred(self
, isa
, os
):
503 self
.args
= [ 'input.random', '1' ]
504 def lgred(self
, isa
, os
):
505 self
.args
= [ 'input.random', '1' ]
507 class gzip_program(gzip
):
508 def ref(self
, isa
, os
):
509 self
.args
= [ 'input.program', '60' ]
510 def smred(self
, isa
, os
):
511 self
.args
= [ 'input.program', '1' ]
512 def mdred(self
, isa
, os
):
513 self
.args
= [ 'input.program', '1' ]
514 def lgred(self
, isa
, os
):
515 self
.args
= [ 'input.program', '1' ]
517 class mcf(MinneDefaultBenchmark
):
523 class parser(MinneDefaultBenchmark
):
527 args
= [ '2.1.dict', '-batch' ]
529 class perlbmk(DefaultBenchmark
):
534 def test(self
, isa
, os
):
535 self
.args
= [ '-I.', '-I', 'lib', 'test.pl' ]
536 self
.stdin
= 'test.in'
538 class perlbmk_diffmail(perlbmk
):
539 def ref(self
, isa
, os
):
540 self
.args
= [ '-I', 'lib', 'diffmail.pl', '2', '550', '15', '24',
543 def train(self
, isa
, os
):
544 self
.args
= [ '-I', 'lib', 'diffmail.pl', '2', '350', '15', '24',
547 class perlbmk_scrabbl(perlbmk
):
548 def train(self
, isa
, os
):
549 self
.args
= [ '-I.', '-I', 'lib', 'scrabbl.pl' ]
550 self
.stdin
= 'scrabbl.in'
552 class perlbmk_makerand(perlbmk
):
553 def ref(self
, isa
, os
):
554 self
.args
= [ '-I', 'lib', 'makerand.pl' ]
556 def lgred(self
, isa
, os
):
557 self
.args
= [ '-I.', '-I', 'lib', 'lgred.makerand.pl' ]
559 def mdred(self
, isa
, os
):
560 self
.args
= [ '-I.', '-I', 'lib', 'mdred.makerand.pl' ]
562 def smred(self
, isa
, os
):
563 self
.args
= [ '-I.', '-I', 'lib', 'smred.makerand.pl' ]
565 class perlbmk_perfect(perlbmk
):
566 def ref(self
, isa
, os
):
567 self
.args
= [ '-I', 'lib', 'perfect.pl', 'b', '3', 'm', '4' ]
569 def train(self
, isa
, os
):
570 self
.args
= [ '-I', 'lib', 'perfect.pl', 'b', '3' ]
572 class perlbmk_splitmail1(perlbmk
):
573 def ref(self
, isa
, os
):
574 self
.args
= [ '-I', 'lib', 'splitmail.pl', '850', '5', '19',
577 class perlbmk_splitmail2(perlbmk
):
578 def ref(self
, isa
, os
):
579 self
.args
= [ '-I', 'lib', 'splitmail.pl', '704', '12', '26',
582 class perlbmk_splitmail3(perlbmk
):
583 def ref(self
, isa
, os
):
584 self
.args
= [ '-I', 'lib', 'splitmail.pl', '535', '13', '25',
587 class perlbmk_splitmail4(perlbmk
):
588 def ref(self
, isa
, os
):
589 self
.args
= [ '-I', 'lib', 'splitmail.pl', '957', '12', '23',
592 class twolf(Benchmark
):
598 def test(self
, isa
, os
):
599 self
.args
= [ 'test' ]
601 def train(self
, isa
, os
):
602 self
.args
= [ 'train' ]
604 def ref(self
, isa
, os
):
605 self
.args
= [ 'ref' ]
607 def smred(self
, isa
, os
):
608 self
.args
= [ 'smred' ]
610 def mdred(self
, isa
, os
):
611 self
.args
= [ 'mdred' ]
613 def lgred(self
, isa
, os
):
614 self
.args
= [ 'lgred' ]
616 class vortex(Benchmark
):
622 def __init__(self
, isa
, os
, input_set
):
624 self
.endian
= 'lendian'
625 elif (isa
== 'sparc' or isa
== 'sparc32'):
626 self
.endian
= 'bendian'
628 raise AttributeError, "unknown ISA %s" % isa
630 super(vortex
, self
).__init
__(isa
, os
, input_set
)
632 def test(self
, isa
, os
):
633 self
.args
= [ '%s.raw' % self
.endian
]
634 self
.output
= 'vortex.out'
636 def train(self
, isa
, os
):
637 self
.args
= [ '%s.raw' % self
.endian
]
638 self
.output
= 'vortex.out'
640 def smred(self
, isa
, os
):
641 self
.args
= [ '%s.raw' % self
.endian
]
642 self
.output
= 'vortex.out'
644 def mdred(self
, isa
, os
):
645 self
.args
= [ '%s.raw' % self
.endian
]
646 self
.output
= 'vortex.out'
648 def lgred(self
, isa
, os
):
649 self
.args
= [ '%s.raw' % self
.endian
]
650 self
.output
= 'vortex.out'
652 class vortex1(vortex
):
653 def ref(self
, isa
, os
):
654 self
.args
= [ '%s1.raw' % self
.endian
]
655 self
.output
= 'vortex1.out'
658 class vortex2(vortex
):
659 def ref(self
, isa
, os
):
660 self
.args
= [ '%s2.raw' % self
.endian
]
661 self
.output
= 'vortex2.out'
663 class vortex3(vortex
):
664 def ref(self
, isa
, os
):
665 self
.args
= [ '%s3.raw' % self
.endian
]
666 self
.output
= 'vortex3.out'
668 class vpr(MinneDefaultBenchmark
):
673 # not sure about vpr minnespec place.in
674 class vpr_place(vpr
):
675 args
= [ 'net.in', 'arch.in', 'place.out', 'dum.out', '-nodisp',
676 '-place_only', '-init_t', '5', '-exit_t', '0.005',
677 '-alpha_t', '0.9412', '-inner_num', '2' ]
678 output
= 'place_log.out'
680 class vpr_route(vpr
):
681 args
= [ 'net.in', 'arch.in', 'place.in', 'route.out', '-nodisp',
682 '-route_only', '-route_chan_width', '15',
683 '-pres_fac_mult', '2', '-acc_fac', '1',
684 '-first_iter_pres_fac', '4', '-initial_pres_fac', '8' ]
685 output
= 'route_log.out'
687 all
= [ ammp
, applu
, apsi
, art110
, art470
, equake
, facerec
, fma3d
, galgel
,
688 lucas
, mesa
, mgrid
, sixtrack
, swim
, wupwise
, bzip2_source
,
689 bzip2_graphic
, bzip2_program
, crafty
, eon_kajiya
, eon_cook
,
690 eon_rushmeier
, gap
, gcc_166
, gcc_200
, gcc_expr
, gcc_integrate
,
691 gcc_scilab
, gzip_source
, gzip_log
, gzip_graphic
, gzip_random
,
692 gzip_program
, mcf
, parser
, perlbmk_diffmail
, perlbmk_makerand
,
693 perlbmk_perfect
, perlbmk_splitmail1
, perlbmk_splitmail2
,
694 perlbmk_splitmail3
, perlbmk_splitmail4
, twolf
, vortex1
, vortex2
,
695 vortex3
, vpr_place
, vpr_route
]
697 __all__
= [ x
.__name
__ for x
in all
]
699 if __name__
== '__main__':
700 from pprint
import pprint
702 for input_set
in 'ref', 'test', 'train':
703 print 'class: %s' % bench
.__name
__
704 x
= bench('alpha', 'tru64', input_set
)
705 print '%s: %s' % (x
, input_set
)
706 pprint(x
.makeLiveProcessArgs())