Skip to content

Commit 36e26e0

Browse files
committed
adds utility to dpctl.program
1 parent cf73c6e commit 36e26e0

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

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
@@ -28,12 +28,14 @@
2828
create_program_from_source,
2929
create_program_from_spirv,
3030
create_program_from_sycl_source,
31+
is_sycl_source_compilation_available,
3132
)
3233

3334
__all__ = [
3435
"create_program_from_source",
3536
"create_program_from_spirv",
3637
"create_program_from_sycl_source",
38+
"is_sycl_source_compilation_available",
3739
"SyclKernel",
3840
"SyclProgram",
3941
"SyclProgramCompilationError",

dpctl/program/_program.pyx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ from dpctl._backend cimport ( # noqa: E211, E402;
5050
DPCTLKernelBundle_CreateFromOCLSource,
5151
DPCTLKernelBundle_CreateFromSpirv,
5252
DPCTLKernelBundle_CreateFromSYCLSource,
53+
DPCTLKernelBundle_CreateFromSYCLSource_Available,
5354
DPCTLKernelBundle_Delete,
5455
DPCTLKernelBundle_GetKernel,
5556
DPCTLKernelBundle_GetSyclKernel,
@@ -72,6 +73,7 @@ from dpctl._backend cimport ( # noqa: E211, E402;
7273
__all__ = [
7374
"create_program_from_source",
7475
"create_program_from_spirv",
76+
"is_sycl_source_compilation_available",
7577
"SyclKernel",
7678
"SyclProgram",
7779
"SyclProgramCompilationError",
@@ -84,6 +86,17 @@ cdef class SyclProgramCompilationError(Exception):
8486
pass
8587

8688

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

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)