Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .coveragerc

This file was deleted.

3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

# Migrate code style to Black
8bd62e61bb70fe0483bd494040e4103fd050252a

# Set max line width to 80 in black
c27b2b31b3f275225f8db5d7bd5924b4677bcce2
56 changes: 42 additions & 14 deletions numba_dppy/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,16 @@ def define_pipelines(self):
# this maintains the objmode fallback behaviour
pms = []
self.state.parfor_diagnostics = ExtendedParforDiagnostics()
self.state.metadata["parfor_diagnostics"] = self.state.parfor_diagnostics
self.state.metadata[
"parfor_diagnostics"
] = self.state.parfor_diagnostics
if not self.state.flags.force_pyobject:
# print("Numba-DPPY [INFO]: Using Numba-DPPY pipeline")
pms.append(DPPYPassBuilder.define_nopython_pipeline(self.state))
if self.state.status.can_fallback or self.state.flags.force_pyobject:
pms.append(DefaultPassBuilder.define_objectmode_pipeline(self.state))
pms.append(
DefaultPassBuilder.define_objectmode_pipeline(self.state)
)
return pms


Expand Down Expand Up @@ -169,7 +173,9 @@ def compile_with_dppy(pyfunc, return_type, args, is_kernel, debug=None):
def compile_kernel(sycl_queue, pyfunc, args, access_types, debug=None):
# For any array we only accept numba_dppy.dppy_array_type.DPPYArray
for arg in args:
if isinstance(arg, types.npytypes.Array) and not isinstance(arg, DPPYArray):
if isinstance(arg, types.npytypes.Array) and not isinstance(
arg, DPPYArray
):
raise TypeError(
"We only accept DPPYArray as type of array-like objects. We received %s"
% (type(arg))
Expand Down Expand Up @@ -203,10 +209,14 @@ def compile_kernel(sycl_queue, pyfunc, args, access_types, debug=None):
return oclkern


def compile_kernel_parfor(sycl_queue, func_ir, args, args_with_addrspaces, debug=None):
def compile_kernel_parfor(
sycl_queue, func_ir, args, args_with_addrspaces, debug=None
):
# For any array we only accept numba_dppy.dppy_array_type.DPPYArray
for arg in args_with_addrspaces:
if isinstance(arg, types.npytypes.Array) and not isinstance(arg, DPPYArray):
if isinstance(arg, types.npytypes.Array) and not isinstance(
arg, DPPYArray
):
raise TypeError(
"We only accept DPPYArray as type of array-like objects. We received %s"
% (type(arg))
Expand Down Expand Up @@ -246,7 +256,11 @@ def compile_kernel_parfor(sycl_queue, func_ir, args, args_with_addrspaces, debug

def compile_dppy_func(pyfunc, return_type, args, debug=None):
cres = compile_with_dppy(
pyfunc=pyfunc, return_type=return_type, args=args, is_kernel=False, debug=debug
pyfunc=pyfunc,
return_type=return_type,
args=args,
is_kernel=False,
debug=debug,
)
func = cres.library.get_function(cres.fndesc.llvm_func_name)
cres.target_context.mark_ocl_device(func)
Expand Down Expand Up @@ -312,7 +326,9 @@ def compile(self, args):

if first_definition:
# First definition
cres.target_context.insert_user_function(self, cres.fndesc, libs)
cres.target_context.insert_user_function(
self, cres.fndesc, libs
)
else:
cres.target_context.add_user_function(self, cres.fndesc, libs)

Expand All @@ -330,7 +346,9 @@ def __init__(self, cres):
def _ensure_valid_work_item_grid(val, sycl_queue):

if not isinstance(val, (tuple, list, int)):
error_message = "Cannot create work item dimension from provided argument"
error_message = (
"Cannot create work item dimension from provided argument"
)
raise ValueError(error_message)

if isinstance(val, int):
Expand All @@ -351,7 +369,9 @@ def _ensure_valid_work_item_grid(val, sycl_queue):
def _ensure_valid_work_group_size(val, work_item_grid):

if not isinstance(val, (tuple, list, int)):
error_message = "Cannot create work item dimension from provided argument"
error_message = (
"Cannot create work item dimension from provided argument"
)
raise ValueError(error_message)

if isinstance(val, int):
Expand Down Expand Up @@ -496,7 +516,9 @@ def __call__(self, *args):
internal_device_arrs,
self.ordered_arg_access_types,
):
self._pack_argument(ty, val, self.sycl_queue, i_dev_arr, access_type)
self._pack_argument(
ty, val, self.sycl_queue, i_dev_arr, access_type
)

def _pack_argument(self, ty, val, sycl_queue, device_arr, access_type):
"""
Expand Down Expand Up @@ -584,7 +606,9 @@ def _unpack_argument(
packed_val = val
usm_mem = has_usm_memory(val)
if usm_mem is None:
default_behavior = self.check_for_invalid_access_type(access_type)
default_behavior = self.check_for_invalid_access_type(
access_type
)
usm_mem = as_usm_obj(val, queue=sycl_queue, copy=False)

orig_val = val
Expand All @@ -603,8 +627,10 @@ def _unpack_argument(

if (
default_behavior
or self.valid_access_types[access_type] == _NUMBA_DPPY_READ_ONLY
or self.valid_access_types[access_type] == _NUMBA_DPPY_READ_WRITE
or self.valid_access_types[access_type]
== _NUMBA_DPPY_READ_ONLY
or self.valid_access_types[access_type]
== _NUMBA_DPPY_READ_WRITE
):
copy_from_numpy_to_usm_obj(usm_mem, packed_val)

Expand Down Expand Up @@ -693,7 +719,9 @@ def __call__(self, *args, **kwargs):

argtypes = self._get_argtypes(*args)
kernel = self.specialize(argtypes, current_queue)
cfg = kernel.configure(self.sycl_queue, self.global_size, self.local_size)
cfg = kernel.configure(
self.sycl_queue, self.global_size, self.local_size
)
cfg(*args)

def specialize(self, argtypes, queue):
Expand Down
4 changes: 3 additions & 1 deletion numba_dppy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,6 @@ def __getattr__(name):
LLVM_SPIRV_ROOT = _readenv("NUMBA_DPPY_LLVM_SPIRV_ROOT", str, "")
# Emit debug info
DEBUG = _readenv("NUMBA_DPPY_DEBUG", int, config.DEBUG)
DEBUGINFO_DEFAULT = _readenv("NUMBA_DPPY_DEBUGINFO", int, config.DEBUGINFO_DEFAULT)
DEBUGINFO_DEFAULT = _readenv(
"NUMBA_DPPY_DEBUGINFO", int, config.DEBUGINFO_DEFAULT
)
8 changes: 6 additions & 2 deletions numba_dppy/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def kernel(signature=None, access_types=None, debug=None):

def autojit(debug=None, access_types=None):
def _kernel_autojit(pyfunc):
ordered_arg_access_types = get_ordered_arg_access_types(pyfunc, access_types)
ordered_arg_access_types = get_ordered_arg_access_types(
pyfunc, access_types
)
return JitDPPYKernel(pyfunc, debug, ordered_arg_access_types)

return _kernel_autojit
Expand All @@ -64,7 +66,9 @@ def _kernel_jit(signature, debug, access_types):

def _wrapped(pyfunc):
current_queue = dpctl.get_current_queue()
ordered_arg_access_types = get_ordered_arg_access_types(pyfunc, access_types)
ordered_arg_access_types = get_ordered_arg_access_types(
pyfunc, access_types
)
# We create an instance of JitDPPYKernel to make sure at call time
# we are going through the caching mechanism.
dppy_kernel = JitDPPYKernel(pyfunc, debug, ordered_arg_access_types)
Expand Down
4 changes: 3 additions & 1 deletion numba_dppy/dpctl_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def dpctl_malloc_shared():

def dpctl_queue_memcpy():
ret_type = types.voidptr
sig = signature(ret_type, types.voidptr, types.voidptr, types.voidptr, types.int64)
sig = signature(
ret_type, types.voidptr, types.voidptr, types.voidptr, types.int64
)
return types.ExternalFunction("DPCTLQueue_Memcpy", sig)


Expand Down
8 changes: 6 additions & 2 deletions numba_dppy/dpnp_glue/dpnp_array_creations_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ def dpnp_impl(a, b):
dpctl_functions.event_delete(event)

out = np.arange(0, a.size, 1, res_dtype)
out_usm = dpctl_functions.malloc_shared(out.size * out.itemsize, sycl_queue)
out_usm = dpctl_functions.malloc_shared(
out.size * out.itemsize, sycl_queue
)

dpnp_func(b_usm, out_usm, a.size)

Expand Down Expand Up @@ -260,7 +262,9 @@ def dpnp_trace_impl(a):
void dpnp_trace_c(const void* array1_in, void* result1, const size_t* shape_, const size_t ndim)

"""
sig = signature(ret_type, types.voidptr, types.voidptr, types.voidptr, types.intp)
sig = signature(
ret_type, types.voidptr, types.voidptr, types.voidptr, types.intp
)
dpnp_func = dpnp_ext.dpnp_func("dpnp_" + name, [a.dtype.name, "NONE"], sig)

PRINT_DEBUG = dpnp_lowering.DEBUG
Expand Down
16 changes: 12 additions & 4 deletions numba_dppy/dpnp_glue/dpnp_array_ops_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ def dpnp_impl(a):
dpctl_functions.event_delete(event)

out = np.arange(0, a.size, 1, res_dtype)
out_usm = dpctl_functions.malloc_shared(out.size * out.itemsize, sycl_queue)
out_usm = dpctl_functions.malloc_shared(
out.size * out.itemsize, sycl_queue
)

dpnp_func(a_usm, out_usm, a.size)

Expand Down Expand Up @@ -201,7 +203,9 @@ def dpnp_impl(a):
dpctl_functions.event_delete(event)

out = np.arange(0, a.size, 1, res_dtype)
out_usm = dpctl_functions.malloc_shared(out.size * out.itemsize, sycl_queue)
out_usm = dpctl_functions.malloc_shared(
out.size * out.itemsize, sycl_queue
)

dpnp_func(a_usm, out_usm, a.size)

Expand Down Expand Up @@ -261,15 +265,19 @@ def dpnp_impl(a, ind):
dpctl_functions.event_wait(event)
dpctl_functions.event_delete(event)

ind_usm = dpctl_functions.malloc_shared(ind.size * ind.itemsize, sycl_queue)
ind_usm = dpctl_functions.malloc_shared(
ind.size * ind.itemsize, sycl_queue
)
event = dpctl_functions.queue_memcpy(
sycl_queue, ind_usm, ind.ctypes, ind.size * ind.itemsize
)
dpctl_functions.event_wait(event)
dpctl_functions.event_delete(event)

out = np.arange(0, ind.size, 1, res_dtype).reshape(ind.shape)
out_usm = dpctl_functions.malloc_shared(out.size * out.itemsize, sycl_queue)
out_usm = dpctl_functions.malloc_shared(
out.size * out.itemsize, sycl_queue
)

dpnp_func(a_usm, a.size * a.itemsize, ind_usm, out_usm, ind.size)

Expand Down
4 changes: 3 additions & 1 deletion numba_dppy/dpnp_glue/dpnp_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ def dpnp_impl(a, offset=0):
dpctl_functions.event_wait(event)
dpctl_functions.event_delete(event)

out_usm = dpctl_functions.malloc_shared(out.size * out.itemsize, sycl_queue)
out_usm = dpctl_functions.malloc_shared(
out.size * out.itemsize, sycl_queue
)

dpnp_func(
a_usm,
Expand Down
Loading