[pypy-commit] pypy release-pypy2.7-5.x: mark some vector tests x86 only (test cases are written for x86 ISA assumptions)

plan_rich pypy.commits at gmail.com
Wed Nov 9 09:06:07 EST 2016


Author: Richard Plangger <planrichi at gmail.com>
Branch: release-pypy2.7-5.x
Changeset: r88264:aff251e54385
Date: 2016-11-08 09:52 +0100
http://bitbucket.org/pypy/pypy/changeset/aff251e54385/

Log:	mark some vector tests x86 only (test cases are written for x86 ISA
	assumptions)

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
@@ -418,9 +418,7 @@
     def test_sum_float_to_int16(self):
         result = self.run("sum_float_to_int16")
         assert result == sum(range(30))
-        # one can argue that this is not desired,
-        # but unpacking exactly hits savings = 0
-        self.check_vectorized(1, 1)
+
     def define_sum_float_to_int32():
         return """
         a = |30|
@@ -429,7 +427,6 @@
     def test_sum_float_to_int32(self):
         result = self.run("sum_float_to_int32")
         assert result == sum(range(30))
-        self.check_vectorized(1, 1)
 
     def define_sum_float_to_float32():
         return """
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_schedule.py b/rpython/jit/metainterp/optimizeopt/test/test_schedule.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_schedule.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_schedule.py
@@ -1,6 +1,7 @@
 import py
 import sys
 import pytest
+import platform
 
 from rpython.jit.metainterp.history import TargetToken, JitCellToken, TreeLoop
 from rpython.jit.metainterp.optimizeopt.util import equaloplists
@@ -125,6 +126,7 @@
         """, False)
         self.assert_equal(loop2, loop3)
 
+    @py.test.mark.skipif("not platform.machine().startswith('x86')")
     def test_int_to_float(self):
         loop1 = self.parse_trace("""
         i10 = raw_load_i(p0, i0, descr=long)
@@ -227,6 +229,7 @@
         """, False, additional_args=['v10[2xi64]'])
         self.assert_equal(loop2, loop3)
 
+    @py.test.mark.skipif("not platform.machine().startswith('x86')")
     def test_cast_float_to_int(self):
         loop1 = self.parse_trace("""
         f10 = raw_load_f(p0, i1, descr=double)
diff --git a/rpython/jit/metainterp/test/test_vector.py b/rpython/jit/metainterp/test/test_vector.py
--- a/rpython/jit/metainterp/test/test_vector.py
+++ b/rpython/jit/metainterp/test/test_vector.py
@@ -3,7 +3,7 @@
 import pytest
 import math
 import functools
-from hypothesis import given, note, strategies as st
+from hypothesis import given, note, strategies as st, settings
 from rpython.jit.metainterp.warmspot import ll_meta_interp, get_stats
 from rpython.jit.metainterp.test.support import LLJitMixin
 from rpython.jit.codewriter.policy import StopAtXPolicy
@@ -150,9 +150,7 @@
                 i += size
 
         la = data.draw(st.lists(st.floats(), min_size=10, max_size=150))
-        #la = [0.0, 0.0, 0.0, 0.0, 5e-324, 0.0, 0.0, 5e-324, 0.0, 0.0]
         l = len(la)
-        #lb = [0.0] * l
         lb = data.draw(st.lists(st.floats(), min_size=l, max_size=l))
 
         rawstorage = RawStorage()
@@ -181,15 +179,14 @@
         vec_float_binary(lambda a,b: a-b, rffi.DOUBLE)
     test_vec_float_mul = \
         vec_float_binary(lambda a,b: a*b, rffi.DOUBLE)
-    #test_vec_float_div = \
-    #    vec_float_binary(lambda a,b: a/b, rffi.DOUBLE)
 
     test_vec_float_cmp_eq = \
         vec_float_binary(lambda a,b: a == b, rffi.DOUBLE)
     test_vec_float_cmp_ne = \
         vec_float_binary(lambda a,b: a != b, rffi.DOUBLE)
 
-    def _vector_simple_int(self, func, type, strat, data):
+    def _vector_simple_int(self, func, type, la):
+        oldfunc = func
         func = always_inline(func)
 
         size = rffi.sizeof(type)
@@ -204,9 +201,8 @@
                 raw_storage_setitem(vc, i, rffi.cast(type,c))
                 i += size
 
-        la = data.draw(st.lists(strat, min_size=10, max_size=150))
         l = len(la)
-        lb = data.draw(st.lists(strat, min_size=l, max_size=l))
+        lb = list(reversed(la))[:]
 
         rawstorage = RawStorage()
         va = rawstorage.new(la, type)
@@ -216,7 +212,7 @@
 
         for i in range(l):
             c = raw_storage_getitem(type,vc,i*size)
-            assert rffi.cast(type, func(la[i], lb[i])) == c
+            assert rffi.cast(type, oldfunc(la[i], lb[i])) == c
 
         rawstorage.clear()
 
@@ -225,50 +221,52 @@
         bits = size*8
         assert 0 <= bits <= 64
         integers = st.integers(min_value=-2**(bits-1), max_value=2**(bits-1)-1)
-        return pytest.mark.parametrize('func,type,strat', [
-            (arith_func, type, integers)
-        ])(given(data=st.data())(test_func))
+        @given(st.lists(integers, min_size=10, max_size=15))
+        @settings(max_examples=20)
+        def tf(self, la):
+            return test_func(self, arith_func, type, la)
+        return tf
 
     vec_int_arith = functools.partial(vec_int_arith, _vector_simple_int)
 
-    test_vec_signed_add = \
+    test_vec_simple_int_signed_add = \
         vec_int_arith(lambda a,b: intmask(a+b), rffi.SIGNED)
-    test_vec_int_add = \
-        vec_int_arith(lambda a,b: r_int(a)+r_int(b), rffi.INT)
-    test_vec_short_add = \
-        vec_int_arith(lambda a,b: r_int(a)+r_int(b), rffi.SHORT)
+    test_vec_simple_int_int_add = \
+        vec_int_arith(lambda a,b: intmask(r_int(a)+r_int(b)), rffi.INT)
+    test_vec_simple_int_short_add = \
+        vec_int_arith(lambda a,b: intmask(r_int(a)+r_int(b)), rffi.SHORT)
 
-    test_vec_signed_sub = \
+    test_vec_simple_int_signed_sub = \
         vec_int_arith(lambda a,b: intmask(a-b), rffi.SIGNED)
-    test_vec_sub_int = \
-        vec_int_arith(lambda a,b: r_int(a)-r_int(b), rffi.INT)
-    test_vec_sub_short = \
-        vec_int_arith(lambda a,b: r_int(a)-r_int(b), rffi.SHORT)
+    test_vec_simple_int_sub_int = \
+        vec_int_arith(lambda a,b: intmask(r_int(a)-r_int(b)), rffi.INT)
+    test_vec_simple_int_sub_short = \
+        vec_int_arith(lambda a,b: intmask(r_int(a)-r_int(b)), rffi.SHORT)
 
-    test_vec_signed_and = \
+    test_vec_simple_int_signed_and = \
         vec_int_arith(lambda a,b: intmask(a)&intmask(b), rffi.SIGNED)
-    test_vec_int_and = \
+    test_vec_simple_int_int_and = \
         vec_int_arith(lambda a,b: intmask(a)&intmask(b), rffi.INT)
-    test_vec_short_and = \
+    test_vec_simple_int_short_and = \
         vec_int_arith(lambda a,b: intmask(a)&intmask(b), rffi.SHORT)
 
-    test_vec_or_signed = \
+    test_vec_simple_int_or_signed = \
         vec_int_arith(lambda a,b: intmask(a)|intmask(b), rffi.SIGNED)
-    test_vec_or_int = \
+    test_vec_simple_int_or_int = \
         vec_int_arith(lambda a,b: intmask(a)|intmask(b), rffi.INT)
-    test_vec_or_short = \
+    test_vec_simple_int_or_short = \
         vec_int_arith(lambda a,b: intmask(a)|intmask(b), rffi.SHORT)
 
-    test_vec_xor_signed = \
+    test_vec_simple_int_xor_signed = \
         vec_int_arith(lambda a,b: intmask(a)^intmask(b), rffi.SIGNED)
-    test_vec_xor_int = \
+    test_vec_simple_int_xor_int = \
         vec_int_arith(lambda a,b: intmask(a)^intmask(b), rffi.INT)
-    test_vec_xor_short = \
+    test_vec_simple_int_xor_short = \
         vec_int_arith(lambda a,b: intmask(a)^intmask(b), rffi.SHORT)
 
-    test_vec_int_cmp_eq = \
+    test_vec_simple_int_int_cmp_eq = \
         vec_int_arith(lambda a,b: a == b, rffi.SIGNED)
-    test_vec_int_cmp_ne = \
+    test_vec_simple_int_int_cmp_ne = \
         vec_int_arith(lambda a,b: a == b, rffi.SIGNED)
 
     @py.test.mark.parametrize('i',[1,2,3,4,9])
@@ -414,9 +412,9 @@
 
     test_vec_int_sum = vec_reduce(st.integers(min_value=-2**(64-1), max_value=2**(64-1)-1),
                              lambda a,b: lltype.intmask(lltype.intmask(a)+lltype.intmask(b)), lltype.Signed)
-    test_vec_float_sum = vec_reduce(st.floats(), lambda a,b: a+b, rffi.DOUBLE)
-    test_vec_float_prod = vec_reduce(st.floats(min_value=-100, max_value=100,
-                                               allow_nan=False, allow_infinity=False), lambda a,b: a*b, rffi.DOUBLE)
+    small_floats = st.floats(min_value=-100, max_value=100, allow_nan=False, allow_infinity=False)
+    test_vec_float_sum = vec_reduce(small_floats, lambda a,b: a+b, rffi.DOUBLE)
+    test_vec_float_prod = vec_reduce(small_floats, lambda a,b: a*b, rffi.DOUBLE)
 
 
     def test_constant_expand(self):


More information about the pypy-commit mailing list