Skip to content

Commit 6e6e6e3

Browse files
author
Diptorup Deb
authored
Merge pull request #1174 from IntelPython/refactor/dpctl_iface
Refactor the dpctl_iface module.
2 parents 524495f + 922055a commit 6e6e6e3

File tree

9 files changed

+119
-920
lines changed

9 files changed

+119
-920
lines changed

numba_dpex/core/parfors/reduction_helper.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from numba_dpex import utils
2020
from numba_dpex.core.utils.kernel_launcher import KernelLaunchIRBuilder
21-
from numba_dpex.dpctl_iface import DpctlCAPIFnBuilder
21+
from numba_dpex.dpctl_iface import libsyclinterface_bindings as sycl
2222

2323
from ..types.dpnp_ndarray_type import DpnpNdArray
2424

@@ -408,16 +408,6 @@ def copy_final_sum_to_host(self, parfor_kernel):
408408
builder = lowerer.builder
409409
context = lowerer.context
410410

411-
memcpy_fn = DpctlCAPIFnBuilder.get_dpctl_queue_memcpy(
412-
builder=builder, context=context
413-
)
414-
event_del_fn = DpctlCAPIFnBuilder.get_dpctl_event_delete(
415-
builder=builder, context=context
416-
)
417-
event_wait_fn = DpctlCAPIFnBuilder.get_dpctl_event_wait(
418-
builder=builder, context=context
419-
)
420-
421411
for i, redvar in enumerate(self.parfor_redvars):
422412
srcVar = self.final_sum_names[i]
423413

@@ -453,9 +443,8 @@ def copy_final_sum_to_host(self, parfor_kernel):
453443
builder.load(item_size),
454444
]
455445

456-
event_ref = builder.call(memcpy_fn, args)
457-
458-
builder.call(event_wait_fn, [event_ref])
459-
builder.call(event_del_fn, [event_ref])
446+
event_ref = sycl.dpctl_queue_memcpy(builder, *args)
447+
sycl.dpctl_event_wait(builder, event_ref)
448+
sycl.dpctl_event_delete(builder, event_ref)
460449

461450
ir_builder.free_queue(sycl_queue_val=curr_queue)

numba_dpex/core/runtime/context.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -402,27 +402,3 @@ def submit_ndrange(
402402
)
403403

404404
return ret
405-
406-
def copy_queue(self, builder, queue_ref):
407-
"""Calls DPCTLQueue_Copy to create a copy of the DpctlSyclQueueRef
408-
pointer passed in to the function.
409-
410-
Args:
411-
builder: The llvmlite.IRBuilder used to generate the LLVM IR for the
412-
call.
413-
queue_ref: An LLVM value for a DpctlSyclQueueRef pointer that will
414-
be passed to the DPCTLQueue_Copy function.
415-
416-
Returns: A DPCTLSyclQueueRef pointer.
417-
"""
418-
mod = builder.module
419-
fnty = llvmir.FunctionType(
420-
cgutils.voidptr_t,
421-
[cgutils.voidptr_t],
422-
)
423-
fn = cgutils.get_or_insert_function(mod, fnty, "DPCTLQueue_Copy")
424-
fn.return_value.add_attribute("noalias")
425-
426-
ret = builder.call(fn, [queue_ref])
427-
428-
return ret

numba_dpex/core/utils/kernel_launcher.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from numba_dpex import utils
88
from numba_dpex.core.runtime.context import DpexRTContext
99
from numba_dpex.core.types import DpnpNdArray
10-
from numba_dpex.dpctl_iface import DpctlCAPIFnBuilder
10+
from numba_dpex.dpctl_iface import libsyclinterface_bindings as sycl
1111
from numba_dpex.dpctl_iface._helpers import numba_type_to_dpctl_typenum
1212

1313

@@ -283,10 +283,8 @@ def free_queue(self, sycl_queue_val):
283283
Args:
284284
sycl_queue_val: The SYCL queue pointer to be freed.
285285
"""
286-
fn = DpctlCAPIFnBuilder.get_dpctl_queue_delete(
287-
builder=self.builder, context=self.context
288-
)
289-
self.builder.call(fn, [self.builder.load(sycl_queue_val)])
286+
qref = self.builder.load(sycl_queue_val)
287+
sycl.dpctl_queue_delete(self.builder, qref)
290288

291289
def allocate_kernel_arg_array(self, num_kernel_args):
292290
"""Allocates an array to store the LLVM Value for every kernel argument.

numba_dpex/dpctl_iface/__init__.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,6 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
"""
6-
The ``dpctl_iface`` module implements Numba's interface to the dpctl library
7-
that provides Python and C bindings to DPC++'s SYCL runtime API. The module
8-
includes:
9-
10-
- LLVM IR builders for dpctl C API functions to be called directly from a Numba
11-
generated LLVM module.
12-
- Functions to launch kernels on the dpctl "current queue".
13-
6+
The ``dpctl_iface`` module implements Numba's interface to the libsyclinterface
7+
library that provides C bindings to DPC++'s SYCL runtime API.
148
"""
15-
import numba_dpex.dpctl_iface.dpctl_function_types as dpctl_fn_ty
16-
from numba_dpex.dpctl_iface.dpctl_capi_fn_builder import DpctlCAPIFnBuilder
17-
from numba_dpex.dpctl_iface.legacy_kernel_launch_ops import KernelLaunchOps
18-
19-
__all__ = [
20-
DpctlCAPIFnBuilder,
21-
KernelLaunchOps,
22-
]
23-
24-
get_current_queue = dpctl_fn_ty.dpctl_get_current_queue()
25-
malloc_shared = dpctl_fn_ty.dpctl_malloc_shared()
26-
queue_memcpy = dpctl_fn_ty.dpctl_queue_memcpy()
27-
free_with_queue = dpctl_fn_ty.dpctl_free_with_queue()
28-
event_wait = dpctl_fn_ty.dpctl_event_wait()
29-
event_delete = dpctl_fn_ty.dpctl_event_delete()
30-
queue_wait = dpctl_fn_ty.dpctl_queue_wait()

0 commit comments

Comments
 (0)