|
1 | | -from __future__ import print_function, division, absolute_import |
2 | | - |
3 | | -from numba.compiler_machinery import PassManager |
4 | | - |
5 | | -from numba.untyped_passes import (ExtractByteCode, TranslateByteCode, FixupArgs, |
6 | | - IRProcessing, DeadBranchPrune, |
7 | | - RewriteSemanticConstants, InlineClosureLikes, |
8 | | - GenericRewrites, WithLifting, |
9 | | - InlineInlinables, FindLiterallyCalls, |
10 | | - MakeFunctionToJitFunction, |
11 | | - CanonicalizeLoopExit, CanonicalizeLoopEntry, |
12 | | - LiteralUnroll) |
13 | | - |
14 | | -from numba.typed_passes import (NopythonTypeInference, AnnotateTypes, |
15 | | - NopythonRewrites, PreParforPass, ParforPass, |
16 | | - DumpParforDiagnostics, IRLegalization, |
17 | | - InlineOverloads) |
18 | | - |
19 | | -from .dppy_passes import ( |
20 | | - DPPyPreParforPass, |
21 | | - DPPyParforPass, |
22 | | - SpirvFriendlyLowering, |
23 | | - DPPyNoPythonBackend |
24 | | - ) |
25 | | - |
26 | | -class DPPyPassBuilder(object): |
27 | | - """ |
28 | | - This is the DPPy pass builder to run Intel GPU/CPU specific |
29 | | - code-generation and optimization passes. This pass builder does |
30 | | - not offer objectmode and interpreted passes. |
31 | | - """ |
32 | | - |
33 | | - @staticmethod |
34 | | - def default_numba_nopython_pipeline(state, pm): |
35 | | - """Adds the default set of NUMBA passes to the pass manager |
36 | | - """ |
37 | | - if state.func_ir is None: |
38 | | - pm.add_pass(TranslateByteCode, "analyzing bytecode") |
39 | | - pm.add_pass(FixupArgs, "fix up args") |
40 | | - pm.add_pass(IRProcessing, "processing IR") |
41 | | - pm.add_pass(WithLifting, "Handle with contexts") |
42 | | - |
43 | | - # pre typing |
44 | | - if not state.flags.no_rewrites: |
45 | | - pm.add_pass(RewriteSemanticConstants, "rewrite semantic constants") |
46 | | - pm.add_pass(DeadBranchPrune, "dead branch pruning") |
47 | | - pm.add_pass(GenericRewrites, "nopython rewrites") |
48 | | - |
49 | | - pm.add_pass(InlineClosureLikes, |
50 | | - "inline calls to locally defined closures") |
51 | | - # convert any remaining closures into functions |
52 | | - pm.add_pass(MakeFunctionToJitFunction, |
53 | | - "convert make_function into JIT functions") |
54 | | - # inline functions that have been determined as inlinable and rerun |
55 | | - # branch pruning, this needs to be run after closures are inlined as |
56 | | - # the IR repr of a closure masks call sites if an inlinable is called |
57 | | - # inside a closure |
58 | | - pm.add_pass(InlineInlinables, "inline inlinable functions") |
59 | | - if not state.flags.no_rewrites: |
60 | | - pm.add_pass(DeadBranchPrune, "dead branch pruning") |
61 | | - |
62 | | - pm.add_pass(FindLiterallyCalls, "find literally calls") |
63 | | - pm.add_pass(LiteralUnroll, "handles literal_unroll") |
64 | | - |
65 | | - # typing |
66 | | - pm.add_pass(NopythonTypeInference, "nopython frontend") |
67 | | - pm.add_pass(AnnotateTypes, "annotate types") |
68 | | - |
69 | | - # optimisation |
70 | | - pm.add_pass(InlineOverloads, "inline overloaded functions") |
71 | | - |
72 | | - # legalise |
73 | | - pm.add_pass(IRLegalization, "ensure IR is legal prior to lowering") |
74 | | - |
75 | | - |
76 | | - @staticmethod |
77 | | - def define_nopython_pipeline(state, name='dppy_nopython'): |
78 | | - """Returns an nopython mode pipeline based PassManager |
79 | | - """ |
80 | | - pm = PassManager(name) |
81 | | - DPPyPassBuilder.default_numba_nopython_pipeline(state, pm) |
82 | | - |
83 | | - # Intel GPU/CPU specific optimizations |
84 | | - pm.add_pass(DPPyPreParforPass, "Preprocessing for parfors") |
85 | | - if not state.flags.no_rewrites: |
86 | | - pm.add_pass(NopythonRewrites, "nopython rewrites") |
87 | | - pm.add_pass(DPPyParforPass, "convert to parfors") |
88 | | - #pm.add_pass(InlineParforVectorize, "inline vectorize inside parfors ") |
89 | | - |
90 | | - # lower |
91 | | - pm.add_pass(SpirvFriendlyLowering, "SPIRV-friendly lowering pass") |
92 | | - pm.add_pass(DPPyNoPythonBackend, "nopython mode backend") |
93 | | - pm.finalize() |
94 | | - return pm |
| 1 | +from __future__ import print_function, division, absolute_import |
| 2 | + |
| 3 | +from numba.compiler_machinery import PassManager |
| 4 | + |
| 5 | +from numba.untyped_passes import (ExtractByteCode, TranslateByteCode, FixupArgs, |
| 6 | + IRProcessing, DeadBranchPrune, |
| 7 | + RewriteSemanticConstants, InlineClosureLikes, |
| 8 | + GenericRewrites, WithLifting, |
| 9 | + InlineInlinables, FindLiterallyCalls, |
| 10 | + MakeFunctionToJitFunction, |
| 11 | + CanonicalizeLoopExit, CanonicalizeLoopEntry, |
| 12 | + LiteralUnroll) |
| 13 | + |
| 14 | +from numba.typed_passes import (NopythonTypeInference, AnnotateTypes, |
| 15 | + NopythonRewrites, PreParforPass, ParforPass, |
| 16 | + DumpParforDiagnostics, IRLegalization, |
| 17 | + InlineOverloads) |
| 18 | + |
| 19 | +from .dppy_passes import ( |
| 20 | + DPPyPreParforPass, |
| 21 | + DPPyParforPass, |
| 22 | + SpirvFriendlyLowering, |
| 23 | + DPPyNoPythonBackend |
| 24 | + ) |
| 25 | + |
| 26 | +class DPPyPassBuilder(object): |
| 27 | + """ |
| 28 | + This is the DPPy pass builder to run Intel GPU/CPU specific |
| 29 | + code-generation and optimization passes. This pass builder does |
| 30 | + not offer objectmode and interpreted passes. |
| 31 | + """ |
| 32 | + |
| 33 | + @staticmethod |
| 34 | + def default_numba_nopython_pipeline(state, pm): |
| 35 | + """Adds the default set of NUMBA passes to the pass manager |
| 36 | + """ |
| 37 | + if state.func_ir is None: |
| 38 | + pm.add_pass(TranslateByteCode, "analyzing bytecode") |
| 39 | + pm.add_pass(FixupArgs, "fix up args") |
| 40 | + pm.add_pass(IRProcessing, "processing IR") |
| 41 | + pm.add_pass(WithLifting, "Handle with contexts") |
| 42 | + |
| 43 | + # pre typing |
| 44 | + if not state.flags.no_rewrites: |
| 45 | + pm.add_pass(RewriteSemanticConstants, "rewrite semantic constants") |
| 46 | + pm.add_pass(DeadBranchPrune, "dead branch pruning") |
| 47 | + pm.add_pass(GenericRewrites, "nopython rewrites") |
| 48 | + |
| 49 | + pm.add_pass(InlineClosureLikes, |
| 50 | + "inline calls to locally defined closures") |
| 51 | + # convert any remaining closures into functions |
| 52 | + pm.add_pass(MakeFunctionToJitFunction, |
| 53 | + "convert make_function into JIT functions") |
| 54 | + # inline functions that have been determined as inlinable and rerun |
| 55 | + # branch pruning, this needs to be run after closures are inlined as |
| 56 | + # the IR repr of a closure masks call sites if an inlinable is called |
| 57 | + # inside a closure |
| 58 | + pm.add_pass(InlineInlinables, "inline inlinable functions") |
| 59 | + if not state.flags.no_rewrites: |
| 60 | + pm.add_pass(DeadBranchPrune, "dead branch pruning") |
| 61 | + |
| 62 | + pm.add_pass(FindLiterallyCalls, "find literally calls") |
| 63 | + pm.add_pass(LiteralUnroll, "handles literal_unroll") |
| 64 | + |
| 65 | + # typing |
| 66 | + pm.add_pass(NopythonTypeInference, "nopython frontend") |
| 67 | + pm.add_pass(AnnotateTypes, "annotate types") |
| 68 | + |
| 69 | + # optimisation |
| 70 | + pm.add_pass(InlineOverloads, "inline overloaded functions") |
| 71 | + |
| 72 | + # legalise |
| 73 | + pm.add_pass(IRLegalization, "ensure IR is legal prior to lowering") |
| 74 | + |
| 75 | + |
| 76 | + @staticmethod |
| 77 | + def define_nopython_pipeline(state, name='dppy_nopython'): |
| 78 | + """Returns an nopython mode pipeline based PassManager |
| 79 | + """ |
| 80 | + pm = PassManager(name) |
| 81 | + DPPyPassBuilder.default_numba_nopython_pipeline(state, pm) |
| 82 | + |
| 83 | + # Intel GPU/CPU specific optimizations |
| 84 | + pm.add_pass(DPPyPreParforPass, "Preprocessing for parfors") |
| 85 | + if not state.flags.no_rewrites: |
| 86 | + pm.add_pass(NopythonRewrites, "nopython rewrites") |
| 87 | + pm.add_pass(DPPyParforPass, "convert to parfors") |
| 88 | + #pm.add_pass(InlineParforVectorize, "inline vectorize inside parfors ") |
| 89 | + |
| 90 | + # lower |
| 91 | + pm.add_pass(SpirvFriendlyLowering, "SPIRV-friendly lowering pass") |
| 92 | + pm.add_pass(DPPyNoPythonBackend, "nopython mode backend") |
| 93 | + pm.finalize() |
| 94 | + return pm |
0 commit comments