Author: Richard Plangger <[email protected]>
Branch: vecopt
Changeset: r78026:645362226e3e
Date: 2015-06-11 10:55 +0200
http://bitbucket.org/pypy/pypy/changeset/645362226e3e/
Log: added tests and parameterized one
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
@@ -685,6 +685,14 @@
dtype = get_dtype_cache(interp.space).w_int16dtype
elif self.v == 'int32':
dtype = get_dtype_cache(interp.space).w_int32dtype
+ elif self.v == 'uint':
+ dtype = get_dtype_cache(interp.space).w_uint64dtype
+ elif self.v == 'uint8':
+ dtype = get_dtype_cache(interp.space).w_uint8dtype
+ elif self.v == 'uint16':
+ dtype = get_dtype_cache(interp.space).w_uint16dtype
+ elif self.v == 'uint32':
+ dtype = get_dtype_cache(interp.space).w_uint32dtype
elif self.v == 'float':
dtype = get_dtype_cache(interp.space).w_float64dtype
elif self.v == 'float32':
@@ -932,6 +940,16 @@
stack.append(DtypeClass('int32'))
elif token.v.strip(' ') == 'int64':
stack.append(DtypeClass('int'))
+ elif token.v.strip(' ') == 'uint':
+ stack.append(DtypeClass('uint'))
+ elif token.v.strip(' ') == 'uint8':
+ stack.append(DtypeClass('uint8'))
+ elif token.v.strip(' ') == 'uint16':
+ stack.append(DtypeClass('uint16'))
+ elif token.v.strip(' ') == 'uint32':
+ stack.append(DtypeClass('uint32'))
+ elif token.v.strip(' ') == 'uint64':
+ stack.append(DtypeClass('uint'))
elif token.v.strip(' ') == 'float':
stack.append(DtypeClass('float'))
elif token.v.strip(' ') == 'float32':
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
@@ -8,6 +8,7 @@
from rpython.jit.metainterp.warmspot import reset_jit, get_stats
from rpython.jit.metainterp.jitprof import Profiler
from rpython.rlib.jit import Counters
+from rpython.rlib.rarithmetic import intmask
from pypy.module.micronumpy import boxes
from pypy.module.micronumpy.compile import FakeSpace, Parser, InterpreterState
from pypy.module.micronumpy.base import W_NDimArray
@@ -72,6 +73,16 @@
return float(int(w_res.value))
elif isinstance(w_res, boxes.W_Int16Box):
return float(int(w_res.value))
+ elif isinstance(w_res, boxes.W_Int8Box):
+ return float(int(w_res.value))
+ elif isinstance(w_res, boxes.W_UInt64Box):
+ return float(intmask(w_res.value))
+ elif isinstance(w_res, boxes.W_UInt32Box):
+ return float(intmask(w_res.value))
+ elif isinstance(w_res, boxes.W_UInt16Box):
+ return float(intmask(w_res.value))
+ elif isinstance(w_res, boxes.W_UInt8Box):
+ return float(intmask(w_res.value))
elif isinstance(w_res, boxes.W_LongBox):
return float(w_res.value)
elif isinstance(w_res, boxes.W_BoolBox):
@@ -337,12 +348,40 @@
a = |30|
sum(a,int16)
"""
-
def test_sum_float_to_int16(self):
result = self.run("sum_float_to_int16")
assert result == sum(range(30))
+ self.check_vectorized(1, 0)
+ def define_sum_float_to_int32():
+ return """
+ a = |30|
+ sum(a,int32)
+ """
+ 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 """
+ a = |30|
+ sum(a,float32)
+ """
+ def test_sum_float_to_float32(self):
+ result = self.run("sum_float_to_float32")
+ assert result == sum(range(30))
+ self.check_vectorized(1, 1)
+
+ def define_sum_float_to_uint64():
+ return """
+ a = |30|
+ sum(a,uint64)
+ """
+ def test_sum_float_to_uint64(self):
+ result = self.run("sum_float_to_uint64")
+ assert result == sum(range(30))
+ self.check_vectorized(1, 0) # unsigned
+
def define_cumsum():
return """
a = |30|
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_costmodel.py
b/rpython/jit/metainterp/optimizeopt/test/test_costmodel.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_costmodel.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_costmodel.py
@@ -131,26 +131,27 @@
savings = self.savings(loop1)
assert savings == 2
- def test_sum_float_to_int16(self):
+ @py.test.mark.parametrize("bytes,s", [(1,-1),(2,-1),(4,0),(8,-1)])
+ def test_sum_float_to_int(self, bytes, s):
loop1 = self.parse("""
f10 = raw_load(p0, i0, descr=double)
f11 = raw_load(p0, i1, descr=double)
i10 = cast_float_to_int(f10)
i11 = cast_float_to_int(f11)
- i12 = int_signext(i10, 2)
- i13 = int_signext(i11, 2)
+ i12 = int_signext(i10, {c})
+ i13 = int_signext(i11, {c})
i14 = int_add(i1, i12)
- i16 = int_signext(i14, 2)
+ i16 = int_signext(i14, {c})
i15 = int_add(i16, i13)
- i17 = int_signext(i15, 2)
- """)
+ i17 = int_signext(i15, {c})
+ """.format(c=bytes))
savings = self.savings(loop1)
# it does not benefit because signext has
# a very inefficient implementation (x86
# does not provide nice instr to convert
# integer sizes)
# signext -> no benefit, + 2x unpack
- assert savings < 0
+ assert savings <= s
class Test(CostModelBaseTest, LLtypeMixin):
pass
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit