Skip to content
Open
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Added `dpctl.SyclQueue.get_last_event` and `dpctl.SyclQueue.is_get_last_event_available`, and the `DPCTLQueue_GetLastEvent` and `DPCTLQueue_GetLastEvent_Available` C-API functions, wrapping the DPC++ `sycl_ext_oneapi_in_order_queue_events` extension [gh-2299](https://github.com/IntelPython/dpctl/pull/2299)
* Added `dpctl.SyclPlatform.has_aspect_*` properties and the `DPCTLPlatform_HasAspect` C-API function for querying aspects supported by all devices of a platform [gh-2412](https://github.com/IntelPython/dpctl/pull/2412)

* Kernel bundles in `input`, `object` and `executable` states for the kernels compiled into the application: `dpctl.compiler.get_kernel_bundle`, `has_kernel_bundle`, `compile`, `link`, `build` and `join`, the `dpctl.compiler.SyclKernelId` and `dpctl.compiler.SyclDeviceImage` classes, `get_kernel_ids` and `is_compatible`, and new `dpctl.compiler.SyclKernelBundle` queries (`state`, `backend`, `sycl_context`, `get_devices`, `is_empty`, `get_kernel_ids`, `has_kernel`, `get_kernel`, `get_device_images`, `contains_specialization_constants`, `native_specialization_constant`), with the matching `DPCTLKernelBundle_*`, `DPCTLInputKernelBundle_*`, `DPCTLObjectKernelBundle_*` and `DPCTLKernelId_*` C-API functions
* `selector` argument of `dpctl.compiler.get_kernel_bundle`, a callable that chooses the device images to include, with the `DPCTLKernelBundle_CreateFromContextWithSelector`, `DPCTLInputKernelBundle_CreateFromContextWithSelector`, `DPCTLObjectKernelBundle_CreateFromContextWithSelector` and `DPCTLDeviceImage_HasKernel` C-API functions
* `dpctl4pybind11.hpp` type casters for `sycl::kernel_bundle<sycl::bundle_state::input>`, `sycl::kernel_bundle<sycl::bundle_state::object>` and `sycl::kernel_id`, and the `examples/pybind11/use_kernel_bundle` example that sets a SYCL specialization constant on a kernel bundle obtained in Python
* `dpctl.compiler.load_kernel_library` and the `DPCTLKernelId_LoadLibrary` C-API function, which load a shared library with SYCL device code, e.g. compiled for CUDA or HIP devices, and return the ids of its kernels for use with `dpctl.compiler.get_kernel_bundle`

### Changed
* Object lifetime during offload is now managed by a list of releases deferred until the events that gate them have completed, rather than by a `host_task`. `dpctl` keeps one thread for looking over the list and running the releases that have come due, started by the first release deferred and again in the child of a `fork`, which takes the GIL to do so and lets a release call into the interpreter and free USM allocations [gh-2359](https://github.com/IntelPython/dpctl/pull/2359)
* `import_dpctl()` now returns 0 on success and -1 with a Python exception set on failure, and `dpctl4pybind11.hpp` raises that exception rather than failing on the first C-API call [gh-2359](https://github.com/IntelPython/dpctl/pull/2359)
* The event returned by `dpctl.SyclQueue.keep_args_alive`, `dpctl::utils::keep_args_alive` and `dpctl.SyclQueue._submit_keep_args_alive` is now for an empty kernel that gates the deferred release rather than for a `host_task` that performs it, so its completion means that the objects are no longer in use rather than that they have been released [gh-2359](https://github.com/IntelPython/dpctl/pull/2359)
* `dpctl.utils.SequentialOrderManager[q].submitted_events` includes the queue's last event for in-order queues when `sycl_ext_oneapi_in_order_queue_events` is available, and `wait()` waits for all work on an in-order queue [gh-2299](https://github.com/IntelPython/dpctl/pull/2299)

* **Breaking:** the `dpctl.compiler.SyclKernel` properties `work_group_size`, `preferred_work_group_size_multiple`, `private_mem_size`, `max_num_sub_groups`, `max_sub_group_size`, `compile_num_sub_groups` and `compile_sub_group_size` are now methods taking an optional `device`, which defaults to the first device of the kernel bundle; the matching `DPCTLKernel_Get*` C-API functions take a `DPCTLSyclDeviceRef` argument, which may be `NULL`

### Deprecated
* Deprecated `dpctl.SyclQueue._submit_keep_args_alive` in favor of `dpctl.SyclQueue.keep_args_alive`, which it now calls and which behaves identically [gh-2359](https://github.com/IntelPython/dpctl/pull/2359)
* Deprecated the order manager's `add_event_pair`, `host_task_events` and `num_host_task_events`, as `host_task` is no longer used for managing object lifetimes, in favor of `add_event`, `add_cleanup_event`, `cleanup_events` and `num_cleanup_events`; they do not yet emit a `DeprecationWarning` [gh-2359](https://github.com/IntelPython/dpctl/pull/2359)
Expand All @@ -32,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* A USM allocation that fails now drops the references held for offloaded tasks that have completed, and is attempted once more if that released anything, so that memory only waiting to be given up is not reported as unavailable [gh-2359](https://github.com/IntelPython/dpctl/pull/2359)
* `dpctl.SyclPlatform.get_devices` no longer prints Unified Runtime warnings for `device_type="custom"` on non-OpenCL platforms, where custom devices are not supported [gh-2306](https://github.com/IntelPython/dpctl/pull/2306)
* Fixed building with the open source DPC++ compiler and CMake 4.5 or newer, which identifies it as `DPClang` instead of `Clang` [gh-2433](https://github.com/IntelPython/dpctl/pull/2433)
* `DPCTLKernel_Get*` device-specific queries return 0 instead of terminating the process when the SYCL runtime throws

### Maintenance
* Removed the `-fno-sycl-id-queries-fit-in-int` compile option, which none of the `dpctl` extensions need since `dpctl.tensor` moved to `dpnp` [gh-2413](https://github.com/IntelPython/dpctl/pull/2413)
Expand Down
20 changes: 20 additions & 0 deletions docs/doc_sources/api_reference/dpctl/compiler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ It implements creation of interoperability
as well as creation of individual ``sycl::kernel``, suitable for submission for
execution via :py:meth:`dpctl.SyclQueue.submit`.

It also exposes the kernel bundles of the kernels compiled into the
application, in ``input``, ``object`` and ``executable`` states, along with
the SYCL functions that compile, link, build and join them.

.. py:module:: dpctl.compiler

.. currentmodule:: dpctl.compiler
Expand All @@ -25,12 +29,28 @@ execution via :py:meth:`dpctl.SyclQueue.submit`.
create_kernel_bundle_from_sycl_source
is_sycl_source_compilation_available

.. autosummary::
:toctree: generated
:nosignatures:

get_kernel_bundle
has_kernel_bundle
get_kernel_ids
load_kernel_library
is_compatible
compile
link
build
join

.. autosummary::
:toctree: generated
:nosignatures:

SyclKernelBundle
SyclKernel
SyclKernelId
SyclDeviceImage
SpecializationConstant

.. autosummary::
Expand Down
215 changes: 205 additions & 10 deletions dpctl/_backend.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ cdef extern from "syclinterface/dpctl_sycl_types.h":
cdef struct DPCTLOpaqueSyclKernel
cdef struct DPCTLOpaqueSyclPlatform
cdef struct DPCTLOpaqueSyclKernelBundle
cdef struct DPCTLOpaqueSyclInputKernelBundle
cdef struct DPCTLOpaqueSyclObjectKernelBundle
cdef struct DPCTLOpaqueSyclKernelId
cdef struct DPCTLOpaqueSyclDeviceImage
cdef struct DPCTLOpaqueSyclQueue
cdef struct DPCTLOpaqueSyclUSM

Expand All @@ -191,6 +195,10 @@ cdef extern from "syclinterface/dpctl_sycl_types.h":
ctypedef DPCTLOpaqueSyclKernel *DPCTLSyclKernelRef
ctypedef DPCTLOpaqueSyclPlatform *DPCTLSyclPlatformRef
ctypedef DPCTLOpaqueSyclKernelBundle *DPCTLSyclKernelBundleRef
ctypedef DPCTLOpaqueSyclInputKernelBundle *DPCTLSyclInputKernelBundleRef
ctypedef DPCTLOpaqueSyclObjectKernelBundle *DPCTLSyclObjectKernelBundleRef
ctypedef DPCTLOpaqueSyclKernelId *DPCTLSyclKernelIdRef
ctypedef DPCTLOpaqueSyclDeviceImage *DPCTLSyclDeviceImageRef
ctypedef DPCTLOpaqueSyclQueue *DPCTLSyclQueueRef
ctypedef DPCTLOpaqueSyclUSM *DPCTLSyclUSMRef

Expand Down Expand Up @@ -439,19 +447,27 @@ cdef extern from "syclinterface/dpctl_sycl_kernel_interface.h":
cdef size_t DPCTLKernel_GetNumArgs(const DPCTLSyclKernelRef KRef)
cdef void DPCTLKernel_Delete(DPCTLSyclKernelRef KRef)
cdef DPCTLSyclKernelRef DPCTLKernel_Copy(const DPCTLSyclKernelRef KRef)
cdef size_t DPCTLKernel_GetWorkGroupSize(const DPCTLSyclKernelRef KRef)
cdef size_t DPCTLKernel_GetWorkGroupSize(
const DPCTLSyclKernelRef KRef,
const DPCTLSyclDeviceRef DRef)
cdef size_t DPCTLKernel_GetPreferredWorkGroupSizeMultiple(
const DPCTLSyclKernelRef KRef
)
cdef size_t DPCTLKernel_GetPrivateMemSize(const DPCTLSyclKernelRef KRef)
cdef uint32_t DPCTLKernel_GetMaxNumSubGroups(const DPCTLSyclKernelRef KRef)
cdef uint32_t DPCTLKernel_GetMaxSubGroupSize(const DPCTLSyclKernelRef KRef)
const DPCTLSyclKernelRef KRef,
const DPCTLSyclDeviceRef DRef)
cdef size_t DPCTLKernel_GetPrivateMemSize(
const DPCTLSyclKernelRef KRef,
const DPCTLSyclDeviceRef DRef)
cdef uint32_t DPCTLKernel_GetMaxNumSubGroups(
const DPCTLSyclKernelRef KRef,
const DPCTLSyclDeviceRef DRef)
cdef uint32_t DPCTLKernel_GetMaxSubGroupSize(
const DPCTLSyclKernelRef KRef,
const DPCTLSyclDeviceRef DRef)
cdef uint32_t DPCTLKernel_GetCompileNumSubGroups(
const DPCTLSyclKernelRef KRef
)
const DPCTLSyclKernelRef KRef,
const DPCTLSyclDeviceRef DRef)
cdef uint32_t DPCTLKernel_GetCompileSubGroupSize(
const DPCTLSyclKernelRef KRef
)
const DPCTLSyclKernelRef KRef,
const DPCTLSyclDeviceRef DRef)


cdef extern from "syclinterface/dpctl_sycl_platform_manager.h":
Expand Down Expand Up @@ -558,6 +574,185 @@ cdef extern from "syclinterface/dpctl_sycl_kernel_bundle_interface.h":
cdef DPCTLSyclKernelBundleRef DPCTLKernelBundle_Copy(
const DPCTLSyclKernelBundleRef KBRef)

cdef struct DPCTLKernelIdVector
ctypedef DPCTLKernelIdVector *DPCTLKernelIdVectorRef
cdef DPCTLKernelIdVectorRef DPCTLKernelIdVector_Create()
cdef DPCTLKernelIdVectorRef DPCTLKernelIdVector_CreateFromArray(
size_t nelems,
DPCTLSyclKernelIdRef *elems)
cdef void DPCTLKernelIdVector_Delete(DPCTLKernelIdVectorRef KIdVRef)

ctypedef bool (*DPCTLDeviceImageSelectorFn)(
DPCTLSyclDeviceImageRef ImgRef, void *UserData) noexcept
cdef bool DPCTLDeviceImage_HasKernel(
const DPCTLSyclDeviceImageRef ImgRef,
const DPCTLSyclKernelIdRef KIdRef,
const DPCTLSyclDeviceRef DRef)
cdef DPCTLSyclKernelBundleRef \
DPCTLKernelBundle_CreateFromContextWithSelector(
const DPCTLSyclContextRef CRef,
const DPCTLDeviceVectorRef DVRef,
DPCTLDeviceImageSelectorFn Selector,
void *UserData)
cdef DPCTLSyclInputKernelBundleRef \
DPCTLInputKernelBundle_CreateFromContextWithSelector(
const DPCTLSyclContextRef CRef,
const DPCTLDeviceVectorRef DVRef,
DPCTLDeviceImageSelectorFn Selector,
void *UserData)
cdef DPCTLSyclObjectKernelBundleRef \
DPCTLObjectKernelBundle_CreateFromContextWithSelector(
const DPCTLSyclContextRef CRef,
const DPCTLDeviceVectorRef DVRef,
DPCTLDeviceImageSelectorFn Selector,
void *UserData)
cdef size_t DPCTLKernelIdVector_Size(DPCTLKernelIdVectorRef KIdVRef)
cdef DPCTLSyclKernelIdRef DPCTLKernelIdVector_GetAt(
DPCTLKernelIdVectorRef KIdVRef,
size_t index)

cdef const char *DPCTLKernelId_GetName(const DPCTLSyclKernelIdRef KIdRef)
cdef bool DPCTLKernelId_AreEq(
const DPCTLSyclKernelIdRef KIdRef1,
const DPCTLSyclKernelIdRef KIdRef2)
cdef size_t DPCTLKernelId_Hash(const DPCTLSyclKernelIdRef KIdRef)
cdef DPCTLSyclKernelIdRef DPCTLKernelId_Copy(
const DPCTLSyclKernelIdRef KIdRef)
cdef void DPCTLKernelId_Delete(DPCTLSyclKernelIdRef KIdRef)
cdef DPCTLKernelIdVectorRef DPCTLKernelId_GetAll()
cdef DPCTLKernelIdVectorRef DPCTLKernelId_LoadLibrary(const char *Path)
cdef bool DPCTLKernelId_IsCompatible(
const DPCTLKernelIdVectorRef KIdVRef,
const DPCTLSyclDeviceRef DRef)

cdef DPCTLSyclContextRef DPCTLKernelBundle_GetContext(
const DPCTLSyclKernelBundleRef KBRef)
cdef DPCTLDeviceVectorRef DPCTLKernelBundle_GetDevices(
const DPCTLSyclKernelBundleRef KBRef)
cdef _backend_type DPCTLKernelBundle_GetBackend(
const DPCTLSyclKernelBundleRef KBRef)
cdef bool DPCTLKernelBundle_IsEmpty(const DPCTLSyclKernelBundleRef KBRef)
cdef DPCTLKernelIdVectorRef DPCTLKernelBundle_GetKernelIds(
const DPCTLSyclKernelBundleRef KBRef)
cdef bool DPCTLKernelBundle_HasKernelId(
const DPCTLSyclKernelBundleRef KBRef,
const DPCTLSyclKernelIdRef KIdRef,
const DPCTLSyclDeviceRef DRef)
cdef bool DPCTLKernelBundle_ContainsSpecializationConstants(
const DPCTLSyclKernelBundleRef KBRef)
cdef bool DPCTLKernelBundle_NativeSpecializationConstant(
const DPCTLSyclKernelBundleRef KBRef)
cdef size_t DPCTLKernelBundle_GetNumDeviceImages(
const DPCTLSyclKernelBundleRef KBRef)
cdef bool DPCTLKernelBundle_DeviceImageHasKernel(
const DPCTLSyclKernelBundleRef KBRef,
size_t Index,
const DPCTLSyclKernelIdRef KIdRef,
const DPCTLSyclDeviceRef DRef)
cdef DPCTLSyclKernelBundleRef DPCTLKernelBundle_Join(
size_t NumKBRefs, const DPCTLSyclKernelBundleRef *KBRefs)
cdef DPCTLSyclKernelBundleRef DPCTLKernelBundle_CreateFromContext(
const DPCTLSyclContextRef CRef,
const DPCTLDeviceVectorRef DVRef,
const DPCTLKernelIdVectorRef KIdVRef)
cdef bool DPCTLKernelBundle_CanCreateFromContext(
const DPCTLSyclContextRef CRef,
const DPCTLDeviceVectorRef DVRef,
const DPCTLKernelIdVectorRef KIdVRef)
cdef DPCTLSyclKernelRef DPCTLKernelBundle_GetKernelById(
const DPCTLSyclKernelBundleRef KBRef,
const DPCTLSyclKernelIdRef KIdRef)

cdef DPCTLSyclContextRef DPCTLInputKernelBundle_GetContext(
const DPCTLSyclInputKernelBundleRef KBRef)
cdef DPCTLDeviceVectorRef DPCTLInputKernelBundle_GetDevices(
const DPCTLSyclInputKernelBundleRef KBRef)
cdef _backend_type DPCTLInputKernelBundle_GetBackend(
const DPCTLSyclInputKernelBundleRef KBRef)
cdef bool DPCTLInputKernelBundle_IsEmpty(
const DPCTLSyclInputKernelBundleRef KBRef)
cdef DPCTLKernelIdVectorRef DPCTLInputKernelBundle_GetKernelIds(
const DPCTLSyclInputKernelBundleRef KBRef)
cdef bool DPCTLInputKernelBundle_HasKernelId(
const DPCTLSyclInputKernelBundleRef KBRef,
const DPCTLSyclKernelIdRef KIdRef,
const DPCTLSyclDeviceRef DRef)
cdef bool DPCTLInputKernelBundle_ContainsSpecializationConstants(
const DPCTLSyclInputKernelBundleRef KBRef)
cdef bool DPCTLInputKernelBundle_NativeSpecializationConstant(
const DPCTLSyclInputKernelBundleRef KBRef)
cdef size_t DPCTLInputKernelBundle_GetNumDeviceImages(
const DPCTLSyclInputKernelBundleRef KBRef)
cdef bool DPCTLInputKernelBundle_DeviceImageHasKernel(
const DPCTLSyclInputKernelBundleRef KBRef,
size_t Index,
const DPCTLSyclKernelIdRef KIdRef,
const DPCTLSyclDeviceRef DRef)
cdef DPCTLSyclInputKernelBundleRef DPCTLInputKernelBundle_Join(
size_t NumKBRefs, const DPCTLSyclInputKernelBundleRef *KBRefs)
cdef DPCTLSyclInputKernelBundleRef DPCTLInputKernelBundle_CreateFromContext(
const DPCTLSyclContextRef CRef,
const DPCTLDeviceVectorRef DVRef,
const DPCTLKernelIdVectorRef KIdVRef)
cdef bool DPCTLInputKernelBundle_CanCreateFromContext(
const DPCTLSyclContextRef CRef,
const DPCTLDeviceVectorRef DVRef,
const DPCTLKernelIdVectorRef KIdVRef)
cdef DPCTLSyclInputKernelBundleRef DPCTLInputKernelBundle_Copy(
const DPCTLSyclInputKernelBundleRef KBRef)
cdef void DPCTLInputKernelBundle_Delete(DPCTLSyclInputKernelBundleRef KBRef)
cdef DPCTLSyclObjectKernelBundleRef DPCTLInputKernelBundle_Compile(
const DPCTLSyclInputKernelBundleRef KBRef,
const DPCTLDeviceVectorRef DVRef)
cdef DPCTLSyclKernelBundleRef DPCTLInputKernelBundle_Build(
const DPCTLSyclInputKernelBundleRef KBRef,
const DPCTLDeviceVectorRef DVRef)

cdef DPCTLSyclContextRef DPCTLObjectKernelBundle_GetContext(
const DPCTLSyclObjectKernelBundleRef KBRef)
cdef DPCTLDeviceVectorRef DPCTLObjectKernelBundle_GetDevices(
const DPCTLSyclObjectKernelBundleRef KBRef)
cdef _backend_type DPCTLObjectKernelBundle_GetBackend(
const DPCTLSyclObjectKernelBundleRef KBRef)
cdef bool DPCTLObjectKernelBundle_IsEmpty(
const DPCTLSyclObjectKernelBundleRef KBRef)
cdef DPCTLKernelIdVectorRef DPCTLObjectKernelBundle_GetKernelIds(
const DPCTLSyclObjectKernelBundleRef KBRef)
cdef bool DPCTLObjectKernelBundle_HasKernelId(
const DPCTLSyclObjectKernelBundleRef KBRef,
const DPCTLSyclKernelIdRef KIdRef,
const DPCTLSyclDeviceRef DRef)
cdef bool DPCTLObjectKernelBundle_ContainsSpecializationConstants(
const DPCTLSyclObjectKernelBundleRef KBRef)
cdef bool DPCTLObjectKernelBundle_NativeSpecializationConstant(
const DPCTLSyclObjectKernelBundleRef KBRef)
cdef size_t DPCTLObjectKernelBundle_GetNumDeviceImages(
const DPCTLSyclObjectKernelBundleRef KBRef)
cdef bool DPCTLObjectKernelBundle_DeviceImageHasKernel(
const DPCTLSyclObjectKernelBundleRef KBRef,
size_t Index,
const DPCTLSyclKernelIdRef KIdRef,
const DPCTLSyclDeviceRef DRef)
cdef DPCTLSyclObjectKernelBundleRef DPCTLObjectKernelBundle_Join(
size_t NumKBRefs, const DPCTLSyclObjectKernelBundleRef *KBRefs)
cdef DPCTLSyclObjectKernelBundleRef \
DPCTLObjectKernelBundle_CreateFromContext(
const DPCTLSyclContextRef CRef,
const DPCTLDeviceVectorRef DVRef,
const DPCTLKernelIdVectorRef KIdVRef)
cdef bool DPCTLObjectKernelBundle_CanCreateFromContext(
const DPCTLSyclContextRef CRef,
const DPCTLDeviceVectorRef DVRef,
const DPCTLKernelIdVectorRef KIdVRef)
cdef DPCTLSyclObjectKernelBundleRef DPCTLObjectKernelBundle_Copy(
const DPCTLSyclObjectKernelBundleRef KBRef)
cdef void DPCTLObjectKernelBundle_Delete(
DPCTLSyclObjectKernelBundleRef KBRef)
cdef DPCTLSyclKernelBundleRef DPCTLObjectKernelBundle_Link(
size_t NumKBRefs,
const DPCTLSyclObjectKernelBundleRef *KBRefs,
const DPCTLDeviceVectorRef DVRef)

cdef struct DPCTLBuildOptionList
cdef struct DPCTLKernelNameList
cdef struct DPCTLVirtualHeaderList
Expand Down
Loading
Loading