Author: Richard Plangger <r...@pasra.at>
Branch: vecopt
Changeset: r77175:209fd97b0b33
Date: 2015-05-07 14:49 +0200
http://bitbucket.org/pypy/pypy/changeset/209fd97b0b33/

Log:    numpy call2 now runs as vector ops (llgraph, x86 not yet)

diff --git a/rpython/jit/backend/llgraph/runner.py 
b/rpython/jit/backend/llgraph/runner.py
--- a/rpython/jit/backend/llgraph/runner.py
+++ b/rpython/jit/backend/llgraph/runner.py
@@ -668,20 +668,24 @@
         return lltype.malloc(rffi.CCHARP.TO, size, flavor='raw')
 
     # vector operations
-    def bh_vec_int_add(self, vx, vy, count):
+    vector_arith_code = """
+    def bh_vec_{0}_{1}(self, vx, vy, count):
         assert len(vx) == count
         assert len(vy) == count
-        return [_vx + _vy for _vx,_vy in zip(vx,vy)]
+        return [_vx {2} _vy for _vx,_vy in zip(vx,vy)]
+    """
+    exec py.code.Source(vector_arith_code.format('int','add','+')).compile()
+    exec py.code.Source(vector_arith_code.format('int','sub','-')).compile()
+    exec py.code.Source(vector_arith_code.format('int','mul','*')).compile()
+    exec py.code.Source(vector_arith_code.format('float','add','+')).compile()
+    exec py.code.Source(vector_arith_code.format('float','sub','-')).compile()
+    exec py.code.Source(vector_arith_code.format('float','mul','*')).compile()
 
-    def bh_vec_int_mul(self, vx, vy, count):
-        assert len(vx) == count
-        assert len(vy) == count
-        return [_vx * _vy for _vx,_vy in zip(vx,vy)]
+    def bh_vec_box_pack(self, vx, index, y):
+        vx[index] = y
 
-    def bh_vec_int_sub(self, vx, vy, count):
-        assert len(vx) == count
-        assert len(vy) == count
-        return [_vx - _vy for _vx,_vy in zip(vx,vy)]
+    def bh_vec_box_unpack(self, vx, index):
+        return vx[index]
 
     def bh_vec_int_signext(self, vx, ext, count):
         return [heaptracker.int_signext(_vx, ext) for _vx in vx]
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
@@ -517,7 +517,7 @@
     _attrs_ = ('item_type','byte_count','item_count','signed')
     _extended_display = False
 
-    def __init__(self, item_type, item_count, bytecount, signed):
+    def __init__(self, item_type=FLOAT, item_count=8, bytecount=2, 
signed=True):
         self.item_type = item_type
         self.item_count = item_count
         self.byte_count = bytecount
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
@@ -125,7 +125,7 @@
         op = guard.getoperation()
         assert isinstance(tgt_op, GuardResOp)
         assert isinstance(op, GuardResOp)
-        olddescr = tgt_op.getdescr()
+        olddescr = op.getdescr()
         descr = compile.ResumeAtLoopHeaderDescr()
         if olddescr:
             assert isinstance(olddescr, compile.ResumeGuardDescr)
diff --git a/rpython/jit/metainterp/pyjitpl.py 
b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -2184,6 +2184,8 @@
         self.current_merge_points = []
         self.resumekey = key
         self.seen_loop_header_for_jdindex = -1
+        import py
+        py.test.set_trace()
         if isinstance(key, compile.ResumeAtPositionDescr):
             self.seen_loop_header_for_jdindex = self.jitdriver_sd.index
         try:
@@ -2336,6 +2338,8 @@
         if opnum == rop.GUARD_FUTURE_CONDITION:
             pass
         elif opnum == rop.GUARD_EARLY_EXIT:
+            import py
+            py.test.set_trace()
             pass
         elif opnum == rop.GUARD_TRUE:     # a goto_if_not that jumps only now
             frame.pc = frame.jitcode.follow_jump(frame.pc)
diff --git a/rpython/jit/tool/oparser.py b/rpython/jit/tool/oparser.py
--- a/rpython/jit/tool/oparser.py
+++ b/rpython/jit/tool/oparser.py
@@ -121,7 +121,7 @@
             box = ts.BoxRef()
             _box_counter_more_than(self.model, elem[1:])
         elif elem.startswith('v'):
-            box = self.model.BoxVector('f', 8, 2, True)
+            box = self.model.BoxVector()
             _box_counter_more_than(self.model, elem[1:])
         else:
             for prefix, boxclass in self.boxkinds.iteritems():
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to