Author: Richard Plangger <planri...@gmail.com> Branch: ppc-vsx-support Changeset: r87040:15528006be4d Date: 2016-09-12 14:57 +0200 http://bitbucket.org/pypy/pypy/changeset/15528006be4d/
Log: renamed costmodel class to generic one (it is used also for ppc, not only for x86) diff --git a/rpython/jit/metainterp/optimizeopt/guard.py b/rpython/jit/metainterp/optimizeopt/guard.py --- a/rpython/jit/metainterp/optimizeopt/guard.py +++ b/rpython/jit/metainterp/optimizeopt/guard.py @@ -268,6 +268,7 @@ if user_code: self.eliminate_array_bound_checks(info, loop) + def emit_operation(self, op): self.renamer.rename(op) self._newoperations.append(op) 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 @@ -58,11 +58,13 @@ del needs_resolving[op] if op in indexvars: indexvar = indexvars[op] + last = None for operation in indexvar.get_operations(): self.append_to_oplist(operation) last = operation - indexvars[last] = indexvar - self.renamer.start_renaming(op, last) + if last: + indexvars[last] = indexvar + self.renamer.start_renaming(op, last) else: self.resolve_delayed(needs_resolving, delayed, op) self.append_to_oplist(op) 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 @@ -2,7 +2,7 @@ from rpython.jit.metainterp.history import TargetToken, JitCellToken, TreeLoop from rpython.jit.metainterp.optimizeopt.util import equaloplists -from rpython.jit.metainterp.optimizeopt.vector import (Pack, X86_CostModel, +from rpython.jit.metainterp.optimizeopt.vector import (Pack, GenericCostModel, NotAProfitableLoop, VectorizingOptimizer, CostModel) from rpython.jit.metainterp.optimizeopt.schedule import VecScheduleState from rpython.jit.metainterp.optimizeopt.dependency import Node, DependencyGraph @@ -101,7 +101,7 @@ print "pack: \n ", print '\n '.join([str(op.getoperation()) for op in pack.operations]) print - costmodel = FakeCostModel(X86_CostModel(self.cpu, 0)) + costmodel = FakeCostModel(GenericCostModel(self.cpu, 0)) costmodel.reset_savings() state = VecScheduleState(graph, opt.packset, self.cpu, costmodel) opt.schedule(state) 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 @@ -4,7 +4,7 @@ from rpython.jit.metainterp.optimizeopt.util import equaloplists from rpython.jit.metainterp.optimizeopt.renamer import Renamer from rpython.jit.metainterp.optimizeopt.vector import (VecScheduleState, - Pack, Pair, NotAProfitableLoop, VectorizingOptimizer, X86_CostModel, + Pack, Pair, NotAProfitableLoop, VectorizingOptimizer, GenericCostModel, PackSet) from rpython.jit.backend.llsupport.vector_ext import VectorExt from rpython.jit.metainterp.optimizeopt.dependency import Node, DependencyGraph @@ -43,7 +43,7 @@ def schedule(self, loop, packs, vec_reg_size=16, prepend_invariant=False, overwrite_funcs=None): - cm = X86_CostModel(self.cpu, 0) + cm = GenericCostModel(self.cpu, 0) cm.profitable = lambda: True pairs = [] for pack in packs: 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 @@ -13,7 +13,7 @@ from rpython.jit.metainterp.optimizeopt.dependency import DependencyGraph from rpython.jit.metainterp.optimizeopt.vector import (VectorizingOptimizer, MemoryRef, isomorphic, Pair, NotAVectorizeableLoop, VectorLoop, - NotAProfitableLoop, GuardStrengthenOpt, CostModel, X86_CostModel, + NotAProfitableLoop, GuardStrengthenOpt, CostModel, GenericCostModel, PackSet, optimize_vector) from rpython.jit.metainterp.optimizeopt.schedule import (Scheduler, SchedulerState, VecScheduleState, Pack) @@ -174,6 +174,14 @@ if with_guard_opt: gso = GuardStrengthenOpt(graph.index_vars) gso.propagate_all_forward(info, loop) + # re-schedule + #vsize = self.cpu.vector_ext.vec_size() + #graph = DependencyGraph(loop) + #state = VecScheduleState(graph, PackSet(vsize), self.cpu, costmodel) + #state.prepare() + #scheduler = Scheduler() + #scheduler.walk_and_emit(state) + #state.post_schedule() return opt def vectorize(self, loop, unroll_factor = -1): @@ -183,13 +191,23 @@ opt.find_adjacent_memory_refs(graph) opt.extend_packset() opt.combine_packset() - costmodel = X86_CostModel(self.cpu, 0) + costmodel = GenericCostModel(self.cpu, 0) state = VecScheduleState(graph, opt.packset, self.cpu, costmodel) opt.schedule(state) if not costmodel.profitable(): raise NotAProfitableLoop() gso = GuardStrengthenOpt(graph.index_vars) gso.propagate_all_forward(info, loop) + # + # re-schedule + #vsize = self.cpu.vector_ext.vec_size() + #graph = DependencyGraph(loop) + #state = VecScheduleState(graph, PackSet(vsize), self.cpu, costmodel) + #state.prepare() + #scheduler = Scheduler() + #scheduler.walk_and_emit(state) + #state.post_schedule() + # oplist = loop.operations loop.operations = loop.prefix[:] if loop.prefix_label: 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 @@ -133,9 +133,7 @@ # start = time.clock() opt = VectorizingOptimizer(metainterp_sd, jitdriver_sd, warmstate.vec_cost) - index_vars = opt.run_optimization(metainterp_sd, info, loop) - gso = GuardStrengthenOpt(index_vars) - gso.propagate_all_forward(info, loop, user_code) + opt.run_optimization(metainterp_sd, info, loop) end = time.clock() # metainterp_sd.profiler.count(Counters.OPT_VECTORIZED) @@ -254,13 +252,23 @@ self.find_adjacent_memory_refs(graph) self.extend_packset() self.combine_packset() - # TODO move cost model to CPU - costmodel = X86_CostModel(self.cpu, self.cost_threshold) + costmodel = GenericCostModel(self.cpu, self.cost_threshold) state = VecScheduleState(graph, self.packset, self.cpu, costmodel) self.schedule(state) if not state.profitable(): raise NotAProfitableLoop - return graph.index_vars + gso = GuardStrengthenOpt(graph.index_vars) + gso.propagate_all_forward(info, loop, user_code) + + # re-schedule the trace -> removes index operations + # work in progress + #graph = DependencyGraph(loop) + #costmodel = GenericCostModel(self.cpu, self.cost_threshold) + #state = VecScheduleState(graph, PackSet(vsize), self.cpu, costmodel) + #state.prepare() + #scheduler = Scheduler() + #scheduler.walk_and_emit(state) + #state.post_schedule() def unroll_loop_iterations(self, loop, unroll_count): """ Unroll the loop X times. unroll_count + 1 = unroll_factor """ @@ -600,7 +608,7 @@ def profitable(self): return self.savings >= 0 -class X86_CostModel(CostModel): +class GenericCostModel(CostModel): def record_pack_savings(self, pack, times): cost, benefit_factor = (1,1) node = pack.operations[0] _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit