Author: Hakan Ardo <ha...@debian.org> Branch: extradoc Changeset: r4527:63e9884bf1b2 Date: 2012-08-12 20:27 +0200 http://bitbucket.org/pypy/extradoc/changeset/63e9884bf1b2/
Log: representation of 2D arrays as a list of arrays diff --git a/talk/iwtc11/benchmarks/benchmark.sh b/talk/iwtc11/benchmarks/benchmark.sh --- a/talk/iwtc11/benchmarks/benchmark.sh +++ b/talk/iwtc11/benchmarks/benchmark.sh @@ -50,8 +50,10 @@ #$* ./runner.py $EXTRA_OPTS image/noborder.py main NoBorderImage range #$* ./runner.py $EXTRA_OPTS image/sobel.py main NoBorderImagePadded #$* ./runner.py $EXTRA_OPTS image/sobel.py main NoBorderImagePadded uint8 - $* ./runner.py $EXTRA_OPTS scimark.py SOR 100 32768 - $* ./runner.py $EXTRA_OPTS scimark.py SOR 1000 256 + $* ./runner.py $EXTRA_OPTS scimark.py SOR 100 32768 Array2D + $* ./runner.py $EXTRA_OPTS scimark.py SOR 1000 256 Array2D + $* ./runner.py $EXTRA_OPTS scimark.py SOR 100 32768 ArrayList + $* ./runner.py $EXTRA_OPTS scimark.py SOR 1000 256 ArrayList $* ./runner.py $EXTRA_OPTS scimark.py SparseMatMult 1000 5000 262144 $* ./runner.py $EXTRA_OPTS scimark.py SparseMatMult 100000 1000000 1024 $* ./runner.py $EXTRA_OPTS scimark.py MonteCarlo 268435456 diff --git a/talk/iwtc11/benchmarks/scimark.py b/talk/iwtc11/benchmarks/scimark.py --- a/talk/iwtc11/benchmarks/scimark.py +++ b/talk/iwtc11/benchmarks/scimark.py @@ -60,6 +60,25 @@ return self.dm1 * float(k); +class ArrayList(Array2D): + def __init__(self, w, h, data=None): + self.width = w + self.height = h + self.data = [array('d', [0]) * w for y in xrange(h)] + if data is not None: + self.setup(data) + + def __getitem__(self, idx): + if isinstance(idx, tuple): + return self.data[idx[1]][idx[0]] + else: + return self.data[idx] + + def __setitem__(self, idx, val): + if isinstance(idx, tuple): + self.data[idx[1]][idx[0]] = val + else: + self.data[idx] = val def SOR_execute(omega, G, num_iterations): for p in xrange(num_iterations): @@ -68,8 +87,8 @@ G[x, y] = omega * 0.25 * (G[x, y-1] + G[x, y+1] + G[x-1, y] + G[x+1, y]) + \ (1.0 - omega) * G[x, y] def SOR(args): - n, cycles = map(int, args) - a = Array2D(n, n) + n, cycles, Array = map(eval, args) + a = Array(n, n) SOR_execute(1.25, a, cycles) return "SOR(%d, %d)" % (n, cycles) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit