1 # Copyright (c) 2006-2008 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
29 from __future__
import print_function
30 from __future__
import absolute_import
34 from os
.path
import basename
, exists
, join
as joinpath
, normpath
35 from os
.path
import isdir
, isfile
, islink
37 spec_dist
= os
.environ
.get('M5_CPU2000', '/dist/m5/cpu2000')
39 def copyfiles(srcdir
, dstdir
):
40 from filecmp
import cmp as filecmp
41 from shutil
import copyfile
43 srcdir
= normpath(srcdir
)
44 dstdir
= normpath(dstdir
)
49 for root
, dirs
, files
in os
.walk(srcdir
):
51 prefix
= os
.path
.commonprefix([root
, srcdir
])
53 root
= root
[len(prefix
):]
54 if root
.startswith('/'):
58 newdir
= joinpath(dstdir
, root
, entry
)
63 dest
= normpath(joinpath(dstdir
, root
, entry
))
64 src
= normpath(joinpath(srcdir
, root
, entry
))
65 if not isfile(dest
) or not filecmp(src
, dest
):
68 # some of the spec benchmarks expect to be run from one directory up.
69 # just create some symlinks that solve the problem
70 inlink
= joinpath(dstdir
, 'input')
71 outlink
= joinpath(dstdir
, 'output')
72 if not exists(inlink
):
73 os
.symlink('.', inlink
)
74 if not exists(outlink
):
75 os
.symlink('.', outlink
)
77 class Benchmark(object):
78 def __init__(self
, isa
, os
, input_set
):
79 if not hasattr(self
.__class
__, 'name'):
80 self
.name
= self
.__class
__.__name
__
82 if not hasattr(self
.__class
__, 'binary'):
83 self
.binary
= self
.name
85 if not hasattr(self
.__class
__, 'args'):
88 if not hasattr(self
.__class
__, 'output'):
89 self
.output
= '%s.out' % self
.name
91 if not hasattr(self
.__class
__, 'simpoint'):
95 func
= getattr(self
.__class
__, input_set
)
96 except AttributeError:
98 'The benchmark %s does not have the %s input set' % \
99 (self
.name
, input_set
))
101 executable
= joinpath(spec_dist
, 'binaries', isa
, os
, self
.binary
)
102 if not isfile(executable
):
103 raise AttributeError('%s not found' % executable
)
104 self
.executable
= executable
106 # root of tree for input & output data files
107 data_dir
= joinpath(spec_dist
, 'data', self
.name
)
108 # optional subtree with files shared across input sets
109 all_dir
= joinpath(data_dir
, 'all')
110 # dirs for input & output files for this input set
111 inputs_dir
= joinpath(data_dir
, input_set
, 'input')
112 outputs_dir
= joinpath(data_dir
, input_set
, 'output')
113 # keep around which input set was specified
114 self
.input_set
= input_set
116 if not isdir(inputs_dir
):
117 raise AttributeError('%s not found' % inputs_dir
)
119 self
.inputs_dir
= [ inputs_dir
]
121 self
.inputs_dir
+= [ joinpath(all_dir
, 'input') ]
122 if isdir(outputs_dir
):
123 self
.outputs_dir
= outputs_dir
125 if not hasattr(self
.__class
__, 'stdin'):
126 self
.stdin
= joinpath(inputs_dir
, '%s.in' % self
.name
)
127 if not isfile(self
.stdin
):
130 if not hasattr(self
.__class
__, 'stdout'):
131 self
.stdout
= joinpath(outputs_dir
, '%s.out' % self
.name
)
132 if not isfile(self
.stdout
):
137 def makeProcessArgs(self
, **kwargs
):
138 # set up default args for Process object
140 process_args
['cmd'] = [ self
.name
] + self
.args
141 process_args
['executable'] = self
.executable
143 process_args
['input'] = self
.stdin
145 process_args
['output'] = self
.stdout
147 process_args
['simpoint'] = self
.simpoint
148 # explicit keywords override defaults
149 process_args
.update(kwargs
)
153 def makeProcess(self
, **kwargs
):
154 process_args
= self
.makeProcessArgs(**kwargs
)
156 # figure out working directory: use m5's outdir unless
157 # overridden by Process's cwd param
158 cwd
= process_args
.get('cwd')
161 from m5
import options
163 process_args
['cwd'] = cwd
166 # copy input files to working directory
167 for d
in self
.inputs_dir
:
169 # generate Process object
170 from m5
.objects
import Process
171 return Process(**process_args
)
176 class DefaultBenchmark(Benchmark
):
177 def ref(self
, isa
, os
): pass
178 def test(self
, isa
, os
): pass
179 def train(self
, isa
, os
): pass
181 class MinneDefaultBenchmark(DefaultBenchmark
):
182 def smred(self
, isa
, os
): pass
183 def mdred(self
, isa
, os
): pass
184 def lgred(self
, isa
, os
): pass
186 class ammp(MinneDefaultBenchmark
):
192 class applu(MinneDefaultBenchmark
):
196 simpoint
= 2179*100E6
198 class apsi(MinneDefaultBenchmark
):
202 simpoint
= 3408*100E6
204 class art(DefaultBenchmark
):
209 def test(self
, isa
, os
):
210 self
.args
= [ '-scanfile', 'c756hel.in',
211 '-trainfile1', 'a10.img',
218 self
.output
= 'test.out'
220 def train(self
, isa
, os
):
221 self
.args
= [ '-scanfile', 'c756hel.in',
222 '-trainfile1', 'a10.img',
229 self
.output
= 'train.out'
231 def lgred(self
, isa
, os
):
232 self
.args
= ['-scanfile', 'c756hel.in',
233 '-trainfile1', 'a10.img',
240 self
.output
= 'lgred.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.1.out'
255 self
.simpoint
= 340*100E6
258 def ref(self
, isa
, os
):
259 self
.args
= [ '-scanfile', 'c756hel.in',
260 '-trainfile1', 'a10.img',
261 '-trainfile2', 'hc.img',
268 self
.output
= 'ref.2.out'
269 self
.simpoint
= 365*100E6
271 class equake(DefaultBenchmark
):
277 def lgred(self
, isa
, os
): pass
279 class facerec(MinneDefaultBenchmark
):
285 class fma3d(MinneDefaultBenchmark
):
289 simpoint
= 2541*100E6
291 class galgel(MinneDefaultBenchmark
):
295 simpoint
= 2491*100E6
297 class lucas(MinneDefaultBenchmark
):
303 class mesa(Benchmark
):
309 def __set_args(self
, frames
):
310 self
.args
= [ '-frames', frames
, '-meshfile', '%s.in' % self
.name
,
311 '-ppmfile', '%s.ppm' % self
.name
]
313 def test(self
, isa
, os
):
314 self
.__set
_args
('10')
316 def train(self
, isa
, os
):
317 self
.__set
_args
('500')
319 def ref(self
, isa
, os
):
320 self
.__set
_args
('1000')
321 self
.simpoint
= 1135*100E6
323 def lgred(self
, isa
, os
):
326 class mgrid(MinneDefaultBenchmark
):
330 simpoint
= 3292*100E6
332 class sixtrack(DefaultBenchmark
):
336 simpoint
= 3043*100E6
338 def lgred(self
, isa
, os
): pass
340 class swim(MinneDefaultBenchmark
):
344 simpoint
= 2079*100E6
346 class wupwise(DefaultBenchmark
):
350 simpoint
= 3237*100E6
352 def lgred(self
, isa
, os
): pass
354 class bzip2(DefaultBenchmark
):
359 def test(self
, isa
, os
):
360 self
.args
= [ 'input.random' ]
362 def train(self
, isa
, os
):
363 self
.args
= [ 'input.compressed' ]
365 class bzip2_source(bzip2
):
366 def ref(self
, isa
, os
):
367 self
.simpoint
= 977*100E6
368 self
.args
= [ 'input.source', '58' ]
370 def lgred(self
, isa
, os
):
371 self
.args
= [ 'input.source', '1' ]
373 class bzip2_graphic(bzip2
):
374 def ref(self
, isa
, os
):
375 self
.simpoint
= 718*100E6
376 self
.args
= [ 'input.graphic', '58' ]
378 def lgred(self
, isa
, os
):
379 self
.args
= [ 'input.graphic', '1' ]
381 class bzip2_program(bzip2
):
382 def ref(self
, isa
, os
):
383 self
.simpoint
= 458*100E6
384 self
.args
= [ 'input.program', '58' ]
386 def lgred(self
, isa
, os
):
387 self
.args
= [ 'input.program', '1' ]
389 class crafty(MinneDefaultBenchmark
):
395 class eon(MinneDefaultBenchmark
):
401 class eon_kajiya(eon
):
402 args
= [ 'chair.control.kajiya', 'chair.camera', 'chair.surfaces',
403 'chair.kajiya.ppm', 'ppm', 'pixels_out.kajiya']
404 output
= 'kajiya_log.out'
408 args
= [ 'chair.control.cook', 'chair.camera', 'chair.surfaces',
409 'chair.cook.ppm', 'ppm', 'pixels_out.cook' ]
410 output
= 'cook_log.out'
412 class eon_rushmeier(eon
):
413 args
= [ 'chair.control.rushmeier', 'chair.camera', 'chair.surfaces',
414 'chair.rushmeier.ppm', 'ppm', 'pixels_out.rushmeier' ]
415 output
= 'rushmeier_log.out'
418 class gap(DefaultBenchmark
):
423 def __set_args(self
, size
):
424 self
.args
= [ '-l', './', '-q', '-m', size
]
426 def test(self
, isa
, os
):
427 self
.__set
_args
('64M')
429 def train(self
, isa
, os
):
430 self
.__set
_args
('128M')
432 def ref(self
, isa
, os
):
433 self
.__set
_args
('192M')
434 self
.simpoint
= 674*100E6
436 def lgred(self
, isa
, os
):
437 self
.__set
_args
('64M')
439 def mdred(self
, isa
, os
):
440 self
.__set
_args
('64M')
442 def smred(self
, isa
, os
):
443 self
.__set
_args
('64M')
445 class gcc(DefaultBenchmark
):
450 def test(self
, isa
, os
):
451 self
.args
= [ 'cccp.i', '-o', 'cccp.s' ]
453 def train(self
, isa
, os
):
454 self
.args
= [ 'cp-decl.i', '-o', 'cp-decl.s' ]
456 def smred(self
, isa
, os
):
457 self
.args
= [ 'c-iterate.i', '-o', 'c-iterate.s' ]
459 def mdred(self
, isa
, os
):
460 self
.args
= [ 'rdlanal.i', '-o', 'rdlanal.s' ]
462 def lgred(self
, isa
, os
):
463 self
.args
= [ 'cp-decl.i', '-o', 'cp-decl.s' ]
466 def ref(self
, isa
, os
):
467 self
.simpoint
= 389*100E6
468 self
.args
= [ '166.i', '-o', '166.s' ]
471 def ref(self
, isa
, os
):
472 self
.simpoint
= 736*100E6
473 self
.args
= [ '200.i', '-o', '200.s' ]
476 def ref(self
, isa
, os
):
477 self
.simpoint
= 36*100E6
478 self
.args
= [ 'expr.i', '-o', 'expr.s' ]
480 class gcc_integrate(gcc
):
481 def ref(self
, isa
, os
):
482 self
.simpoint
= 4*100E6
483 self
.args
= [ 'integrate.i', '-o', 'integrate.s' ]
485 class gcc_scilab(gcc
):
486 def ref(self
, isa
, os
):
487 self
.simpoint
= 207*100E6
488 self
.args
= [ 'scilab.i', '-o', 'scilab.s' ]
490 class gzip(DefaultBenchmark
):
495 def test(self
, isa
, os
):
496 self
.args
= [ 'input.compressed', '2' ]
498 def train(self
, isa
, os
):
499 self
.args
= [ 'input.combined', '32' ]
501 class gzip_source(gzip
):
502 def ref(self
, isa
, os
):
503 self
.simpoint
= 334*100E6
504 self
.args
= [ 'input.source', '1' ]
505 def smred(self
, isa
, os
):
506 self
.args
= [ 'input.source', '1' ]
507 def mdred(self
, isa
, os
):
508 self
.args
= [ 'input.source', '1' ]
509 def lgred(self
, isa
, os
):
510 self
.args
= [ 'input.source', '1' ]
512 class gzip_log(gzip
):
513 def ref(self
, isa
, os
):
514 self
.simpoint
= 265*100E6
515 self
.args
= [ 'input.log', '60' ]
516 def smred(self
, isa
, os
):
517 self
.args
= [ 'input.log', '1' ]
518 def mdred(self
, isa
, os
):
519 self
.args
= [ 'input.log', '1' ]
520 def lgred(self
, isa
, os
):
521 self
.args
= [ 'input.log', '1' ]
523 class gzip_graphic(gzip
):
524 def ref(self
, isa
, os
):
525 self
.simpoint
= 653*100E6
526 self
.args
= [ 'input.graphic', '60' ]
527 def smred(self
, isa
, os
):
528 self
.args
= [ 'input.graphic', '1' ]
529 def mdred(self
, isa
, os
):
530 self
.args
= [ 'input.graphic', '1' ]
531 def lgred(self
, isa
, os
):
532 self
.args
= [ 'input.graphic', '1' ]
534 class gzip_random(gzip
):
535 def ref(self
, isa
, os
):
536 self
.simpoint
= 623*100E6
537 self
.args
= [ 'input.random', '60' ]
538 def smred(self
, isa
, os
):
539 self
.args
= [ 'input.random', '1' ]
540 def mdred(self
, isa
, os
):
541 self
.args
= [ 'input.random', '1' ]
542 def lgred(self
, isa
, os
):
543 self
.args
= [ 'input.random', '1' ]
545 class gzip_program(gzip
):
546 def ref(self
, isa
, os
):
547 self
.simpoint
= 1189*100E6
548 self
.args
= [ 'input.program', '60' ]
549 def smred(self
, isa
, os
):
550 self
.args
= [ 'input.program', '1' ]
551 def mdred(self
, isa
, os
):
552 self
.args
= [ 'input.program', '1' ]
553 def lgred(self
, isa
, os
):
554 self
.args
= [ 'input.program', '1' ]
556 class mcf(MinneDefaultBenchmark
):
563 class parser(MinneDefaultBenchmark
):
567 args
= [ '2.1.dict', '-batch' ]
568 simpoint
= 1146*100E6
570 class perlbmk(DefaultBenchmark
):
575 def test(self
, isa
, os
):
576 self
.args
= [ '-I.', '-I', 'lib', 'test.pl' ]
577 self
.stdin
= 'test.in'
579 class perlbmk_diffmail(perlbmk
):
580 def ref(self
, isa
, os
):
581 self
.simpoint
= 141*100E6
582 self
.args
= [ '-I', 'lib', 'diffmail.pl', '2', '550', '15', '24',
585 def train(self
, isa
, os
):
586 self
.args
= [ '-I', 'lib', 'diffmail.pl', '2', '350', '15', '24',
589 class perlbmk_scrabbl(perlbmk
):
590 def train(self
, isa
, os
):
591 self
.args
= [ '-I.', '-I', 'lib', 'scrabbl.pl' ]
592 self
.stdin
= 'scrabbl.in'
594 class perlbmk_makerand(perlbmk
):
595 def ref(self
, isa
, os
):
596 self
.simpoint
= 11*100E6
597 self
.args
= [ '-I', 'lib', 'makerand.pl' ]
599 def lgred(self
, isa
, os
):
600 self
.args
= [ '-I.', '-I', 'lib', 'lgred.makerand.pl' ]
602 def mdred(self
, isa
, os
):
603 self
.args
= [ '-I.', '-I', 'lib', 'mdred.makerand.pl' ]
605 def smred(self
, isa
, os
):
606 self
.args
= [ '-I.', '-I', 'lib', 'smred.makerand.pl' ]
608 class perlbmk_perfect(perlbmk
):
609 def ref(self
, isa
, os
):
610 self
.simpoint
= 5*100E6
611 self
.args
= [ '-I', 'lib', 'perfect.pl', 'b', '3', 'm', '4' ]
613 def train(self
, isa
, os
):
614 self
.args
= [ '-I', 'lib', 'perfect.pl', 'b', '3' ]
616 class perlbmk_splitmail1(perlbmk
):
617 def ref(self
, isa
, os
):
618 self
.simpoint
= 405*100E6
619 self
.args
= [ '-I', 'lib', 'splitmail.pl', '850', '5', '19',
622 class perlbmk_splitmail2(perlbmk
):
623 def ref(self
, isa
, os
):
624 self
.args
= [ '-I', 'lib', 'splitmail.pl', '704', '12', '26',
627 class perlbmk_splitmail3(perlbmk
):
628 def ref(self
, isa
, os
):
629 self
.args
= [ '-I', 'lib', 'splitmail.pl', '535', '13', '25',
632 class perlbmk_splitmail4(perlbmk
):
633 def ref(self
, isa
, os
):
634 self
.args
= [ '-I', 'lib', 'splitmail.pl', '957', '12', '23',
637 class twolf(Benchmark
):
643 def test(self
, isa
, os
):
644 self
.args
= [ 'test' ]
646 def train(self
, isa
, os
):
647 self
.args
= [ 'train' ]
649 def ref(self
, isa
, os
):
650 self
.simpoint
= 1066*100E6
651 self
.args
= [ 'ref' ]
653 def smred(self
, isa
, os
):
654 self
.args
= [ 'smred' ]
656 def mdred(self
, isa
, os
):
657 self
.args
= [ 'mdred' ]
659 def lgred(self
, isa
, os
):
660 self
.args
= [ 'lgred' ]
662 class vortex(Benchmark
):
668 def __init__(self
, isa
, os
, input_set
):
669 if (isa
in ('alpha', 'arm', 'thumb', 'aarch64')):
670 self
.endian
= 'lendian'
671 elif (isa
== 'sparc' or isa
== 'sparc32'):
672 self
.endian
= 'bendian'
674 raise AttributeError("unknown ISA %s" % isa
)
676 super(vortex
, self
).__init
__(isa
, os
, input_set
)
678 def test(self
, isa
, os
):
679 self
.args
= [ '%s.raw' % self
.endian
]
680 self
.output
= 'vortex.out'
682 def train(self
, isa
, os
):
683 self
.args
= [ '%s.raw' % self
.endian
]
684 self
.output
= 'vortex.out'
686 def smred(self
, isa
, os
):
687 self
.args
= [ '%s.raw' % self
.endian
]
688 self
.output
= 'vortex.out'
690 def mdred(self
, isa
, os
):
691 self
.args
= [ '%s.raw' % self
.endian
]
692 self
.output
= 'vortex.out'
694 def lgred(self
, isa
, os
):
695 self
.args
= [ '%s.raw' % self
.endian
]
696 self
.output
= 'vortex.out'
698 class vortex1(vortex
):
699 def ref(self
, isa
, os
):
700 self
.args
= [ '%s1.raw' % self
.endian
]
701 self
.output
= 'vortex1.out'
702 self
.simpoint
= 271*100E6
705 class vortex2(vortex
):
706 def ref(self
, isa
, os
):
707 self
.simpoint
= 1024*100E6
708 self
.args
= [ '%s2.raw' % self
.endian
]
709 self
.output
= 'vortex2.out'
711 class vortex3(vortex
):
712 def ref(self
, isa
, os
):
713 self
.simpoint
= 564*100E6
714 self
.args
= [ '%s3.raw' % self
.endian
]
715 self
.output
= 'vortex3.out'
717 class vpr(MinneDefaultBenchmark
):
722 # not sure about vpr minnespec place.in
723 class vpr_place(vpr
):
724 args
= [ 'net.in', 'arch.in', 'place.out', 'dum.out', '-nodisp',
725 '-place_only', '-init_t', '5', '-exit_t', '0.005',
726 '-alpha_t', '0.9412', '-inner_num', '2' ]
727 output
= 'place_log.out'
729 class vpr_route(vpr
):
731 args
= [ 'net.in', 'arch.in', 'place.in', 'route.out', '-nodisp',
732 '-route_only', '-route_chan_width', '15',
733 '-pres_fac_mult', '2', '-acc_fac', '1',
734 '-first_iter_pres_fac', '4', '-initial_pres_fac', '8' ]
735 output
= 'route_log.out'
737 all
= [ ammp
, applu
, apsi
, art
, art110
, art470
, equake
, facerec
, fma3d
, galgel
,
738 lucas
, mesa
, mgrid
, sixtrack
, swim
, wupwise
, bzip2_source
,
739 bzip2_graphic
, bzip2_program
, crafty
, eon_kajiya
, eon_cook
,
740 eon_rushmeier
, gap
, gcc_166
, gcc_200
, gcc_expr
, gcc_integrate
,
741 gcc_scilab
, gzip_source
, gzip_log
, gzip_graphic
, gzip_random
,
742 gzip_program
, mcf
, parser
, perlbmk_diffmail
, perlbmk_makerand
,
743 perlbmk_perfect
, perlbmk_splitmail1
, perlbmk_splitmail2
,
744 perlbmk_splitmail3
, perlbmk_splitmail4
, twolf
, vortex1
, vortex2
,
745 vortex3
, vpr_place
, vpr_route
]
747 __all__
= [ x
.__name
__ for x
in all
]
749 if __name__
== '__main__':
750 from pprint
import pprint
752 for input_set
in 'ref', 'test', 'train':
753 print('class: %s' % bench
.__name
__)
754 x
= bench('alpha', 'tru64', input_set
)
755 print('%s: %s' % (x
, input_set
))
756 pprint(x
.makeProcessArgs())