Author: Richard Plangger <planri...@gmail.com> Branch: ppc-vsx-support Changeset: r85313:277106ec536b Date: 2016-06-21 18:29 +0200 http://bitbucket.org/pypy/pypy/changeset/277106ec536b/
Log: extend the integer vector test diff --git a/rpython/jit/backend/ppc/vector_ext.py b/rpython/jit/backend/ppc/vector_ext.py --- a/rpython/jit/backend/ppc/vector_ext.py +++ b/rpython/jit/backend/ppc/vector_ext.py @@ -178,6 +178,29 @@ elif itemsize == 8: self.mc.xvdivdp(resloc.value, loc0.value, loc1.value) + def emit_vec_int_mul(self, op, arglocs, resloc): + loc0, loc1, itemsize_loc = arglocs + itemsize = itemsize_loc.value + if itemsize == 1: + self.mc.PMULLW(loc0, loc1) + elif itemsize == 2: + self.mc.PMULLW(loc0, loc1) + elif itemsize == 4: + self.mc.PMULLD(loc0, loc1) + else: + # NOTE see http://stackoverflow.com/questions/8866973/can-long-integer-routines-benefit-from-sse/8867025#8867025 + # There is no 64x64 bit packed mul. For 8 bit either. It is questionable if it gives any benefit? + not_implemented("int8/64 mul") + + def emit_vec_int_and(self, op, arglocs, resloc): + self.mc.PAND(resloc, arglocs[0]) + + def emit_vec_int_or(self, op, arglocs, resloc): + self.mc.POR(resloc, arglocs[0]) + + def emit_vec_int_xor(self, op, arglocs, resloc): + self.mc.PXOR(resloc, arglocs[0]) + #def genop_guard_vec_guard_true(self, guard_op, guard_token, locs, resloc): # self.implement_guard(guard_token) @@ -293,47 +316,6 @@ # # entries before) become ones # self.mc.PCMPEQ(loc, temp, sizeloc.value) - #def genop_vec_int_mul(self, op, arglocs, resloc): - # loc0, loc1, itemsize_loc = arglocs - # itemsize = itemsize_loc.value - # if itemsize == 2: - # self.mc.PMULLW(loc0, loc1) - # elif itemsize == 4: - # self.mc.PMULLD(loc0, loc1) - # else: - # # NOTE see http://stackoverflow.com/questions/8866973/can-long-integer-routines-benefit-from-sse/8867025#8867025 - # # There is no 64x64 bit packed mul. For 8 bit either. It is questionable if it gives any benefit? - # not_implemented("int8/64 mul") - - #def genop_vec_int_sub(self, op, arglocs, resloc): - # loc0, loc1, size_loc = arglocs - # size = size_loc.value - # if size == 1: - # self.mc.PSUBB(loc0, loc1) - # elif size == 2: - # self.mc.PSUBW(loc0, loc1) - # elif size == 4: - # self.mc.PSUBD(loc0, loc1) - # elif size == 8: - # self.mc.PSUBQ(loc0, loc1) - - #def genop_vec_int_and(self, op, arglocs, resloc): - # self.mc.PAND(resloc, arglocs[0]) - - #def genop_vec_int_or(self, op, arglocs, resloc): - # self.mc.POR(resloc, arglocs[0]) - - #def genop_vec_int_xor(self, op, arglocs, resloc): - # self.mc.PXOR(resloc, arglocs[0]) - - #def genop_vec_float_truediv(self, op, arglocs, resloc): - # loc0, loc1, sizeloc = arglocs - # size = sizeloc.value - # if size == 4: - # self.mc.DIVPS(loc0, loc1) - # elif size == 8: - # self.mc.DIVPD(loc0, loc1) - #def genop_vec_float_abs(self, op, arglocs, resloc): # src, sizeloc = arglocs # size = sizeloc.value @@ -648,12 +630,17 @@ return [resloc, loc0, loc1, imm(size)] prepare_vec_int_add = prepare_vec_arith - #prepare_vec_int_sub = prepare_vec_arith - #prepare_vec_int_mul = prepare_vec_arith + prepare_vec_int_sub = prepare_vec_arith + prepare_vec_int_mul = prepare_vec_arith prepare_vec_float_add = prepare_vec_arith prepare_vec_float_sub = prepare_vec_arith prepare_vec_float_mul = prepare_vec_arith prepare_vec_float_truediv = prepare_vec_arith + + # logic functions + prepare_vec_int_and = prepare_vec_arith + prepare_vec_int_or = prepare_vec_arith + prepare_vec_int_xor = prepare_vec_arith del prepare_vec_arith def _prepare_vec_store(self, op): @@ -691,13 +678,6 @@ #prepare_vec_float_abs = prepare_vec_arith_unary #del prepare_vec_arith_unary - #def prepare_vec_logic(self, op): - # lhs = op.getarg(0) - # assert isinstance(lhs, VectorOp) - # args = op.getarglist() - # source = self.make_sure_var_in_reg(op.getarg(1), args) - # result = self.xrm.force_result_in_reg(op, op.getarg(0), args) - # self.perform(op, [source, imm(lhs.bytesize)], result) #def prepare_vec_float_eq(self, op): # assert isinstance(op, VectorOp) @@ -712,11 +692,6 @@ #prepare_vec_int_eq = prepare_vec_float_eq #prepare_vec_int_ne = prepare_vec_float_eq - #prepare_vec_int_and = prepare_vec_logic - #prepare_vec_int_or = prepare_vec_logic - #prepare_vec_int_xor = prepare_vec_logic - #del prepare_vec_logic - #def prepare_vec_pack_i(self, op): # # new_res = vec_pack_i(res, src, index, count) # assert isinstance(op, VectorOp) 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 @@ -52,10 +52,11 @@ array = self.arrays.pop() free_raw_storage(array) -@pytest.fixture(scope='session') +@pytest.fixture(scope='function') def rawstorage(request): rs = RawStorage() request.addfinalizer(rs.clear) + request.cls.a return rs integers_64bit = st.integers(min_value=-2**63, max_value=2**63-1) @@ -70,7 +71,7 @@ return rfloat.NAN return rfloat.copysign(rfloat.INFINITY, v1 * v2) -class VectorizeTests: +class VectorizeTests(object): enable_opts = 'intbounds:rewrite:virtualize:string:earlyforce:pure:heap:unroll' def setup_method(self, method): @@ -126,10 +127,20 @@ rawstorage.clear() #@given(st.data()) - def test_vector_simple_int(self): + @pytest.mark.parametrize('func,type', [ + (lambda a,b: intmask(a+b), rffi.SIGNED), + (lambda a,b: intmask(a+b), rffi.UNSIGNED), + (lambda a,b: intmask(a+b), rffi.INT), + (lambda a,b: intmask(a+b), rffi.UINT), + (lambda a,b: intmask(a+b), rffi.SHORT), + (lambda a,b: intmask(a+b), rffi.USHORT), + (lambda a,b: intmask(a+b), rffi.CHAR), + (lambda a,b: intmask(a+b), rffi.UCHAR), + ]) + def test_vector_simple_int(self, func, type): + func = always_inline(func) - type = rffi.SIGNED - size = rffi.sizeof(rffi.SIGNED) + size = rffi.sizeof(type) myjitdriver = JitDriver(greens = [], reds = 'auto', vectorize=True) def f(bytecount, va, vb, vc): i = 0 @@ -137,25 +148,25 @@ myjitdriver.jit_merge_point() a = raw_storage_getitem(type,va,i) b = raw_storage_getitem(type,vb,i) - c = a+b + c = func(a,b) raw_storage_setitem(vc, i, rffi.cast(type,c)) i += size - rawstorage = RawStorage() #la = data.draw(st.lists(integers_64bit, min_size=10, max_size=150)) la = [1] * 10 l = len(la) #lb = data.draw(st.lists(integers_64bit, min_size=l, max_size=l)) lb = [0] * 10 - va = rawstorage.new(la, lltype.Signed) - vb = rawstorage.new(lb, lltype.Signed) - vc = rawstorage.new(None, lltype.Signed, size=l) + rawstorage = RawStorage() + va = rawstorage.new(la, type) + vb = rawstorage.new(lb, type) + vc = rawstorage.new(None, type, size=l) self.meta_interp(f, [l*size, va, vb, vc]) for i in range(l): c = raw_storage_getitem(type,vc,i*size) - assert intmask(la[i] + lb[i]) == c + assert func(la[i], lb[i]) == c rawstorage.clear() _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit