def schedule(self, loop, packs, vec_reg_size=16, prepend_invariant=False, overwrite_funcs=None): cm = X86_CostModel(self.cpu, 0) cm.profitable = lambda: True pairs = [] for pack in packs: for i in range(len(pack.operations)-1): o1 = pack.operations[i] o2 = pack.operations[i+1] pair = Pair(o1,o2) pairs.append(pair) packset = FakePackSet(pairs) state = VecScheduleState(loop.graph, packset, self.cpu, cm) for name, overwrite in (overwrite_funcs or {}).items(): setattr(state, name, overwrite) renamer = Renamer() metainterp_sd = FakeMetaInterpStaticData(self.cpu) jitdriver_sd = FakeJitDriverStaticData() opt = VectorizingOptimizer(metainterp_sd, jitdriver_sd, 0) opt.packset = packset opt.combine_packset() opt.schedule(state) # works for now. might be the wrong class? # wrap label + operations + jump it in tree loop otherwise loop = state.graph.loop if prepend_invariant: loop.operations = loop.prefix + loop.operations return loop
def schedule(self, loop, packs, vec_reg_size=16, prepend_invariant=False, overwrite_funcs=None): cm = GenericCostModel(self.cpu, 0) cm.profitable = lambda: True pairs = [] for pack in packs: for i in range(len(pack.operations) - 1): o1 = pack.operations[i] o2 = pack.operations[i + 1] pair = Pair(o1, o2) pairs.append(pair) packset = FakePackSet(pairs) state = VecScheduleState(loop.graph, packset, self.cpu, cm) for name, overwrite in (overwrite_funcs or {}).items(): setattr(state, name, overwrite) renamer = Renamer() metainterp_sd = FakeMetaInterpStaticData(self.cpu) jitdriver_sd = FakeJitDriverStaticData() opt = VectorizingOptimizer(metainterp_sd, jitdriver_sd, 0) opt.packset = packset opt.combine_packset() opt.schedule(state) # works for now. might be the wrong class? # wrap label + operations + jump it in tree loop otherwise loop = state.graph.loop if prepend_invariant: loop.operations = loop.prefix + loop.operations return loop
def savings(self, loop): metainterp_sd = FakeMetaInterpStaticData(self.cpu) jitdriver_sd = FakeJitDriverStaticData() opt = VectorizingOptimizer(metainterp_sd, jitdriver_sd, 0) opt.orig_label_args = loop.label.getarglist()[:] graph = opt.dependency_graph = DependencyGraph(loop) self.show_dot_graph(graph, 'costmodel') for k,m in graph.memory_refs.items(): graph.memory_refs[k] = FakeMemoryRef(m.array, m.index_var) opt.find_adjacent_memory_refs(graph) opt.extend_packset() opt.combine_packset() for pack in opt.packset.packs: print "pack: \n ", print '\n '.join([str(op.getoperation()) for op in pack.operations]) print costmodel = FakeCostModel(X86_CostModel(self.cpu, 0)) costmodel.reset_savings() state = VecScheduleState(graph, opt.packset, self.cpu, costmodel) opt.schedule(state) return costmodel.getsavings()
def savings(self, loop): jitdriver_sd = FakeJitDriverStaticData() opt = VectorizingOptimizer(self.metainterp_sd, jitdriver_sd, 0) opt.orig_label_args = loop.label.getarglist()[:] graph = opt.dependency_graph = DependencyGraph(loop) self.show_dot_graph(graph, 'costmodel') for k, m in graph.memory_refs.items(): graph.memory_refs[k] = FakeMemoryRef(m.array, m.index_var) opt.find_adjacent_memory_refs(graph) opt.extend_packset() opt.combine_packset() for pack in opt.packset.packs: print "pack: \n ", print '\n '.join( [str(op.getoperation()) for op in pack.operations]) print costmodel = FakeCostModel(GenericCostModel(self.cpu, 0)) costmodel.reset_savings() state = VecScheduleState(graph, opt.packset, self.cpu, costmodel) opt.schedule(state) return costmodel.getsavings()