viff

changeset 996:5d64a7bf429c

Refactor preprocessing in benchmark.
author Martin Geisler <mg@daimi.au.dk>
date Thu, 02 Oct 2008 13:18:47 +0200
parents f2921340d625
children 4a31eebed787
files apps/benchmark.py
diffstat 1 files changed, 23 insertions(+), 23 deletions(-) [+]
line diff
     1.1 --- a/apps/benchmark.py	Thu Oct 02 12:14:58 2008 +0200
     1.2 +++ b/apps/benchmark.py	Thu Oct 02 13:18:47 2008 +0200
     1.3 @@ -142,35 +142,35 @@
     1.4          self.rt = rt
     1.5          self.operation = operation
     1.6  
     1.7 +        program_desc = {}
     1.8 +
     1.9          if isinstance(self.rt, BasicActiveRuntime):
    1.10              # TODO: Make this optional and maybe automatic. The
    1.11              # program descriptions below were found by carefully
    1.12              # studying the output reported when the benchmarks were
    1.13              # run with no preprocessing. So they are quite brittle.
    1.14 +            if self.operation == operator.mul:
    1.15 +                key = ("generate_triples", (Zp,))
    1.16 +                desc = [(i, 1, 0) for i in range(3 + 2*count, 3 + 3*count)]
    1.17 +                program_desc.setdefault(key, []).extend(desc)
    1.18 +            elif isinstance(self.rt, ComparisonToft05Mixin):
    1.19 +                key = ("generate_triples", (GF256,))
    1.20 +                desc = sum([[(c, 64, i, 1, 1, 0) for i in range(2, 33)] +
    1.21 +                            [(c, 64, i, 3, 1, 0) for i in range(17, 33)]
    1.22 +                            for c in range(3 + 2*count, 3 + 3*count)],
    1.23 +                           [])
    1.24 +                program_desc.setdefault(key, []).extend(desc)
    1.25 +            elif isinstance(self.rt, ComparisonToft07Mixin):
    1.26 +                key = ("generate_triples", (Zp,))
    1.27 +                desc = sum([[(c, 2, 4, i, 2, 1, 0) for i in range(1, 33)] +
    1.28 +                            [(c, 2, 4, 99, 2, 1, 0)] +
    1.29 +                            [(c, 2, 4, i, 1, 0) for i in range(65, 98)]
    1.30 +                            for c in range(3 + 2*count, 3 + 3*count)],
    1.31 +                           [])
    1.32 +                program_desc.setdefault(key, []).extend(desc)
    1.33 +
    1.34 +        if program_desc:
    1.35              print "Starting preprocessing"
    1.36 -            if self.operation == operator.mul:
    1.37 -                program_desc = {
    1.38 -                    ("generate_triples", (Zp,)):
    1.39 -                        [(i, 1, 0) for i in range(3 + 2*count, 3 + 3*count)]
    1.40 -                    }
    1.41 -            elif isinstance(self.rt, ComparisonToft05Mixin):
    1.42 -                program_desc = {
    1.43 -                    ("generate_triples", (GF256,)):
    1.44 -                    sum([[(c, 64, i, 1, 1, 0) for i in range(2, 33)] +
    1.45 -                         [(c, 64, i, 3, 1, 0) for i in range(17, 33)]
    1.46 -                         for c in range(3 + 2*count, 3 + 3*count)],
    1.47 -                        [])
    1.48 -                    }
    1.49 -            elif isinstance(self.rt, ComparisonToft07Mixin):
    1.50 -                program_desc = {
    1.51 -                    ("generate_triples", (Zp,)):
    1.52 -                    sum([[(c, 2, 4, i, 2, 1, 0) for i in range(1, 33)] +
    1.53 -                         [(c, 2, 4, 99, 2, 1, 0)] +
    1.54 -                         [(c, 2, 4, i, 1, 0) for i in range(65, 98)]
    1.55 -                         for c in range(3 + 2*count, 3 + 3*count)],
    1.56 -                        [])
    1.57 -                    }
    1.58 -
    1.59              record_start("preprocessing")
    1.60              preproc = rt.preprocess(program_desc)
    1.61              preproc.addCallback(record_stop, "preprocessing")