Author: Richard Plangger <r...@pasra.at>
Branch: vecopt
Changeset: r77618:c5bf438f0e12
Date: 2015-05-27 11:13 +0200
http://bitbucket.org/pypy/pypy/changeset/c5bf438f0e12/

Log:    added a vectorize_user parameter to try the vectorization on user
        code (array[i], numpy.array[i]), removed some old checks for
        test_axissum

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
@@ -285,7 +285,7 @@
         """
 
     def test_pow(self):
-        py.test.skip()
+        py.test.skip("Not implemented 
CDefinedIntSymbolic('RPY_TLOFS_rpy_errno')")
         result = self.run("pow")
         assert result == 29 ** 2
         self.check_trace_count(1)
@@ -299,7 +299,7 @@
         """
 
     def test_pow_int(self):
-        py.test.skip()
+        py.test.skip("Not implemented 
CDefinedIntSymbolic('RPY_TLOFS_rpy_errno')")
         result = self.run("pow_int")
         assert result == 15 ** 2
         self.check_trace_count(4)  # extra one for the astype
@@ -335,52 +335,10 @@
         """
 
     def test_axissum(self):
-        py.test.skip()
         result = self.run("axissum")
         assert result == 30
         # XXX note - the bridge here is fairly crucial and yet it's pretty
         #            bogus. We need to improve the situation somehow.
-        self.check_trace_count(2)
-        self.check_simple_loop({
-            'float_add': 1,
-            'getarrayitem_gc': 2,
-            'guard_false': 2,
-            'guard_not_invalidated': 1,
-            'guard_true': 1,
-            'int_add': 4,
-            'int_ge': 1,
-            'int_is_zero': 1,
-            'int_lt': 1,
-            'jump': 1,
-            'raw_load': 2,
-            'raw_store': 1,
-            'setarrayitem_gc': 1,
-        })
-        self.check_resops({
-            'float_add': 2,
-            'getarrayitem_gc': 5,
-            'getarrayitem_gc_pure': 7,
-            'getfield_gc': 5,
-            'getfield_gc_pure': 51,
-            'guard_class': 3,
-            'guard_false': 12,
-            'guard_nonnull': 11,
-            'guard_nonnull_class': 3,
-            'guard_not_invalidated': 2,
-            'guard_true': 10,
-            'guard_value': 6,
-            'int_add': 13,
-            'int_ge': 4,
-            'int_is_true': 3,
-            'int_is_zero': 4,
-            'int_le': 2,
-            'int_lt': 3,
-            'int_sub': 1,
-            'jump': 2,
-            'raw_load': 4,
-            'raw_store': 2,
-            'setarrayitem_gc': 4,
-        })
 
     def define_reduce():
         return """
diff --git a/rpython/jit/metainterp/history.py 
b/rpython/jit/metainterp/history.py
--- a/rpython/jit/metainterp/history.py
+++ b/rpython/jit/metainterp/history.py
@@ -552,7 +552,7 @@
 
 class BoxVector(Box, PrimitiveTypeMixin):
     type = VECTOR
-    _attrs_ = ('item_type','item_count','item_size','signed')
+    _attrs_ = ('item_type','item_count','item_size','item_signed')
     _extended_display = False
 
     def __init__(self, item_type=FLOAT, item_count=2, item_size=8, 
item_signed=False):
diff --git a/rpython/jit/metainterp/optimizeopt/__init__.py 
b/rpython/jit/metainterp/optimizeopt/__init__.py
--- a/rpython/jit/metainterp/optimizeopt/__init__.py
+++ b/rpython/jit/metainterp/optimizeopt/__init__.py
@@ -68,7 +68,9 @@
                                                           loop.operations)
         optimizations, unroll = build_opt_chain(metainterp_sd, enable_opts)
         if unroll:
-            if not export_state and warmstate.vectorize and 
jitdriver_sd.vectorize:
+            if not export_state and \
+                ((warmstate.vectorize and jitdriver_sd.vectorize) \
+                 or warmstate.vectorize_user):
                 optimize_vector(metainterp_sd, jitdriver_sd, loop, 
optimizations,
                                 inline_short_preamble, start_state)
             else:
diff --git a/rpython/jit/metainterp/optimizeopt/dependency.py 
b/rpython/jit/metainterp/optimizeopt/dependency.py
--- a/rpython/jit/metainterp/optimizeopt/dependency.py
+++ b/rpython/jit/metainterp/optimizeopt/dependency.py
@@ -986,6 +986,7 @@
         return mycoeff + self.constant - (othercoeff + other.constant)
 
     def emit_operations(self, opt, result_box=None):
+        assert not self.is_identity()
         box = self.var
         last_op = None
         if self.coefficient_mul != 1:
diff --git a/rpython/jit/metainterp/optimizeopt/vectorize.py 
b/rpython/jit/metainterp/optimizeopt/vectorize.py
--- a/rpython/jit/metainterp/optimizeopt/vectorize.py
+++ b/rpython/jit/metainterp/optimizeopt/vectorize.py
@@ -609,7 +609,6 @@
             return key
         return (None, 0, None)
 
-
     def get_key(self, guard_bool, operations, i):
         cmp_op = self.find_compare_guard_bool(guard_bool.getarg(0), 
operations, i)
         return self._get_key(cmp_op)
@@ -672,8 +671,9 @@
                         self.emit_operation(ResOperation(rop.SAME_AS, [box], 
op.result))
                         continue
                     else:
-                        index_var.emit_operations(self, op.result)
-                        continue
+                        if not index_var.is_identity():
+                            index_var.emit_operations(self, op.result)
+                            continue
             self.emit_operation(op)
 
         loop.operations = self._newoperations[:]
@@ -756,11 +756,11 @@
         return self.arg_ptypes[i] is not None
 
     def pack_ptype(self, op):
-        _, vbox = self.getvector_of_box(op.getarg(0))
+        _, vbox = self.sched_data.getvector_of_box(op.getarg(0))
         if vbox:
             return PackType.of(vbox)
         else:
-            raise RuntimeError("fatal: box %s is not in a vector box" % (arg,))
+            raise RuntimeError("fatal: box %s is not in a vector box" % 
(op.getarg(0),))
 
     def as_vector_operation(self, pack, sched_data, oplist):
         self.sched_data = sched_data
@@ -852,7 +852,7 @@
         # The instruction takes less items than the vector has.
         # Unpack if not at off 0
         if off != 0 and box_pos != 0:
-            vbox = self.unpack(vbox, off, count, arg_ptype)
+            vbox = self.unpack(vbox, off, len(ops), arg_ptype)
         #
         return vbox
 
diff --git a/rpython/jit/metainterp/warmspot.py 
b/rpython/jit/metainterp/warmspot.py
--- a/rpython/jit/metainterp/warmspot.py
+++ b/rpython/jit/metainterp/warmspot.py
@@ -73,7 +73,8 @@
                     inline=False, loop_longevity=0, retrace_limit=5,
                     function_threshold=4,
                     enable_opts=ALL_OPTS_NAMES, max_retrace_guards=15, 
-                    max_unroll_recursion=7, vectorize=0, **kwds):
+                    max_unroll_recursion=7, vectorize=0, vectorize_user=0,
+                    **kwds):
     from rpython.config.config import ConfigError
     translator = interp.typer.annotator.translator
     try:
@@ -97,6 +98,7 @@
         jd.warmstate.set_param_enable_opts(enable_opts)
         jd.warmstate.set_param_max_unroll_recursion(max_unroll_recursion)
         jd.warmstate.set_param_vectorize(vectorize)
+        jd.warmstate.set_param_vectorize_user(vectorize_user)
     warmrunnerdesc.finish()
     if graph_and_interp_only:
         return interp, graph
diff --git a/rpython/jit/metainterp/warmstate.py 
b/rpython/jit/metainterp/warmstate.py
--- a/rpython/jit/metainterp/warmstate.py
+++ b/rpython/jit/metainterp/warmstate.py
@@ -300,6 +300,9 @@
     def set_param_vectorize(self, value):
         self.vectorize = bool(value)
 
+    def set_param_vectorize_user(self, value):
+        self.vectorize_user = bool(value)
+
     def disable_noninlinable_function(self, greenkey):
         cell = self.JitCell.ensure_jit_cell_at_key(greenkey)
         cell.flags |= JC_DONT_TRACE_HERE
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -552,7 +552,8 @@
     'enable_opts': 'INTERNAL USE ONLY (MAY NOT WORK OR LEAD TO CRASHES): '
                    'optimizations to enable, or all = %s' % ENABLE_ALL_OPTS,
     'max_unroll_recursion': 'how many levels deep to unroll a recursive 
function',
-    'vectorize': 'turn on the vectorization optimization. requires sse4.1',
+    'vectorize': 'turn on the vectorization optimization (vecopt). requires 
sse4.1',
+    'vectorize_user': 'turn on the vecopt for the python user program. 
requires sse4.1',
     }
 
 PARAMETERS = {'threshold': 1039, # just above 1024, prime
@@ -568,6 +569,7 @@
               'enable_opts': 'all',
               'max_unroll_recursion': 7,
               'vectorize': 0,
+              'vectorize_user': 0,
               }
 unroll_parameters = unrolling_iterable(PARAMETERS.items())
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to