[pypy-commit] pypy numpy-speed: reset to try new approach

bdkearns noreply at buildbot.pypy.org
Fri Apr 18 00:09:04 CEST 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: numpy-speed
Changeset: r70721:ae7367976397
Date: 2014-04-17 15:16 -0400
http://bitbucket.org/pypy/pypy/changeset/ae7367976397/

Log:	reset to try new approach

diff --git a/pypy/module/micronumpy/iterators.py b/pypy/module/micronumpy/iterators.py
--- a/pypy/module/micronumpy/iterators.py
+++ b/pypy/module/micronumpy/iterators.py
@@ -79,9 +79,8 @@
 
 
 class ArrayIter(object):
-    _virtualizable_ = ['index', 'indices[*]', 'offset']
     _immutable_fields_ = ['array', 'size', 'ndim_m1', 'shape_m1[*]',
-                          'strides[*]', 'backstrides[*]', 'indices']
+                          'strides[*]', 'backstrides[*]']
 
     def __init__(self, array, size, shape, strides, backstrides):
         assert len(shape) == len(strides) == len(backstrides)
@@ -91,16 +90,11 @@
         self.shape_m1 = [s - 1 for s in shape]
         self.strides = strides
         self.backstrides = backstrides
+        self.reset()
 
-        self.index = 0
-        self.indices = [0] * len(shape)
-        self.offset = array.start
-
-    @jit.unroll_safe
     def reset(self):
         self.index = 0
-        for i in xrange(self.ndim_m1, -1, -1):
-            self.indices[i] = 0
+        self.indices = [0] * len(self.shape_m1)
         self.offset = self.array.start
 
     @jit.unroll_safe
diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py
--- a/pypy/module/micronumpy/loop.py
+++ b/pypy/module/micronumpy/loop.py
@@ -16,8 +16,7 @@
                              greens = ['shapelen', 'func', 'calc_dtype',
                                        'res_dtype'],
                              reds = ['shape', 'w_lhs', 'w_rhs', 'out',
-                                     'left_iter', 'right_iter', 'out_iter'],
-                             virtualizables=['out_iter'])
+                                     'left_iter', 'right_iter', 'out_iter'])
 
 def call2(space, shape, func, calc_dtype, res_dtype, w_lhs, w_rhs, out):
     # handle array_priority
@@ -270,10 +269,7 @@
 
 dot_driver = jit.JitDriver(name = 'numpy_dot',
                            greens = ['dtype'],
-                           reds=['n', 's1', 's2', 'i1', 'i2', 'i',
-                                 'left_impl', 'right_impl', 'result',
-                                 'outi', 'lefti', 'righti', 'oval'],
-                           virtualizables=['outi'])
+                           reds = 'auto')
 
 def multidim_dot(space, left, right, result, dtype, right_critical_dim):
     ''' assumes left, right are concrete arrays
@@ -309,11 +305,7 @@
             i = 0
             while i < n:
                 i += 1
-                dot_driver.jit_merge_point(dtype=dtype,
-                    n=n, s1=s1, s2=s2, i1=i1, i2=i2, i=i,
-                    left_impl=left_impl, right_impl=right_impl, result=result,
-                    outi=outi, lefti=lefti, righti=righti, oval=oval,
-                )
+                dot_driver.jit_merge_point(dtype=dtype)
                 lval = left_impl.getitem(i1).convert_to(space, dtype)
                 rval = right_impl.getitem(i2).convert_to(space, dtype)
                 oval = dtype.itemtype.add(oval, dtype.itemtype.mul(lval, rval))
diff --git a/pypy/module/micronumpy/test/test_zjit.py b/pypy/module/micronumpy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/micronumpy/test/test_zjit.py
@@ -99,11 +99,9 @@
         assert result == 3 + 3
         self.check_trace_count(1)
         self.check_simple_loop({
-            'arraylen_gc': 2,
-            'cond_call': 2,
             'float_add': 1,
-            'getarrayitem_gc': 2,
-            'getfield_gc': 4,
+            'getarrayitem_gc': 3,
+            'getfield_gc': 7,
             'guard_false': 1,
             'guard_not_invalidated': 1,
             'guard_true': 3,
@@ -113,8 +111,8 @@
             'jump': 1,
             'raw_load': 2,
             'raw_store': 1,
-            'setarrayitem_gc': 2,
-            'setfield_gc': 4,
+            'setarrayitem_gc': 3,
+            'setfield_gc': 6,
         })
 
     def define_pow():
@@ -128,15 +126,13 @@
         assert result == 3 ** 2
         self.check_trace_count(1)
         self.check_simple_loop({
-            'arraylen_gc': 2,
             'call': 3,
-            'cond_call': 2,
             'float_add': 1,
             'float_eq': 3,
             'float_mul': 2,
             'float_ne': 1,
-            'getarrayitem_gc': 2,
-            'getfield_gc': 4,
+            'getarrayitem_gc': 3,
+            'getfield_gc': 7,
             'guard_false': 4,
             'guard_not_invalidated': 1,
             'guard_true': 5,
@@ -147,8 +143,8 @@
             'jump': 1,
             'raw_load': 2,
             'raw_store': 1,
-            'setarrayitem_gc': 2,
-            'setfield_gc': 4,
+            'setarrayitem_gc': 3,
+            'setfield_gc': 6,
         })
 
     def define_sum():
@@ -530,7 +526,6 @@
         assert result == 1.0
         self.check_trace_count(1)
         self.check_simple_loop({
-            'cond_call': 2,
             'getarrayitem_gc': 2,
             'getfield_gc': 4,
             'guard_not_invalidated': 1,
@@ -569,7 +564,7 @@
             'raw_load': 2,
         })
         self.check_resops({
-            'cond_call': 4,
+            'arraylen_gc': 1,
             'float_add': 2,
             'float_mul': 2,
             'getarrayitem_gc': 7,
@@ -577,24 +572,23 @@
             'getfield_gc': 35,
             'getfield_gc_pure': 39,
             'guard_class': 4,
-            'guard_false': 18,
+            'guard_false': 14,
             'guard_nonnull': 12,
             'guard_nonnull_class': 4,
             'guard_not_invalidated': 2,
             'guard_true': 13,
-            'guard_value': 6,
+            'guard_value': 4,
             'int_add': 25,
             'int_ge': 4,
             'int_le': 8,
             'int_lt': 11,
             'int_sub': 4,
             'jump': 3,
-            'ptr_eq': 4,
-            'ptr_ne': 4,
+            'new_array': 1,
             'raw_load': 6,
             'raw_store': 1,
-            'setarrayitem_gc': 7,
-            'setfield_gc': 10,
+            'setarrayitem_gc': 8,
+            'setfield_gc': 15,
         })
 
     def define_argsort():


More information about the pypy-commit mailing list