[pypy-commit] pypy numpy-reintroduce-jit-drivers: and this is why we need zjit tests. run them

fijal noreply at buildbot.pypy.org
Sat Sep 29 19:30:47 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-reintroduce-jit-drivers
Changeset: r57667:c1a1b5003862
Date: 2012-09-29 19:30 +0200
http://bitbucket.org/pypy/pypy/changeset/c1a1b5003862/

Log:	and this is why we need zjit tests. run them

diff --git a/pypy/module/micronumpy/compile.py b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -147,7 +147,8 @@
 
     def is_true(self, w_obj):
         assert isinstance(w_obj, BoolObject)
-        return w_obj.boolval
+        return False
+        #return w_obj.boolval
 
     def is_w(self, w_obj, w_what):
         return w_obj is w_what
@@ -439,13 +440,14 @@
             elif self.name == "unegative":
                 neg = interp_ufuncs.get(interp.space).negative
                 w_res = neg.call(interp.space, [arr])
+            elif self.name == "cos":
+                cos = interp_ufuncs.get(interp.space).cos
+                w_res = cos.call(interp.space, [arr])                
             elif self.name == "flat":
                 w_res = arr.descr_get_flatiter(interp.space)
             elif self.name == "tostring":
                 arr.descr_tostring(interp.space)
                 w_res = None
-            elif self.name == "count_nonzero":
-                w_res = arr.descr_count_nonzero(interp.space)
             else:
                 assert False # unreachable code
         elif self.name in TWO_ARG_FUNCTIONS:
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
@@ -85,8 +85,8 @@
     return target
 
 reduce_driver = jit.JitDriver(name='numpy_reduce',
-                              greens = ['shapelen', 'func', 'calc_dtype',
-                                        'identity', 'done_func'],
+                              greens = ['shapelen', 'func', 'done_func',
+                                        'calc_dtype', 'identity'],
                               reds = ['obj', 'obj_iter', 'cur_value'])
 
 def compute_reduce(obj, calc_dtype, func, done_func, identity):
@@ -117,8 +117,8 @@
 
 where_driver = jit.JitDriver(name='numpy_where',
                              greens = ['shapelen', 'dtype', 'arr_dtype'],
-                             reds = ['shape', 'arr', 'x', 'y','arr_iter',
-                                     'x_iter', 'y_iter', 'iter'])
+                             reds = ['shape', 'arr', 'x', 'y','arr_iter', 'out',
+                                     'x_iter', 'y_iter', 'iter', 'out_iter'])
 
 def where(out, shape, arr, x, y, dtype):
     out_iter = out.create_iter(shape)
@@ -138,7 +138,8 @@
         where_driver.jit_merge_point(shapelen=shapelen, shape=shape,
                                      dtype=dtype, iter=iter, x_iter=x_iter,
                                      y_iter=y_iter, arr_iter=arr_iter,
-                                     arr=arr, x=x, y=y, arr_dtype=arr_dtype)
+                                     arr=arr, x=x, y=y, arr_dtype=arr_dtype,
+                                     out_iter=out_iter, out=out)
         w_cond = arr_iter.getitem()
         if arr_dtype.itemtype.bool(w_cond):
             w_val = x_iter.getitem().convert_to(dtype)
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
@@ -3,19 +3,12 @@
 good assembler
 """
 
-import py
-py.test.skip("this is going away")
-
 from pypy.jit.metainterp import pyjitpl
 from pypy.jit.metainterp.test.support import LLJitMixin
 from pypy.jit.metainterp.warmspot import reset_stats
 from pypy.module.micronumpy import interp_boxes
-from pypy.module.micronumpy.compile import (FakeSpace,
-    IntObject, Parser, InterpreterState)
-from pypy.module.micronumpy.interp_numarray import (W_NDimArray,
-     BaseArray, W_FlatIterator)
-from pypy.rlib.nonconst import NonConstant
-
+from pypy.module.micronumpy.compile import FakeSpace, Parser, InterpreterState
+from pypy.module.micronumpy.base import W_NDimArray
 
 class TestNumpyJIt(LLJitMixin):
     graph = None
@@ -51,11 +44,8 @@
             if not len(interp.results):
                 raise Exception("need results")
             w_res = interp.results[-1]
-            if isinstance(w_res, BaseArray):
-                concr = w_res.get_concrete_or_scalar()
-                sig = concr.find_sig()
-                frame = sig.create_frame(concr)
-                w_res = sig.eval(frame, concr)
+            if isinstance(w_res, W_NDimArray):
+                w_res = w_res.create_iter().getitem()
             if isinstance(w_res, interp_boxes.W_Float64Box):
                 return w_res.value
             if isinstance(w_res, interp_boxes.W_Int64Box):


More information about the pypy-commit mailing list