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 from __future__
import print_function
28 from __future__
import absolute_import
32 from os
.path
import basename
, exists
, join
as joinpath
, normpath
33 from os
.path
import isdir
, isfile
, islink
35 spec_dist
= os
.environ
.get('M5_CPU2000', '/dist/m5/cpu2000')
37 def copyfiles(srcdir
, dstdir
):
38 from filecmp
import cmp as filecmp
39 from shutil
import copyfile
41 srcdir
= normpath(srcdir
)
42 dstdir
= normpath(dstdir
)
47 for root
, dirs
, files
in os
.walk(srcdir
):
49 prefix
= os
.path
.commonprefix([root
, srcdir
])
51 root
= root
[len(prefix
):]
52 if root
.startswith('/'):
56 newdir
= joinpath(dstdir
, root
, entry
)
61 dest
= normpath(joinpath(dstdir
, root
, entry
))
62 src
= normpath(joinpath(srcdir
, root
, entry
))
63 if not isfile(dest
) or not filecmp(src
, dest
):
66 # some of the spec benchmarks expect to be run from one directory up.
67 # just create some symlinks that solve the problem
68 inlink
= joinpath(dstdir
, 'input')
69 outlink
= joinpath(dstdir
, 'output')
70 if not exists(inlink
):
71 os
.symlink('.', inlink
)
72 if not exists(outlink
):
73 os
.symlink('.', outlink
)
75 class Benchmark(object):
76 def __init__(self
, isa
, os
, input_set
):
77 if not hasattr(self
.__class
__, 'name'):
78 self
.name
= self
.__class
__.__name
__
80 if not hasattr(self
.__class
__, 'binary'):
81 self
.binary
= self
.name
83 if not hasattr(self
.__class
__, 'args'):
86 if not hasattr(self
.__class
__, 'output'):
87 self
.output
= '%s.out' % self
.name
89 if not hasattr(self
.__class
__, 'simpoint'):
93 func
= getattr(self
.__class
__, input_set
)
94 except AttributeError:
96 'The benchmark %s does not have the %s input set' % \
97 (self
.name
, input_set
))
99 executable
= joinpath(spec_dist
, 'binaries', isa
, os
, self
.binary
)
100 if not isfile(executable
):
101 raise AttributeError('%s not found' % executable
)
102 self
.executable
= executable
104 # root of tree for input & output data files
105 data_dir
= joinpath(spec_dist
, 'data', self
.name
)
106 # optional subtree with files shared across input sets
107 all_dir
= joinpath(data_dir
, 'all')
108 # dirs for input & output files for this input set
109 inputs_dir
= joinpath(data_dir
, input_set
, 'input')
110 outputs_dir
= joinpath(data_dir
, input_set
, 'output')
111 # keep around which input set was specified
112 self
.input_set
= input_set
114 if not isdir(inputs_dir
):
115 raise AttributeError('%s not found' % inputs_dir
)
117 self
.inputs_dir
= [ inputs_dir
]
119 self
.inputs_dir
+= [ joinpath(all_dir
, 'input') ]
120 if isdir(outputs_dir
):
121 self
.outputs_dir
= outputs_dir
123 if not hasattr(self
.__class
__, 'stdin'):
124 self
.stdin
= joinpath(inputs_dir
, '%s.in' % self
.name
)
125 if not isfile(self
.stdin
):
128 if not hasattr(self
.__class
__, 'stdout'):
129 self
.stdout
= joinpath(outputs_dir
, '%s.out' % self
.name
)
130 if not isfile(self
.stdout
):
135 def makeProcessArgs(self
, **kwargs
):
136 # set up default args for Process object
138 process_args
['cmd'] = [ self
.name
] + self
.args
139 process_args
['executable'] = self
.executable
141 process_args
['input'] = self
.stdin
143 process_args
['output'] = self
.stdout
145 process_args
['simpoint'] = self
.simpoint
146 # explicit keywords override defaults
147 process_args
.update(kwargs
)
151 def makeProcess(self
, **kwargs
):
152 process_args
= self
.makeProcessArgs(**kwargs
)
154 # figure out working directory: use m5's outdir unless
155 # overridden by Process's cwd param
156 cwd
= process_args
.get('cwd')
159 from m5
import options
161 process_args
['cwd'] = cwd
164 # copy input files to working directory
165 for d
in self
.inputs_dir
:
167 # generate Process object
168 from m5
.objects
import Process
169 return Process(**process_args
)
174 class DefaultBenchmark(Benchmark
):
175 def ref(self
, isa
, os
): pass
176 def test(self
, isa
, os
): pass
177 def train(self
, isa
, os
): pass
179 class MinneDefaultBenchmark(DefaultBenchmark
):
180 def smred(self
, isa
, os
): pass
181 def mdred(self
, isa
, os
): pass
182 def lgred(self
, isa
, os
): pass
184 class ammp(MinneDefaultBenchmark
):
190 class applu(MinneDefaultBenchmark
):
194 simpoint
= 2179*100E6
196 class apsi(MinneDefaultBenchmark
):
200 simpoint
= 3408*100E6
202 class art(DefaultBenchmark
):
207 def test(self
, isa
, os
):
208 self
.args
= [ '-scanfile', 'c756hel.in',
209 '-trainfile1', 'a10.img',
216 self
.output
= 'test.out'
218 def train(self
, isa
, os
):
219 self
.args
= [ '-scanfile', 'c756hel.in',
220 '-trainfile1', 'a10.img',
227 self
.output
= 'train.out'
229 def lgred(self
, isa
, os
):
230 self
.args
= ['-scanfile', 'c756hel.in',
231 '-trainfile1', 'a10.img',
238 self
.output
= 'lgred.out'
242 def ref(self
, isa
, os
):
243 self
.args
= [ '-scanfile', 'c756hel.in',
244 '-trainfile1', 'a10.img',
245 '-trainfile2', 'hc.img',
252 self
.output
= 'ref.1.out'
253 self
.simpoint
= 340*100E6
256 def ref(self
, isa
, os
):
257 self
.args
= [ '-scanfile', 'c756hel.in',
258 '-trainfile1', 'a10.img',
259 '-trainfile2', 'hc.img',
266 self
.output
= 'ref.2.out'
267 self
.simpoint
= 365*100E6
269 class equake(DefaultBenchmark
):
275 def lgred(self
, isa
, os
): pass
277 class facerec(MinneDefaultBenchmark
):
283 class fma3d(MinneDefaultBenchmark
):
287 simpoint
= 2541*100E6
289 class galgel(MinneDefaultBenchmark
):
293 simpoint
= 2491*100E6
295 class lucas(MinneDefaultBenchmark
):
301 class mesa(Benchmark
):
307 def __set_args(self
, frames
):
308 self
.args
= [ '-frames', frames
, '-meshfile', '%s.in' % self
.name
,
309 '-ppmfile', '%s.ppm' % self
.name
]
311 def test(self
, isa
, os
):
312 self
.__set
_args
('10')
314 def train(self
, isa
, os
):
315 self
.__set
_args
('500')
317 def ref(self
, isa
, os
):
318 self
.__set
_args
('1000')
319 self
.simpoint
= 1135*100E6
321 def lgred(self
, isa
, os
):
324 class mgrid(MinneDefaultBenchmark
):
328 simpoint
= 3292*100E6
330 class sixtrack(DefaultBenchmark
):
334 simpoint
= 3043*100E6
336 def lgred(self
, isa
, os
): pass
338 class swim(MinneDefaultBenchmark
):
342 simpoint
= 2079*100E6
344 class wupwise(DefaultBenchmark
):
348 simpoint
= 3237*100E6
350 def lgred(self
, isa
, os
): pass
352 class bzip2(DefaultBenchmark
):
357 def test(self
, isa
, os
):
358 self
.args
= [ 'input.random' ]
360 def train(self
, isa
, os
):
361 self
.args
= [ 'input.compressed' ]
363 class bzip2_source(bzip2
):
364 def ref(self
, isa
, os
):
365 self
.simpoint
= 977*100E6
366 self
.args
= [ 'input.source', '58' ]
368 def lgred(self
, isa
, os
):
369 self
.args
= [ 'input.source', '1' ]
371 class bzip2_graphic(bzip2
):
372 def ref(self
, isa
, os
):
373 self
.simpoint
= 718*100E6
374 self
.args
= [ 'input.graphic', '58' ]
376 def lgred(self
, isa
, os
):
377 self
.args
= [ 'input.graphic', '1' ]
379 class bzip2_program(bzip2
):
380 def ref(self
, isa
, os
):
381 self
.simpoint
= 458*100E6
382 self
.args
= [ 'input.program', '58' ]
384 def lgred(self
, isa
, os
):
385 self
.args
= [ 'input.program', '1' ]
387 class crafty(MinneDefaultBenchmark
):
393 class eon(MinneDefaultBenchmark
):
399 class eon_kajiya(eon
):
400 args
= [ 'chair.control.kajiya', 'chair.camera', 'chair.surfaces',
401 'chair.kajiya.ppm', 'ppm', 'pixels_out.kajiya']
402 output
= 'kajiya_log.out'
406 args
= [ 'chair.control.cook', 'chair.camera', 'chair.surfaces',
407 'chair.cook.ppm', 'ppm', 'pixels_out.cook' ]
408 output
= 'cook_log.out'
410 class eon_rushmeier(eon
):
411 args
= [ 'chair.control.rushmeier', 'chair.camera', 'chair.surfaces',
412 'chair.rushmeier.ppm', 'ppm', 'pixels_out.rushmeier' ]
413 output
= 'rushmeier_log.out'
416 class gap(DefaultBenchmark
):
421 def __set_args(self
, size
):
422 self
.args
= [ '-l', './', '-q', '-m', size
]
424 def test(self
, isa
, os
):
425 self
.__set
_args
('64M')
427 def train(self
, isa
, os
):
428 self
.__set
_args
('128M')
430 def ref(self
, isa
, os
):
431 self
.__set
_args
('192M')
432 self
.simpoint
= 674*100E6
434 def lgred(self
, isa
, os
):
435 self
.__set
_args
('64M')
437 def mdred(self
, isa
, os
):
438 self
.__set
_args
('64M')
440 def smred(self
, isa
, os
):
441 self
.__set
_args
('64M')
443 class gcc(DefaultBenchmark
):
448 def test(self
, isa
, os
):
449 self
.args
= [ 'cccp.i', '-o', 'cccp.s' ]
451 def train(self
, isa
, os
):
452 self
.args
= [ 'cp-decl.i', '-o', 'cp-decl.s' ]
454 def smred(self
, isa
, os
):
455 self
.args
= [ 'c-iterate.i', '-o', 'c-iterate.s' ]
457 def mdred(self
, isa
, os
):
458 self
.args
= [ 'rdlanal.i', '-o', 'rdlanal.s' ]
460 def lgred(self
, isa
, os
):
461 self
.args
= [ 'cp-decl.i', '-o', 'cp-decl.s' ]
464 def ref(self
, isa
, os
):
465 self
.simpoint
= 389*100E6
466 self
.args
= [ '166.i', '-o', '166.s' ]
469 def ref(self
, isa
, os
):
470 self
.simpoint
= 736*100E6
471 self
.args
= [ '200.i', '-o', '200.s' ]
474 def ref(self
, isa
, os
):
475 self
.simpoint
= 36*100E6
476 self
.args
= [ 'expr.i', '-o', 'expr.s' ]
478 class gcc_integrate(gcc
):
479 def ref(self
, isa
, os
):
480 self
.simpoint
= 4*100E6
481 self
.args
= [ 'integrate.i', '-o', 'integrate.s' ]
483 class gcc_scilab(gcc
):
484 def ref(self
, isa
, os
):
485 self
.simpoint
= 207*100E6
486 self
.args
= [ 'scilab.i', '-o', 'scilab.s' ]
488 class gzip(DefaultBenchmark
):
493 def test(self
, isa
, os
):
494 self
.args
= [ 'input.compressed', '2' ]
496 def train(self
, isa
, os
):
497 self
.args
= [ 'input.combined', '32' ]
499 class gzip_source(gzip
):
500 def ref(self
, isa
, os
):
501 self
.simpoint
= 334*100E6
502 self
.args
= [ 'input.source', '1' ]
503 def smred(self
, isa
, os
):
504 self
.args
= [ 'input.source', '1' ]
505 def mdred(self
, isa
, os
):
506 self
.args
= [ 'input.source', '1' ]
507 def lgred(self
, isa
, os
):
508 self
.args
= [ 'input.source', '1' ]
510 class gzip_log(gzip
):
511 def ref(self
, isa
, os
):
512 self
.simpoint
= 265*100E6
513 self
.args
= [ 'input.log', '60' ]
514 def smred(self
, isa
, os
):
515 self
.args
= [ 'input.log', '1' ]
516 def mdred(self
, isa
, os
):
517 self
.args
= [ 'input.log', '1' ]
518 def lgred(self
, isa
, os
):
519 self
.args
= [ 'input.log', '1' ]
521 class gzip_graphic(gzip
):
522 def ref(self
, isa
, os
):
523 self
.simpoint
= 653*100E6
524 self
.args
= [ 'input.graphic', '60' ]
525 def smred(self
, isa
, os
):
526 self
.args
= [ 'input.graphic', '1' ]
527 def mdred(self
, isa
, os
):
528 self
.args
= [ 'input.graphic', '1' ]
529 def lgred(self
, isa
, os
):
530 self
.args
= [ 'input.graphic', '1' ]
532 class gzip_random(gzip
):
533 def ref(self
, isa
, os
):
534 self
.simpoint
= 623*100E6
535 self
.args
= [ 'input.random', '60' ]
536 def smred(self
, isa
, os
):
537 self
.args
= [ 'input.random', '1' ]
538 def mdred(self
, isa
, os
):
539 self
.args
= [ 'input.random', '1' ]
540 def lgred(self
, isa
, os
):
541 self
.args
= [ 'input.random', '1' ]
543 class gzip_program(gzip
):
544 def ref(self
, isa
, os
):
545 self
.simpoint
= 1189*100E6
546 self
.args
= [ 'input.program', '60' ]
547 def smred(self
, isa
, os
):
548 self
.args
= [ 'input.program', '1' ]
549 def mdred(self
, isa
, os
):
550 self
.args
= [ 'input.program', '1' ]
551 def lgred(self
, isa
, os
):
552 self
.args
= [ 'input.program', '1' ]
554 class mcf(MinneDefaultBenchmark
):
561 class parser(MinneDefaultBenchmark
):
565 args
= [ '2.1.dict', '-batch' ]
566 simpoint
= 1146*100E6
568 class perlbmk(DefaultBenchmark
):
573 def test(self
, isa
, os
):
574 self
.args
= [ '-I.', '-I', 'lib', 'test.pl' ]
575 self
.stdin
= 'test.in'
577 class perlbmk_diffmail(perlbmk
):
578 def ref(self
, isa
, os
):
579 self
.simpoint
= 141*100E6
580 self
.args
= [ '-I', 'lib', 'diffmail.pl', '2', '550', '15', '24',
583 def train(self
, isa
, os
):
584 self
.args
= [ '-I', 'lib', 'diffmail.pl', '2', '350', '15', '24',
587 class perlbmk_scrabbl(perlbmk
):
588 def train(self
, isa
, os
):
589 self
.args
= [ '-I.', '-I', 'lib', 'scrabbl.pl' ]
590 self
.stdin
= 'scrabbl.in'
592 class perlbmk_makerand(perlbmk
):
593 def ref(self
, isa
, os
):
594 self
.simpoint
= 11*100E6
595 self
.args
= [ '-I', 'lib', 'makerand.pl' ]
597 def lgred(self
, isa
, os
):
598 self
.args
= [ '-I.', '-I', 'lib', 'lgred.makerand.pl' ]
600 def mdred(self
, isa
, os
):
601 self
.args
= [ '-I.', '-I', 'lib', 'mdred.makerand.pl' ]
603 def smred(self
, isa
, os
):
604 self
.args
= [ '-I.', '-I', 'lib', 'smred.makerand.pl' ]
606 class perlbmk_perfect(perlbmk
):
607 def ref(self
, isa
, os
):
608 self
.simpoint
= 5*100E6
609 self
.args
= [ '-I', 'lib', 'perfect.pl', 'b', '3', 'm', '4' ]
611 def train(self
, isa
, os
):
612 self
.args
= [ '-I', 'lib', 'perfect.pl', 'b', '3' ]
614 class perlbmk_splitmail1(perlbmk
):
615 def ref(self
, isa
, os
):
616 self
.simpoint
= 405*100E6
617 self
.args
= [ '-I', 'lib', 'splitmail.pl', '850', '5', '19',
620 class perlbmk_splitmail2(perlbmk
):
621 def ref(self
, isa
, os
):
622 self
.args
= [ '-I', 'lib', 'splitmail.pl', '704', '12', '26',
625 class perlbmk_splitmail3(perlbmk
):
626 def ref(self
, isa
, os
):
627 self
.args
= [ '-I', 'lib', 'splitmail.pl', '535', '13', '25',
630 class perlbmk_splitmail4(perlbmk
):
631 def ref(self
, isa
, os
):
632 self
.args
= [ '-I', 'lib', 'splitmail.pl', '957', '12', '23',
635 class twolf(Benchmark
):
641 def test(self
, isa
, os
):
642 self
.args
= [ 'test' ]
644 def train(self
, isa
, os
):
645 self
.args
= [ 'train' ]
647 def ref(self
, isa
, os
):
648 self
.simpoint
= 1066*100E6
649 self
.args
= [ 'ref' ]
651 def smred(self
, isa
, os
):
652 self
.args
= [ 'smred' ]
654 def mdred(self
, isa
, os
):
655 self
.args
= [ 'mdred' ]
657 def lgred(self
, isa
, os
):
658 self
.args
= [ 'lgred' ]
660 class vortex(Benchmark
):
666 def __init__(self
, isa
, os
, input_set
):
667 if (isa
in ('arm', 'thumb', 'aarch64')):
668 self
.endian
= 'lendian'
669 elif (isa
== 'sparc' or isa
== 'sparc32'):
670 self
.endian
= 'bendian'
672 raise AttributeError("unknown ISA %s" % isa
)
674 super(vortex
, self
).__init
__(isa
, os
, input_set
)
676 def test(self
, isa
, os
):
677 self
.args
= [ '%s.raw' % self
.endian
]
678 self
.output
= 'vortex.out'
680 def train(self
, isa
, os
):
681 self
.args
= [ '%s.raw' % self
.endian
]
682 self
.output
= 'vortex.out'
684 def smred(self
, isa
, os
):
685 self
.args
= [ '%s.raw' % self
.endian
]
686 self
.output
= 'vortex.out'
688 def mdred(self
, isa
, os
):
689 self
.args
= [ '%s.raw' % self
.endian
]
690 self
.output
= 'vortex.out'
692 def lgred(self
, isa
, os
):
693 self
.args
= [ '%s.raw' % self
.endian
]
694 self
.output
= 'vortex.out'
696 class vortex1(vortex
):
697 def ref(self
, isa
, os
):
698 self
.args
= [ '%s1.raw' % self
.endian
]
699 self
.output
= 'vortex1.out'
700 self
.simpoint
= 271*100E6
703 class vortex2(vortex
):
704 def ref(self
, isa
, os
):
705 self
.simpoint
= 1024*100E6
706 self
.args
= [ '%s2.raw' % self
.endian
]
707 self
.output
= 'vortex2.out'
709 class vortex3(vortex
):
710 def ref(self
, isa
, os
):
711 self
.simpoint
= 564*100E6
712 self
.args
= [ '%s3.raw' % self
.endian
]
713 self
.output
= 'vortex3.out'
715 class vpr(MinneDefaultBenchmark
):
720 # not sure about vpr minnespec place.in
721 class vpr_place(vpr
):
722 args
= [ 'net.in', 'arch.in', 'place.out', 'dum.out', '-nodisp',
723 '-place_only', '-init_t', '5', '-exit_t', '0.005',
724 '-alpha_t', '0.9412', '-inner_num', '2' ]
725 output
= 'place_log.out'
727 class vpr_route(vpr
):
729 args
= [ 'net.in', 'arch.in', 'place.in', 'route.out', '-nodisp',
730 '-route_only', '-route_chan_width', '15',
731 '-pres_fac_mult', '2', '-acc_fac', '1',
732 '-first_iter_pres_fac', '4', '-initial_pres_fac', '8' ]
733 output
= 'route_log.out'
735 all
= [ ammp
, applu
, apsi
, art
, art110
, art470
, equake
, facerec
, fma3d
, galgel
,
736 lucas
, mesa
, mgrid
, sixtrack
, swim
, wupwise
, bzip2_source
,
737 bzip2_graphic
, bzip2_program
, crafty
, eon_kajiya
, eon_cook
,
738 eon_rushmeier
, gap
, gcc_166
, gcc_200
, gcc_expr
, gcc_integrate
,
739 gcc_scilab
, gzip_source
, gzip_log
, gzip_graphic
, gzip_random
,
740 gzip_program
, mcf
, parser
, perlbmk_diffmail
, perlbmk_makerand
,
741 perlbmk_perfect
, perlbmk_splitmail1
, perlbmk_splitmail2
,
742 perlbmk_splitmail3
, perlbmk_splitmail4
, twolf
, vortex1
, vortex2
,
743 vortex3
, vpr_place
, vpr_route
]
745 __all__
= [ x
.__name
__ for x
in all
]
747 if __name__
== '__main__':
748 from pprint
import pprint
750 for input_set
in 'ref', 'test', 'train':
751 print('class: %s' % bench
.__name
__)
752 x
= bench('x86', 'linux', input_set
)
753 print('%s: %s' % (x
, input_set
))
754 pprint(x
.makeProcessArgs())