Skip to content

Commit 3b9321e

Browse files
committed
adds utility to dpctl.program
1 parent 686861e commit 3b9321e

4 files changed

Lines changed: 26 additions & 0 deletions

File tree

dpctl/_backend.pxd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ cdef extern from "syclinterface/dpctl_sycl_kernel_bundle_interface.h":
484484
cdef void DPCTLKernelBuildLog_Delete(DPCTLKernelBuildLogRef Ref)
485485
cdef const char *DPCTLKernelBuildLog_Get(DPCTLKernelBuildLogRef)
486486

487+
cdef bool DPCTLKernelBundle_CreateFromSYCLSource_Available()
488+
487489
cdef DPCTLSyclKernelBundleRef DPCTLKernelBundle_CreateFromSYCLSource(
488490
const DPCTLSyclContextRef Ctx,
489491
const DPCTLSyclDeviceRef Dev,

dpctl/program/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
create_kernel_bundle_from_sycl_source,
3131
create_program_from_source,
3232
create_program_from_spirv,
33+
is_sycl_source_compilation_available,
3334
)
3435

3536
__all__ = [
@@ -38,6 +39,7 @@
3839
"create_program_from_source",
3940
"create_program_from_spirv",
4041
"create_kernel_bundle_from_sycl_source",
42+
"is_sycl_source_compilation_available",
4143
"SyclKernel",
4244
"SyclKernelBundle",
4345
"SyclKernelBundleCompilationError",

dpctl/program/_program.pyx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ from dpctl._backend cimport ( # noqa: E211, E402;
5353
DPCTLKernelBundle_CreateFromOCLSource,
5454
DPCTLKernelBundle_CreateFromSpirv,
5555
DPCTLKernelBundle_CreateFromSYCLSource,
56+
DPCTLKernelBundle_CreateFromSYCLSource_Available,
5657
DPCTLKernelBundle_Delete,
5758
DPCTLKernelBundle_GetKernel,
5859
DPCTLKernelBundle_GetSyclKernel,
@@ -75,6 +76,7 @@ from dpctl._backend cimport ( # noqa: E211, E402;
7576
__all__ = [
7677
"create_kernel_bundle_from_source",
7778
"create_kernel_bundle_from_spirv",
79+
"is_sycl_source_compilation_available",
7880
"SyclKernel",
7981
"SyclKernelBundle",
8082
"SyclKernelBundleCompilationError",
@@ -87,6 +89,17 @@ cdef class SyclKernelBundleCompilationError(Exception):
8789
pass
8890

8991

92+
cpdef bint is_sycl_source_compilation_available():
93+
"""Returns True if dpctl was built with compiler that supports the DPC++
94+
`kernel_compiler` extension API used by
95+
:func:`create_kernel_bundle_from_sycl_source`.
96+
97+
Device support is separate; callers should also check
98+
``q.sycl_device.can_compile('sycl')`` (or similar) for specific devices.
99+
"""
100+
return DPCTLKernelBundle_CreateFromSYCLSource_Available()
101+
102+
90103
cdef class SyclKernel:
91104
"""
92105
"""

libsyclinterface/source/dpctl_sycl_kernel_bundle_interface.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,15 @@ namespace syclex = sycl::ext::oneapi::experimental;
866866
#endif
867867
#endif
868868

869+
bool DPCTLKernelBundle_CreateFromSYCLSource_Available()
870+
{
871+
#if (SUPPORTS_SYCL_COMPILATION > 0)
872+
return true;
873+
#else
874+
return false;
875+
#endif
876+
}
877+
869878
#if (SUPPORTS_SYCL_COMPILATION > 0)
870879
// The property for registering names was renamed between DPC++ versions 2025.1
871880
// and 2025.2. The original name was `registered_kernel_names`, the new name is

0 commit comments

Comments
 (0)