Skip to content

Commit 3060a61

Browse files
committed
(numba/dppy) Merged devel
2 parents c05dc4a + e71ad21 commit 3060a61

20 files changed

+144
-133
lines changed

CHANGE_LOG

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
NUMBA Version 0.48.0 + DPPY Version 0.3.0 (June 29, 2020)
2+
--------------------------------------------------------
3+
4+
This release includes:
5+
6+
* Caching of dppy.kernels which will improve performance.
7+
* Addition of support for Intel Advisor which will help in profiling applications.

codegen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from llvmlite import binding as ll
22
from llvmlite.llvmpy import core as lc
33

4-
from numba.targets.codegen import BaseCPUCodegen, CodeLibrary
5-
from numba import utils
4+
from numba.core.codegen import BaseCPUCodegen, CodeLibrary
5+
from numba.core import utils
66

77

88
SPIR_TRIPLE = {32: ' spir-unknown-unknown',

compiler.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33
from collections import namedtuple
44

55
from .dppy_passbuilder import DPPyPassBuilder
6-
from numba.typing.templates import ConcreteTemplate
7-
from numba import types, compiler, ir
8-
from numba.typing.templates import AbstractTemplate
9-
from numba import ctypes_support as ctypes
6+
from numba.core.typing.templates import ConcreteTemplate
7+
from numba.core import types, compiler, ir
8+
from numba.core.typing.templates import AbstractTemplate
9+
import ctypes
1010
from types import FunctionType
1111
from inspect import signature
1212

1313
import dppy.ocldrv as driver
1414
from . import spirv_generator
1515

1616
import os
17-
from numba.compiler import DefaultPassBuilder, CompilerBase
17+
from numba.core.compiler import DefaultPassBuilder, CompilerBase
1818

1919
DEBUG=os.environ.get('NUMBA_DPPY_DEBUG', None)
20-
_NUMBA_PVC_READ_ONLY = "read_only"
21-
_NUMBA_PVC_WRITE_ONLY = "write_only"
22-
_NUMBA_PVC_READ_WRITE = "read_write"
20+
_NUMBA_DPPY_READ_ONLY = "read_only"
21+
_NUMBA_DPPY_WRITE_ONLY = "write_only"
22+
_NUMBA_DPPY_READ_WRITE = "read_write"
2323

2424
def _raise_no_device_found_error():
2525
error_message = ("No OpenCL device specified. "
@@ -78,7 +78,7 @@ def compile_with_dppy(pyfunc, return_type, args, debug):
7878
# Do not compile (generate native code), just lower (to LLVM)
7979
flags.set('no_compile')
8080
flags.set('no_cpython_wrapper')
81-
#flags.set('nrt')
81+
flags.unset('nrt')
8282

8383
# Run compilation pipeline
8484
if isinstance(pyfunc, FunctionType):
@@ -279,9 +279,9 @@ def __init__(self):
279279

280280
# list of supported access types, stored in dict for fast lookup
281281
self.valid_access_types = {
282-
_NUMBA_PVC_READ_ONLY: _NUMBA_PVC_READ_ONLY,
283-
_NUMBA_PVC_WRITE_ONLY: _NUMBA_PVC_WRITE_ONLY,
284-
_NUMBA_PVC_READ_WRITE: _NUMBA_PVC_READ_WRITE}
282+
_NUMBA_DPPY_READ_ONLY: _NUMBA_DPPY_READ_ONLY,
283+
_NUMBA_DPPY_WRITE_ONLY: _NUMBA_DPPY_WRITE_ONLY,
284+
_NUMBA_DPPY_READ_WRITE: _NUMBA_DPPY_READ_WRITE}
285285

286286
def copy(self):
287287
return copy.copy(self)
@@ -372,7 +372,7 @@ def _pack_argument(self, ty, val, device_env, device_arr, access_type):
372372
"""
373373
if (device_arr and (access_type not in self.valid_access_types or
374374
access_type in self.valid_access_types and
375-
self.valid_access_types[access_type] != _NUMBA_PVC_READ_ONLY)):
375+
self.valid_access_types[access_type] != _NUMBA_DPPY_READ_ONLY)):
376376
# we get the date back to host if have created a
377377
# device_array or if access_type of this device_array
378378
# is not of type read_only and read_write
@@ -415,11 +415,11 @@ def _unpack_argument(self, ty, val, device_env, retr, kernelargs,
415415
dArr = None
416416

417417
if (default_behavior or
418-
self.valid_access_types[access_type] == _NUMBA_PVC_READ_ONLY or
419-
self.valid_access_types[access_type] == _NUMBA_PVC_READ_WRITE):
418+
self.valid_access_types[access_type] == _NUMBA_DPPY_READ_ONLY or
419+
self.valid_access_types[access_type] == _NUMBA_DPPY_READ_WRITE):
420420
# default, read_only and read_write case
421421
dArr = device_env.copy_array_to_device(val)
422-
elif self.valid_access_types[access_type] == _NUMBA_PVC_WRITE_ONLY:
422+
elif self.valid_access_types[access_type] == _NUMBA_DPPY_WRITE_ONLY:
423423
# write_only case, we do not copy the host data
424424
dArr = device_env.create_device_array(val)
425425

decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import print_function, absolute_import, division
2-
from numba import sigutils, types
2+
from numba.core import sigutils, types
33
from .compiler import (compile_kernel, JitDPPyKernel, compile_dppy_func_template,
44
compile_dppy_func, get_ordered_arg_access_types)
55

descriptor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from __future__ import print_function, division, absolute_import
2-
from numba.targets.descriptors import TargetDescriptor
3-
from numba.targets.options import TargetOptions
2+
from numba.core.descriptors import TargetDescriptor
3+
from numba.core.options import TargetOptions
44

5-
from .. import dispatcher, utils, typing
5+
from numba.core import dispatcher, utils, typing
66
from .target import DPPyTargetContext, DPPyTypingContext
77

8-
from numba.targets.cpu import CPUTargetOptions
8+
from numba.core.cpu import CPUTargetOptions
99

1010

1111
class DPPyTarget(TargetDescriptor):

dppy_host_fn_call_gen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import llvmlite.ir.values as liv
66
import llvmlite.ir as lir
77
import llvmlite.binding as lb
8-
from .. import types, cgutils
8+
from numba.core import types, cgutils
99

10-
from numba.ir_utils import legalize_names
10+
from numba.core.ir_utils import legalize_names
1111

1212
class DPPyHostFunctionCallsGenerator(object):
1313
def __init__(self, lowerer, cres, num_inputs):

dppy_lowerer.py

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,11 @@
99
import numpy as np
1010

1111
import numba
12-
from .. import (compiler,
13-
ir,
14-
types,
15-
six,
16-
sigutils,
17-
lowering,
18-
parfor,
19-
funcdesc)
20-
from numba.ir_utils import (add_offset_to_labels,
12+
from numba.core import (compiler, ir, types, sigutils, lowering,
13+
funcdesc, config)
14+
from numba.parfors import parfor
15+
from numba import dppy
16+
from numba.core.ir_utils import (add_offset_to_labels,
2117
replace_var_names,
2218
remove_dels,
2319
legalize_names,
@@ -35,14 +31,11 @@
3531
get_unused_var_name,
3632
find_potential_aliases,
3733
is_const_call)
38-
from ..typing import signature
39-
from numba import config, dppy
40-
from numba.targets.cpu import ParallelOptions
41-
from numba.six import exec_
42-
import operator
34+
35+
from numba.core.typing import signature
4336

4437
import warnings
45-
from ..errors import NumbaParallelSafetyWarning
38+
from numba.core.errors import NumbaParallelSafetyWarning
4639

4740
from .target import SPIR_GENERIC_ADDRSPACE
4841
from .dufunc_inliner import dufunc_inliner
@@ -289,12 +282,12 @@ def _create_gufunc_for_parfor_body(
289282
parfor_params.add(stop.name)
290283

291284
# Get just the outputs of the parfor.
292-
parfor_outputs = numba.parfor.get_parfor_outputs(parfor, parfor_params)
285+
parfor_outputs = numba.parfors.parfor.get_parfor_outputs(parfor, parfor_params)
293286

294287
# Get all parfor reduction vars, and operators.
295288
typemap = lowerer.fndesc.typemap
296289

297-
parfor_redvars, parfor_reddict = numba.parfor.get_parfor_reductions(
290+
parfor_redvars, parfor_reddict = numba.parfors.parfor.get_parfor_reductions(
298291
lowerer.func_ir,
299292
parfor,
300293
parfor_params,
@@ -453,7 +446,7 @@ def print_arg_with_addrspaces(args):
453446
# Force gufunc outline into existence.
454447
globls = {"np": np, "numba": numba, "dppy": dppy}
455448
locls = {}
456-
exec_(gufunc_txt, globls, locls)
449+
exec(gufunc_txt, globls, locls)
457450
gufunc_func = locls[gufunc_name]
458451

459452
if config.DEBUG_ARRAY_OPT:
@@ -679,7 +672,7 @@ def _lower_parfor_gufunc(lowerer, parfor):
679672

680673
alias_map = {}
681674
arg_aliases = {}
682-
numba.parfor.find_potential_aliases_parfor(parfor, parfor.params, typemap,
675+
numba.parfors.parfor.find_potential_aliases_parfor(parfor, parfor.params, typemap,
683676
lowerer.func_ir, alias_map, arg_aliases)
684677
if config.DEBUG_ARRAY_OPT:
685678
print("alias_map", alias_map)
@@ -690,7 +683,7 @@ def _lower_parfor_gufunc(lowerer, parfor):
690683
# dict will become invalid
691684
assert parfor.params != None
692685

693-
parfor_output_arrays = numba.parfor.get_parfor_outputs(
686+
parfor_output_arrays = numba.parfors.parfor.get_parfor_outputs(
694687
parfor, parfor.params)
695688

696689

@@ -705,7 +698,7 @@ def _lower_parfor_gufunc(lowerer, parfor):
705698
for l in parfor.loop_nests[1:]:
706699
assert typemap[l.index_variable.name] == index_var_typ
707700

708-
numba.parfor.sequential_parfor_lowering = True
701+
numba.parfors.parfor.sequential_parfor_lowering = True
709702
loop_ranges = [(l.start, l.stop, l.step) for l in parfor.loop_nests]
710703

711704
func, func_args, func_sig, func_arg_types, modified_arrays =(
@@ -722,7 +715,7 @@ def _lower_parfor_gufunc(lowerer, parfor):
722715
index_var_typ,
723716
parfor.races))
724717

725-
numba.parfor.sequential_parfor_lowering = False
718+
numba.parfors.parfor.sequential_parfor_lowering = False
726719

727720
# get the shape signature
728721
get_shape_classes = parfor.get_shape_classes
@@ -961,7 +954,7 @@ def load_range(v):
961954
dppy_cpu_lowerer.enqueue_kernel_and_read_back(loop_ranges)
962955

963956

964-
from numba.lowering import Lower
957+
from numba.core.lowering import Lower
965958

966959
class DPPyLower(Lower):
967960
def __init__(self, context, library, fndesc, func_ir, metadata=None):

dppy_passbuilder.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
from __future__ import print_function, division, absolute_import
22

3-
from numba.compiler_machinery import PassManager
3+
from numba.core.compiler_machinery import PassManager
44

5-
from numba.untyped_passes import (ExtractByteCode, TranslateByteCode, FixupArgs,
5+
from numba.core.untyped_passes import (ExtractByteCode, TranslateByteCode, FixupArgs,
66
IRProcessing, DeadBranchPrune,
77
RewriteSemanticConstants, InlineClosureLikes,
88
GenericRewrites, WithLifting,
99
InlineInlinables, FindLiterallyCalls,
1010
MakeFunctionToJitFunction,
1111
CanonicalizeLoopExit, CanonicalizeLoopEntry,
12+
ReconstructSSA,
1213
LiteralUnroll)
1314

14-
from numba.typed_passes import (NopythonTypeInference, AnnotateTypes,
15+
from numba.core.typed_passes import (NopythonTypeInference, AnnotateTypes,
1516
NopythonRewrites, PreParforPass, ParforPass,
1617
DumpParforDiagnostics, IRLegalization,
17-
InlineOverloads)
18+
InlineOverloads, PreLowerStripPhis)
1819

1920
from .dppy_passes import (
2021
DPPyConstantSizeStaticLocalMemoryPass,
@@ -68,15 +69,18 @@ def default_numba_nopython_pipeline(state, pm):
6869
pm.add_pass(FindLiterallyCalls, "find literally calls")
6970
pm.add_pass(LiteralUnroll, "handles literal_unroll")
7071

72+
if state.flags.enable_ssa:
73+
pm.add_pass(ReconstructSSA, "ssa")
7174
# typing
7275
pm.add_pass(NopythonTypeInference, "nopython frontend")
7376
pm.add_pass(AnnotateTypes, "annotate types")
7477

78+
# strip phis
79+
pm.add_pass(PreLowerStripPhis, "remove phis nodes")
80+
7581
# optimisation
7682
pm.add_pass(InlineOverloads, "inline overloaded functions")
7783

78-
# legalise
79-
pm.add_pass(IRLegalization, "ensure IR is legal prior to lowering")
8084

8185

8286
@staticmethod
@@ -91,7 +95,9 @@ def define_nopython_pipeline(state, name='dppy_nopython'):
9195
if not state.flags.no_rewrites:
9296
pm.add_pass(NopythonRewrites, "nopython rewrites")
9397
pm.add_pass(DPPyParforPass, "convert to parfors")
94-
#pm.add_pass(InlineParforVectorize, "inline vectorize inside parfors ")
98+
99+
# legalise
100+
pm.add_pass(IRLegalization, "ensure IR is legal prior to lowering")
95101

96102
# lower
97103
pm.add_pass(SpirvFriendlyLowering, "SPIRV-friendly lowering pass")

dppy_passes.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,32 @@
22
from contextlib import contextmanager
33
import warnings
44

5-
from numba import ir
5+
from numba.core import ir
66
import weakref
77
from collections import namedtuple, deque
88
import operator
99

10-
from numba.lowering import Lower, _VarArgItem
11-
12-
from llvmlite.llvmpy.core import Constant, Type, Builder
13-
from numba.stencilparfor import StencilPass
14-
15-
from numba import (
10+
from numba.core import (
1611
config,
1712
errors,
18-
types,
19-
rewrites,
20-
typeinfer,
2113
funcdesc,
2214
utils,
23-
typing
15+
typing,
16+
types,
2417
)
2518

26-
from numba.errors import (LoweringError, new_error_context, TypingError,
19+
from numba.core.ir_utils import remove_dels
20+
21+
from numba.core.errors import (LoweringError, new_error_context, TypingError,
2722
LiteralTypingError)
2823

29-
from numba.compiler_machinery import FunctionPass, LoweringPass, register_pass
24+
from numba.core.compiler_machinery import FunctionPass, LoweringPass, register_pass
3025

3126
from .dppy_lowerer import DPPyLower
3227

33-
from numba.parfor import PreParforPass as _parfor_PreParforPass
34-
from numba.parfor import ParforPass as _parfor_ParforPass
35-
from numba.parfor import Parfor
28+
from numba.parfors.parfor import PreParforPass as _parfor_PreParforPass
29+
from numba.parfors.parfor import ParforPass as _parfor_ParforPass
30+
from numba.parfors.parfor import Parfor
3631

3732

3833
@register_pass(mutates_CFG=True, analysis_only=False)
@@ -168,6 +163,8 @@ def run_pass(self, state):
168163

169164
parfor_pass.run()
170165

166+
remove_dels(state.func_ir.blocks)
167+
171168
if config.DEBUG or config.DUMP_IR:
172169
name = state.func_ir.func_id.func_qualname
173170
print(("IR DUMP: %s" % name).center(80, "-"))
@@ -244,11 +241,12 @@ def run_pass(self, state):
244241
lower.lower()
245242
if not flags.no_cpython_wrapper:
246243
lower.create_cpython_wrapper(flags.release_gil)
244+
247245
env = lower.env
248246
call_helper = lower.call_helper
249247
del lower
250248

251-
from numba.compiler import _LowerResult # TODO: move this
249+
from numba.core.compiler import _LowerResult # TODO: move this
252250
if flags.no_compile:
253251
state['cr'] = _LowerResult(fndesc, call_helper,
254252
cfunc=None, env=env)
@@ -278,7 +276,7 @@ def run_pass(self, state):
278276
lowered = state['cr']
279277
signature = typing.signature(state.return_type, *state.args)
280278

281-
from numba.compiler import compile_result
279+
from numba.core.compiler import compile_result
282280
state.cr = compile_result(
283281
typing_context=state.typingctx,
284282
target_context=state.targetctx,
@@ -296,4 +294,7 @@ def run_pass(self, state):
296294
metadata=state.metadata,
297295
reload_init=state.reload_init,
298296
)
297+
298+
remove_dels(state.func_ir.blocks)
299+
299300
return True

0 commit comments

Comments
 (0)