Author: Richard Plangger <planri...@gmail.com> Branch: ppc-vsx-support Changeset: r85595:b129dbdbe458 Date: 2016-07-07 10:22 +0200 http://bitbucket.org/pypy/pypy/changeset/b129dbdbe458/
Log: continue refactoring started in last commit 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 @@ -2,6 +2,7 @@ from rpython.jit.backend import model from rpython.jit.backend.llgraph import support from rpython.jit.backend.llsupport import symbolic +from rpython.jit.backend.llsupport.vector_ext import VectorExt from rpython.jit.metainterp.history import AbstractDescr from rpython.jit.metainterp.history import Const, getkind from rpython.jit.metainterp.history import INT, REF, FLOAT, VOID @@ -931,7 +932,7 @@ def build_getarrayitem(func): def method(self, struct, offset, descr, _count): values = [] - count = self.vector_register_size // descr.get_item_size_in_bytes() + count = self.vector_ext.vec_size() // descr.get_item_size_in_bytes() assert _count == count assert count > 0 for i in range(count): @@ -949,7 +950,7 @@ def _bh_vec_raw_load(self, struct, offset, descr, _count): values = [] stride = descr.get_item_size_in_bytes() - count = self.vector_register_size // descr.get_item_size_in_bytes() + count = self.vector_ext.vec_size() // descr.get_item_size_in_bytes() assert _count == count assert count > 0 for i in range(count): diff --git a/rpython/jit/backend/x86/runner.py b/rpython/jit/backend/x86/runner.py --- a/rpython/jit/backend/x86/runner.py +++ b/rpython/jit/backend/x86/runner.py @@ -63,6 +63,10 @@ if self.HAS_CODEMAP: self.codemap.setup() self.assembler.setup_once() + if self.vector_ext: + # TODO + pass + #self.vector_ext. @rgc.no_release_gil def finish_once(self): @@ -149,8 +153,9 @@ HAS_CODEMAP = True class CPU_X86_64_SSE4(CPU_X86_64): - vector_extension = True - vector_register_size = 16 - vector_horizontal_operations = True + vector_ext = X86VectorExt() + #vector_extension = True + #vector_register_size = 16 + #vector_horizontal_operations = True CPU = CPU386 diff --git a/rpython/jit/metainterp/optimizeopt/schedule.py b/rpython/jit/metainterp/optimizeopt/schedule.py --- a/rpython/jit/metainterp/optimizeopt/schedule.py +++ b/rpython/jit/metainterp/optimizeopt/schedule.py @@ -473,7 +473,7 @@ def __init__(self, graph, packset, cpu, costmodel): SchedulerState.__init__(self, cpu, graph) self.box_to_vbox = {} - self.vec_reg_size = cpu.vector_register_size + self.vec_reg_size = cpu.vector_ext.vec_size() self.expanded_map = {} self.costmodel = costmodel self.inputargs = {} 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 @@ -13,11 +13,6 @@ from rpython.jit.metainterp.resoperation import rop, ResOperation, AbstractValue from rpython.jit.tool.oparser import parse as opparse from rpython.jit.tool.oparser_model import get_model -from rpython.jit.backend.detect_cpu import getcpuclass - -CPU = getcpuclass() -if not CPU.vector_extension: - py.test.skip("this cpu %s has no implemented vector backend" % CPU) class FakeMemoryRef(object): def __init__(self, array, iv): diff --git a/rpython/jit/metainterp/optimizeopt/test/test_dependency.py b/rpython/jit/metainterp/optimizeopt/test/test_dependency.py --- a/rpython/jit/metainterp/optimizeopt/test/test_dependency.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_dependency.py @@ -35,6 +35,8 @@ def setup_method(self, method): self.test_name = method.__name__ + if not self.cpu.vector_ext.is_enabled(): + py.test.skip("cpu %s needs to implement the vector backend" % self.cpu) def build_dependency(self, ops): loop = self.parse_loop(ops) 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 @@ -15,11 +15,6 @@ from rpython.jit.metainterp.resoperation import rop, ResOperation, VectorizationInfo from rpython.jit.tool.oparser import parse as opparse from rpython.jit.tool.oparser_model import get_model -from rpython.jit.backend.detect_cpu import getcpuclass - -CPU = getcpuclass() -if not CPU.vector_extension: - py.test.skip("this cpu %s has no implemented vector backend" % CPU) class FakeVecScheduleState(VecScheduleState): def __init__(self): diff --git a/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py b/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py --- a/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py @@ -28,8 +28,6 @@ from rpython.jit.backend.detect_cpu import getcpuclass CPU = getcpuclass() -if not CPU.vector_extension: - py.test.skip("this cpu %s has no implemented vector backend" % CPU) class FakeJitDriverStaticData(object): vec=True @@ -111,7 +109,7 @@ def earlyexit(self, loop): opt = self.vectoroptimizer(loop) graph = opt.analyse_index_calculations(loop) - state = SchedulerState(graph) + state = SchedulerState(self.cpu, graph) opt.schedule(state) return graph.loop @@ -133,7 +131,7 @@ print "CYCLE found %s" % cycle self.show_dot_graph(graph, "early_exit_" + self.test_name) assert cycle is None - state = SchedulerState(graph) + state = SchedulerState(self.cpu, graph) opt.schedule(state) opt.unroll_loop_iterations(loop, unroll_factor) self.debug_print_operations(loop) @@ -269,11 +267,11 @@ pack = Pack([Node(ResOperation(rop.RAW_STORE, [0,0,arg('f',4)], descr), 0), Node(ResOperation(rop.RAW_STORE, [0,0,arg('f',4)], descr), 0), ]) - assert pack.opcount_filling_vector_register(16) == 2 + assert pack.opcount_filling_vector_register(16, self.cpu.vector_ext) == 2 def test_opcount_filling_guard(self): descr = ArrayDescr(0,4, None, 'S') - vec = ResOperation(rop.VEC_RAW_LOAD_I, ['a','i'], descr=descr) + vec = ResOperation(rop.VEC_LOAD_I, ['a','i'], descr=descr) vec.count = 4 pack = Pack([Node(ResOperation(rop.GUARD_TRUE, [vec]), 0), Node(ResOperation(rop.GUARD_TRUE, [vec]), 1), @@ -285,12 +283,13 @@ assert pack.pack_load(16) == 24-16 assert pack.pack_load(8) == 24-8 assert pack.pack_load(32) == 24-32 - assert pack.opcount_filling_vector_register(16) == 4 - ops, newops = pack.slice_operations(16) + ext = self.cpu.vector_ext + assert pack.opcount_filling_vector_register(16, ext) == 4 + ops, newops = pack.slice_operations(16, ext) assert len(ops) == 4 assert len(newops) == 2 - assert pack.opcount_filling_vector_register(8) == 2 - ops, newops = pack.slice_operations(8) + assert pack.opcount_filling_vector_register(8, ext) == 2 + ops, newops = pack.slice_operations(8, ext) assert len(ops) == 2 assert len(newops) == 4 @@ -1044,10 +1043,10 @@ i18 = int_lt(i13, i1) guard_true(i18) [i11,i1,i2,i3,i4] i14 = int_mul(i11, 8) - v19[2xi64] = vec_raw_load_i(i2, i6, descr=arraydescr) - v20[2xi64] = vec_raw_load_i(i3, i6, descr=arraydescr) + v19[2xi64] = vec_load_i(i2, i6, descr=arraydescr) + v20[2xi64] = vec_load_i(i3, i6, descr=arraydescr) v21[2xi64] = vec_int_add(v19, v20) - vec_raw_store(i4, i6, v21, descr=arraydescr) + vec_store(i4, i6, v21, descr=arraydescr) jump(i13, i1, i2, i3, i4) """ loop = self.parse_loop(ops) @@ -1182,7 +1181,7 @@ guard_true(i2) [p0, i0, v2[2xf64]] i10 = int_add(i0, 16) i20 = int_lt(i10, 100) - v1[2xf64] = vec_raw_load_f(p0, i0, descr=floatarraydescr) + v1[2xf64] = vec_load_f(p0, i0, descr=floatarraydescr) v3[2xf64] = vec_float_add(v2[2xf64], v1[2xf64]) jump(p0, i1, v3[2xf64]) """ @@ -1222,10 +1221,10 @@ i55 = int_add(i44, 16) i629 = int_add(i41, 16) i637 = int_add(i37, 16) - v61[2xf64] = vec_raw_load_f(i21, i44, descr=floatarraydescr) - v62[2xf64] = vec_raw_load_f(i4, i41, descr=floatarraydescr) + v61[2xf64] = vec_load_f(i21, i44, descr=floatarraydescr) + v62[2xf64] = vec_load_f(i4, i41, descr=floatarraydescr) v63[2xf64] = vec_float_add(v61, v62) - vec_raw_store(i0, i37, v63, descr=floatarraydescr) + vec_store(i0, i37, v63, descr=floatarraydescr) f100 = vec_unpack_f(v61, 1, 1) f101 = vec_unpack_f(v62, 1, 1) jump(p36, i637, p9, i56, p14, f100, p12, p38, f101, p39, i40, i54, p42, i43, i55, i21, i4, i0, i18) @@ -1302,11 +1301,11 @@ i400 = int_add(i4, 16) i401= int_lt(i400, 100) i402 = int_add(i0, 16) - v228[4xi32] = vec_raw_load_i(p0, i0, descr=float32arraydescr) + v228[4xi32] = vec_load_i(p0, i0, descr=float32arraydescr) v229[2xf64] = vec_cast_singlefloat_to_float(v228) v230 = vec_unpack_i(v228, 2, 2) v231 = vec_cast_singlefloat_to_float(v230) - v232 = vec_raw_load_i(p1, i189, descr=float32arraydescr) + v232 = vec_load_i(p1, i189, descr=float32arraydescr) v233 = vec_cast_singlefloat_to_float(v232) v236 = vec_float_add(v229, v233) v238 = vec_cast_float_to_singlefloat(v236) @@ -1315,7 +1314,7 @@ v237 = vec_float_add(v231, v235) v239 = vec_cast_float_to_singlefloat(v237) v240 = vec_pack_i(v238, v239, 2, 2) - vec_raw_store(p2, i4, v240, descr=float32arraydescr) + vec_store(p2, i4, v240, descr=float32arraydescr) jump(p0, p1, p2, i207, i500) """) vopt = self.vectorize(trace) @@ -1355,7 +1354,7 @@ """) vopt = self.schedule(trace) self.ensure_operations([ - 'v10[2xf64] = vec_raw_load_f(p0,i0,descr=floatarraydescr)', + 'v10[2xf64] = vec_load_f(p0,i0,descr=floatarraydescr)', 'v11[2xf64] = vec_float_mul(v10[2xf64], v9[2xf64])', 'v12[2xf64] = vec_float_eq(v11[2xf64], v11[2xf64])', 'i100 = vec_unpack_f(v12[4xi32], 0, 1)', diff --git a/rpython/jit/metainterp/optimizeopt/vector.py b/rpython/jit/metainterp/optimizeopt/vector.py --- a/rpython/jit/metainterp/optimizeopt/vector.py +++ b/rpython/jit/metainterp/optimizeopt/vector.py @@ -216,6 +216,7 @@ def __init__(self, metainterp_sd, jitdriver_sd, cost_threshold): Optimizer.__init__(self, metainterp_sd, jitdriver_sd) self.cpu = metainterp_sd.cpu + self.vector_ext = self.cpu.vector_ext self.cost_threshold = cost_threshold self.packset = None self.unroll_count = 0 @@ -226,7 +227,7 @@ self.orig_label_args = loop.label.getarglist_copy() self.linear_find_smallest_type(loop) byte_count = self.smallest_type_bytes - vsize = self.cpu.vector_register_size + vsize = self.vector_ext.vec_size() if vsize == 0 or byte_count == 0 or loop.label.getopnum() != rop.LABEL: # stop, there is no chance to vectorize this trace # we cannot optimize normal traces (if there is no label) @@ -345,7 +346,7 @@ loop = graph.loop operations = loop.operations - self.packset = PackSet(self.cpu.vector_register_size) + self.packset = PackSet(self.vector_ext.vec_size()) memory_refs = graph.memory_refs.items() # initialize the pack set for node_a,memref_a in memory_refs: @@ -558,7 +559,7 @@ """ def __init__(self, cpu, threshold): self.threshold = threshold - self.vec_reg_size = cpu.vector_register_size + self.vec_reg_size = cpu.vector_ext.vec_size() self.savings = 0 def reset_savings(self): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit