8143e45dec9e8dd00c5d5cf6a66a82f73c9ec7fa
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
33 from os
.path
import basename
, exists
, join
as joinpath
, normpath
34 from os
.path
import isdir
, isfile
, islink
36 spec_dist
= os
.environ
.get('M5_CPU2000', '/dist/m5/cpu2000')
38 def copyfiles(srcdir
, dstdir
):
39 from filecmp
import cmp as filecmp
40 from shutil
import copyfile
42 srcdir
= normpath(srcdir
)
43 dstdir
= normpath(dstdir
)
48 for root
, dirs
, files
in os
.walk(srcdir
):
50 prefix
= os
.path
.commonprefix([root
, srcdir
])
52 root
= root
[len(prefix
):]
53 if root
.startswith('/'):
57 newdir
= joinpath(dstdir
, root
, entry
)
62 dest
= normpath(joinpath(dstdir
, root
, entry
))
63 src
= normpath(joinpath(srcdir
, root
, entry
))
64 if not isfile(dest
) or not filecmp(src
, dest
):
67 # some of the spec benchmarks expect to be run from one directory up.
68 # just create some symlinks that solve the problem
69 inlink
= joinpath(dstdir
, 'input')
70 outlink
= joinpath(dstdir
, 'output')
71 if not exists(inlink
):
72 os
.symlink('.', inlink
)
73 if not exists(outlink
):
74 os
.symlink('.', outlink
)
76 class Benchmark(object):
77 def __init__(self
, isa
, os
, input_set
):
78 if not hasattr(self
.__class
__, 'name'):
79 self
.name
= self
.__class
__.__name
__
81 if not hasattr(self
.__class
__, 'binary'):
82 self
.binary
= self
.name
84 if not hasattr(self
.__class
__, 'args'):
87 if not hasattr(self
.__class
__, 'output'):
88 self
.output
= '%s.out' % self
.name
90 if not hasattr(self
.__class
__, 'simpoint'):
94 func
= getattr(self
.__class
__, input_set
)
95 except AttributeError:
97 'The benchmark %s does not have the %s input set' % \
98 (self
.name
, input_set
))
100 executable
= joinpath(spec_dist
, 'binaries', isa
, os
, self
.binary
)
101 if not isfile(executable
):
102 raise AttributeError('%s not found' % executable
)
103 self
.executable
= executable
105 # root of tree for input & output data files
106 data_dir
= joinpath(spec_dist
, 'data', self
.name
)
107 # optional subtree with files shared across input sets
108 all_dir
= joinpath(data_dir
, 'all')
109 # dirs for input & output files for this input set
110 inputs_dir
= joinpath(data_dir
, input_set
, 'input')
111 outputs_dir
= joinpath(data_dir
, input_set
, 'output')
112 # keep around which input set was specified
113 self
.input_set
= input_set
115 if not isdir(inputs_dir
):
116 raise AttributeError('%s not found' % inputs_dir
)
118 self
.inputs_dir
= [ inputs_dir
]
120 self
.inputs_dir
+= [ joinpath(all_dir
, 'input') ]
121 if isdir(outputs_dir
):
122 self
.outputs_dir
= outputs_dir
124 if not hasattr(self
.__class
__, 'stdin'):
125 self
.stdin
= joinpath(inputs_dir
, '%s.in' % self
.name
)
126 if not isfile(self
.stdin
):
129 if not hasattr(self
.__class
__, 'stdout'):
130 self
.stdout
= joinpath(outputs_dir
, '%s.out' % self
.name
)
131 if not isfile(self
.stdout
):
136 def makeProcessArgs(self
, **kwargs
):
137 # set up default args for Process object
139 process_args
['cmd'] = [ self
.name
] + self
.args
140 process_args
['executable'] = self
.executable
142 process_args
['input'] = self
.stdin
144 process_args
['output'] = self
.stdout
146 process_args
['simpoint'] = self
.simpoint
147 # explicit keywords override defaults
148 process_args
.update(kwargs
)
152 def makeProcess(self
, **kwargs
):
153 process_args
= self
.makeProcessArgs(**kwargs
)
155 # figure out working directory: use m5's outdir unless
156 # overridden by Process's cwd param
157 cwd
= process_args
.get('cwd')
160 from m5
import options
162 process_args
['cwd'] = cwd
165 # copy input files to working directory
166 for d
in self
.inputs_dir
:
168 # generate Process object
169 from m5
.objects
import Process
170 return Process(**process_args
)
175 class DefaultBenchmark(Benchmark
):
176 def ref(self
, isa
, os
): pass
177 def test(self
, isa
, os
): pass
178 def train(self
, isa
, os
): pass
180 class MinneDefaultBenchmark(DefaultBenchmark
):
181 def smred(self
, isa
, os
): pass
182 def mdred(self
, isa
, os
): pass
183 def lgred(self
, isa
, os
): pass
185 class ammp(MinneDefaultBenchmark
):
191 class applu(MinneDefaultBenchmark
):
195 simpoint
= 2179*100E6
197 class apsi(MinneDefaultBenchmark
):
201 simpoint
= 3408*100E6
203 class art(DefaultBenchmark
):
208 def test(self
, isa
, os
):
209 self
.args
= [ '-scanfile', 'c756hel.in',
210 '-trainfile1', 'a10.img',
217 self
.output
= 'test.out'
219 def train(self
, isa
, os
):
220 self
.args
= [ '-scanfile', 'c756hel.in',
221 '-trainfile1', 'a10.img',
228 self
.output
= 'train.out'
230 def lgred(self
, isa
, os
):
231 self
.args
= ['-scanfile', 'c756hel.in',
232 '-trainfile1', 'a10.img',
239 self
.output
= 'lgred.out'
243 def ref(self
, isa
, os
):
244 self
.args
= [ '-scanfile', 'c756hel.in',
245 '-trainfile1', 'a10.img',
246 '-trainfile2', 'hc.img',
253 self
.output
= 'ref.1.out'
254 self
.simpoint
= 340*100E6
257 def ref(self
, isa
, os
):
258 self
.args
= [ '-scanfile', 'c756hel.in',
259 '-trainfile1', 'a10.img',
260 '-trainfile2', 'hc.img',
267 self
.output
= 'ref.2.out'
268 self
.simpoint
= 365*100E6
270 class equake(DefaultBenchmark
):
276 def lgred(self
, isa
, os
): pass
278 class facerec(MinneDefaultBenchmark
):
284 class fma3d(MinneDefaultBenchmark
):
288 simpoint
= 2541*100E6
290 class galgel(MinneDefaultBenchmark
):
294 simpoint
= 2491*100E6
296 class lucas(MinneDefaultBenchmark
):
302 class mesa(Benchmark
):
308 def __set_args(self
, frames
):
309 self
.args
= [ '-frames', frames
, '-meshfile', '%s.in' % self
.name
,
310 '-ppmfile', '%s.ppm' % self
.name
]
312 def test(self
, isa
, os
):
313 self
.__set
_args
('10')
315 def train(self
, isa
, os
):
316 self
.__set
_args
('500')
318 def ref(self
, isa
, os
):
319 self
.__set
_args
('1000')
320 self
.simpoint
= 1135*100E6
322 def lgred(self
, isa
, os
):
325 class mgrid(MinneDefaultBenchmark
):
329 simpoint
= 3292*100E6
331 class sixtrack(DefaultBenchmark
):
335 simpoint
= 3043*100E6
337 def lgred(self
, isa
, os
): pass
339 class swim(MinneDefaultBenchmark
):
343 simpoint
= 2079*100E6
345 class wupwise(DefaultBenchmark
):
349 simpoint
= 3237*100E6
351 def lgred(self
, isa
, os
): pass
353 class bzip2(DefaultBenchmark
):
358 def test(self
, isa
, os
):
359 self
.args
= [ 'input.random' ]
361 def train(self
, isa
, os
):
362 self
.args
= [ 'input.compressed' ]
364 class bzip2_source(bzip2
):
365 def ref(self
, isa
, os
):
366 self
.simpoint
= 977*100E6
367 self
.args
= [ 'input.source', '58' ]
369 def lgred(self
, isa
, os
):
370 self
.args
= [ 'input.source', '1' ]
372 class bzip2_graphic(bzip2
):
373 def ref(self
, isa
, os
):
374 self
.simpoint
= 718*100E6
375 self
.args
= [ 'input.graphic', '58' ]
377 def lgred(self
, isa
, os
):
378 self
.args
= [ 'input.graphic', '1' ]
380 class bzip2_program(bzip2
):
381 def ref(self
, isa
, os
):
382 self
.simpoint
= 458*100E6
383 self
.args
= [ 'input.program', '58' ]
385 def lgred(self
, isa
, os
):
386 self
.args
= [ 'input.program', '1' ]
388 class crafty(MinneDefaultBenchmark
):
394 class eon(MinneDefaultBenchmark
):
400 class eon_kajiya(eon
):
401 args
= [ 'chair.control.kajiya', 'chair.camera', 'chair.surfaces',
402 'chair.kajiya.ppm', 'ppm', 'pixels_out.kajiya']
403 output
= 'kajiya_log.out'
407 args
= [ 'chair.control.cook', 'chair.camera', 'chair.surfaces',
408 'chair.cook.ppm', 'ppm', 'pixels_out.cook' ]
409 output
= 'cook_log.out'
411 class eon_rushmeier(eon
):
412 args
= [ 'chair.control.rushmeier', 'chair.camera', 'chair.surfaces',
413 'chair.rushmeier.ppm', 'ppm', 'pixels_out.rushmeier' ]
414 output
= 'rushmeier_log.out'
417 class gap(DefaultBenchmark
):
422 def __set_args(self
, size
):
423 self
.args
= [ '-l', './', '-q', '-m', size
]
425 def test(self
, isa
, os
):
426 self
.__set
_args
('64M')
428 def train(self
, isa
, os
):
429 self
.__set
_args
('128M')
431 def ref(self
, isa
, os
):
432 self
.__set
_args
('192M')
433 self
.simpoint
= 674*100E6
435 def lgred(self
, isa
, os
):
436 self
.__set
_args
('64M')
438 def mdred(self
, isa
, os
):
439 self
.__set
_args
('64M')
441 def smred(self
, isa
, os
):
442 self
.__set
_args
('64M')
444 class gcc(DefaultBenchmark
):
449 def test(self
, isa
, os
):
450 self
.args
= [ 'cccp.i', '-o', 'cccp.s' ]
452 def train(self
, isa
, os
):
453 self
.args
= [ 'cp-decl.i', '-o', 'cp-decl.s' ]
455 def smred(self
, isa
, os
):
456 self
.args
= [ 'c-iterate.i', '-o', 'c-iterate.s' ]
458 def mdred(self
, isa
, os
):
459 self
.args
= [ 'rdlanal.i', '-o', 'rdlanal.s' ]
461 def lgred(self
, isa
, os
):
462 self
.args
= [ 'cp-decl.i', '-o', 'cp-decl.s' ]
465 def ref(self
, isa
, os
):
466 self
.simpoint
= 389*100E6
467 self
.args
= [ '166.i', '-o', '166.s' ]
470 def ref(self
, isa
, os
):
471 self
.simpoint
= 736*100E6
472 self
.args
= [ '200.i', '-o', '200.s' ]
475 def ref(self
, isa
, os
):
476 self
.simpoint
= 36*100E6
477 self
.args
= [ 'expr.i', '-o', 'expr.s' ]
479 class gcc_integrate(gcc
):
480 def ref(self
, isa
, os
):
481 self
.simpoint
= 4*100E6
482 self
.args
= [ 'integrate.i', '-o', 'integrate.s' ]
484 class gcc_scilab(gcc
):
485 def ref(self
, isa
, os
):
486 self
.simpoint
= 207*100E6
487 self
.args
= [ 'scilab.i', '-o', 'scilab.s' ]
489 class gzip(DefaultBenchmark
):
494 def test(self
, isa
, os
):
495 self
.args
= [ 'input.compressed', '2' ]
497 def train(self
, isa
, os
):
498 self
.args
= [ 'input.combined', '32' ]
500 class gzip_source(gzip
):
501 def ref(self
, isa
, os
):
502 self
.simpoint
= 334*100E6
503 self
.args
= [ 'input.source', '1' ]
504 def smred(self
, isa
, os
):
505 self
.args
= [ 'input.source', '1' ]
506 def mdred(self
, isa
, os
):
507 self
.args
= [ 'input.source', '1' ]
508 def lgred(self
, isa
, os
):
509 self
.args
= [ 'input.source', '1' ]
511 class gzip_log(gzip
):
512 def ref(self
, isa
, os
):
513 self
.simpoint
= 265*100E6
514 self
.args
= [ 'input.log', '60' ]
515 def smred(self
, isa
, os
):
516 self
.args
= [ 'input.log', '1' ]
517 def mdred(self
, isa
, os
):
518 self
.args
= [ 'input.log', '1' ]
519 def lgred(self
, isa
, os
):
520 self
.args
= [ 'input.log', '1' ]
522 class gzip_graphic(gzip
):
523 def ref(self
, isa
, os
):
524 self
.simpoint
= 653*100E6
525 self
.args
= [ 'input.graphic', '60' ]
526 def smred(self
, isa
, os
):
527 self
.args
= [ 'input.graphic', '1' ]
528 def mdred(self
, isa
, os
):
529 self
.args
= [ 'input.graphic', '1' ]
530 def lgred(self
, isa
, os
):
531 self
.args
= [ 'input.graphic', '1' ]
533 class gzip_random(gzip
):
534 def ref(self
, isa
, os
):
535 self
.simpoint
= 623*100E6
536 self
.args
= [ 'input.random', '60' ]
537 def smred(self
, isa
, os
):
538 self
.args
= [ 'input.random', '1' ]
539 def mdred(self
, isa
, os
):
540 self
.args
= [ 'input.random', '1' ]
541 def lgred(self
, isa
, os
):
542 self
.args
= [ 'input.random', '1' ]
544 class gzip_program(gzip
):
545 def ref(self
, isa
, os
):
546 self
.simpoint
= 1189*100E6
547 self
.args
= [ 'input.program', '60' ]
548 def smred(self
, isa
, os
):
549 self
.args
= [ 'input.program', '1' ]
550 def mdred(self
, isa
, os
):
551 self
.args
= [ 'input.program', '1' ]
552 def lgred(self
, isa
, os
):
553 self
.args
= [ 'input.program', '1' ]
555 class mcf(MinneDefaultBenchmark
):
562 class parser(MinneDefaultBenchmark
):
566 args
= [ '2.1.dict', '-batch' ]
567 simpoint
= 1146*100E6
569 class perlbmk(DefaultBenchmark
):
574 def test(self
, isa
, os
):
575 self
.args
= [ '-I.', '-I', 'lib', 'test.pl' ]
576 self
.stdin
= 'test.in'
578 class perlbmk_diffmail(perlbmk
):
579 def ref(self
, isa
, os
):
580 self
.simpoint
= 141*100E6
581 self
.args
= [ '-I', 'lib', 'diffmail.pl', '2', '550', '15', '24',
584 def train(self
, isa
, os
):
585 self
.args
= [ '-I', 'lib', 'diffmail.pl', '2', '350', '15', '24',
588 class perlbmk_scrabbl(perlbmk
):
589 def train(self
, isa
, os
):
590 self
.args
= [ '-I.', '-I', 'lib', 'scrabbl.pl' ]
591 self
.stdin
= 'scrabbl.in'
593 class perlbmk_makerand(perlbmk
):
594 def ref(self
, isa
, os
):
595 self
.simpoint
= 11*100E6
596 self
.args
= [ '-I', 'lib', 'makerand.pl' ]
598 def lgred(self
, isa
, os
):
599 self
.args
= [ '-I.', '-I', 'lib', 'lgred.makerand.pl' ]
601 def mdred(self
, isa
, os
):
602 self
.args
= [ '-I.', '-I', 'lib', 'mdred.makerand.pl' ]
604 def smred(self
, isa
, os
):
605 self
.args
= [ '-I.', '-I', 'lib', 'smred.makerand.pl' ]
607 class perlbmk_perfect(perlbmk
):
608 def ref(self
, isa
, os
):
609 self
.simpoint
= 5*100E6
610 self
.args
= [ '-I', 'lib', 'perfect.pl', 'b', '3', 'm', '4' ]
612 def train(self
, isa
, os
):
613 self
.args
= [ '-I', 'lib', 'perfect.pl', 'b', '3' ]
615 class perlbmk_splitmail1(perlbmk
):
616 def ref(self
, isa
, os
):
617 self
.simpoint
= 405*100E6
618 self
.args
= [ '-I', 'lib', 'splitmail.pl', '850', '5', '19',
621 class perlbmk_splitmail2(perlbmk
):
622 def ref(self
, isa
, os
):
623 self
.args
= [ '-I', 'lib', 'splitmail.pl', '704', '12', '26',
626 class perlbmk_splitmail3(perlbmk
):
627 def ref(self
, isa
, os
):
628 self
.args
= [ '-I', 'lib', 'splitmail.pl', '535', '13', '25',
631 class perlbmk_splitmail4(perlbmk
):
632 def ref(self
, isa
, os
):
633 self
.args
= [ '-I', 'lib', 'splitmail.pl', '957', '12', '23',
636 class twolf(Benchmark
):
642 def test(self
, isa
, os
):
643 self
.args
= [ 'test' ]
645 def train(self
, isa
, os
):
646 self
.args
= [ 'train' ]
648 def ref(self
, isa
, os
):
649 self
.simpoint
= 1066*100E6
650 self
.args
= [ 'ref' ]
652 def smred(self
, isa
, os
):
653 self
.args
= [ 'smred' ]
655 def mdred(self
, isa
, os
):
656 self
.args
= [ 'mdred' ]
658 def lgred(self
, isa
, os
):
659 self
.args
= [ 'lgred' ]
661 class vortex(Benchmark
):
667 def __init__(self
, isa
, os
, input_set
):
668 if (isa
in ('alpha', 'arm', 'thumb', 'aarch64')):
669 self
.endian
= 'lendian'
670 elif (isa
== 'sparc' or isa
== 'sparc32'):
671 self
.endian
= 'bendian'
673 raise AttributeError("unknown ISA %s" % isa
)
675 super(vortex
, self
).__init
__(isa
, os
, input_set
)
677 def test(self
, isa
, os
):
678 self
.args
= [ '%s.raw' % self
.endian
]
679 self
.output
= 'vortex.out'
681 def train(self
, isa
, os
):
682 self
.args
= [ '%s.raw' % self
.endian
]
683 self
.output
= 'vortex.out'
685 def smred(self
, isa
, os
):
686 self
.args
= [ '%s.raw' % self
.endian
]
687 self
.output
= 'vortex.out'
689 def mdred(self
, isa
, os
):
690 self
.args
= [ '%s.raw' % self
.endian
]
691 self
.output
= 'vortex.out'
693 def lgred(self
, isa
, os
):
694 self
.args
= [ '%s.raw' % self
.endian
]
695 self
.output
= 'vortex.out'
697 class vortex1(vortex
):
698 def ref(self
, isa
, os
):
699 self
.args
= [ '%s1.raw' % self
.endian
]
700 self
.output
= 'vortex1.out'
701 self
.simpoint
= 271*100E6
704 class vortex2(vortex
):
705 def ref(self
, isa
, os
):
706 self
.simpoint
= 1024*100E6
707 self
.args
= [ '%s2.raw' % self
.endian
]
708 self
.output
= 'vortex2.out'
710 class vortex3(vortex
):
711 def ref(self
, isa
, os
):
712 self
.simpoint
= 564*100E6
713 self
.args
= [ '%s3.raw' % self
.endian
]
714 self
.output
= 'vortex3.out'
716 class vpr(MinneDefaultBenchmark
):
721 # not sure about vpr minnespec place.in
722 class vpr_place(vpr
):
723 args
= [ 'net.in', 'arch.in', 'place.out', 'dum.out', '-nodisp',
724 '-place_only', '-init_t', '5', '-exit_t', '0.005',
725 '-alpha_t', '0.9412', '-inner_num', '2' ]
726 output
= 'place_log.out'
728 class vpr_route(vpr
):
730 args
= [ 'net.in', 'arch.in', 'place.in', 'route.out', '-nodisp',
731 '-route_only', '-route_chan_width', '15',
732 '-pres_fac_mult', '2', '-acc_fac', '1',
733 '-first_iter_pres_fac', '4', '-initial_pres_fac', '8' ]
734 output
= 'route_log.out'
736 all
= [ ammp
, applu
, apsi
, art
, art110
, art470
, equake
, facerec
, fma3d
, galgel
,
737 lucas
, mesa
, mgrid
, sixtrack
, swim
, wupwise
, bzip2_source
,
738 bzip2_graphic
, bzip2_program
, crafty
, eon_kajiya
, eon_cook
,
739 eon_rushmeier
, gap
, gcc_166
, gcc_200
, gcc_expr
, gcc_integrate
,
740 gcc_scilab
, gzip_source
, gzip_log
, gzip_graphic
, gzip_random
,
741 gzip_program
, mcf
, parser
, perlbmk_diffmail
, perlbmk_makerand
,
742 perlbmk_perfect
, perlbmk_splitmail1
, perlbmk_splitmail2
,
743 perlbmk_splitmail3
, perlbmk_splitmail4
, twolf
, vortex1
, vortex2
,
744 vortex3
, vpr_place
, vpr_route
]
746 __all__
= [ x
.__name
__ for x
in all
]
748 if __name__
== '__main__':
749 from pprint
import pprint
751 for input_set
in 'ref', 'test', 'train':
752 print('class: %s' % bench
.__name
__)
753 x
= bench('alpha', 'tru64', input_set
)
754 print('%s: %s' % (x
, input_set
))
755 pprint(x
.makeProcessArgs())