Skip to content

Support SYCL source compilation#2206

Open
ndgrigorian wants to merge 7 commits into
masterfrom
feature/sycl-source-compilation
Open

Support SYCL source compilation#2206
ndgrigorian wants to merge 7 commits into
masterfrom
feature/sycl-source-compilation

Conversation

@ndgrigorian
Copy link
Copy Markdown
Collaborator

This PR adds support for creating an executable kernel_bundle from SYCL source code to dpctl using the kernel_compiler DPC++ extension

Supersedes gh-2049

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?
  • If this PR is a work in progress, are you opening the PR as a draft?

@github-actions
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

Array API standard conformance tests for dpctl=0.22.0dev0=py310h93fe807_65 ran successfully.
Passed: 1111
Failed: 47
Skipped: 82

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Nov 30, 2025

Coverage Status

coverage: 75.719% (+0.3%) from 75.39% — feature/sycl-source-compilation into master

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 3, 2025

Array API standard conformance tests for dpctl=0.22.0dev0=py310h93fe807_66 ran successfully.
Passed: 1115
Failed: 43
Skipped: 82

@ndgrigorian ndgrigorian force-pushed the feature/sycl-source-compilation branch from 9d64cb8 to 22475d9 Compare December 17, 2025 21:13
@github-actions
Copy link
Copy Markdown

Array API standard conformance tests for dpctl=0.22.0dev0=py310h93fe807_104 ran successfully.
Passed: 1114
Failed: 44
Skipped: 82

@ndgrigorian ndgrigorian force-pushed the feature/sycl-source-compilation branch 2 times, most recently from 75969ce to be75a7e Compare February 11, 2026 22:44
@ndgrigorian ndgrigorian force-pushed the feature/sycl-source-compilation branch from cf56032 to 7a58ef7 Compare February 17, 2026 02:13
@ndgrigorian ndgrigorian force-pushed the feature/sycl-source-compilation branch from 43d385b to 788fdd2 Compare April 8, 2026 09:12
@ndgrigorian ndgrigorian changed the base branch from master to feature/uncouple-tensor-from-dpctl April 8, 2026 09:13
@ndgrigorian ndgrigorian force-pushed the feature/sycl-source-compilation branch from 788fdd2 to 4656feb Compare April 8, 2026 09:39
@ndgrigorian ndgrigorian force-pushed the feature/uncouple-tensor-from-dpctl branch 2 times, most recently from b610ee3 to dd74214 Compare April 13, 2026 16:47
Base automatically changed from feature/uncouple-tensor-from-dpctl to master April 13, 2026 20:20
@ndgrigorian ndgrigorian force-pushed the feature/sycl-source-compilation branch from 4656feb to cae6959 Compare April 28, 2026 21:01
@ndgrigorian ndgrigorian force-pushed the feature/sycl-source-compilation branch 2 times, most recently from cfe7f1f to 417c4a0 Compare May 26, 2026 15:16
sommerlukas and others added 6 commits May 26, 2026 08:19
Enable SYCL source compilation, but only for DPC++ versions that actually
support the compilation, based on the __SYCL_COMPILER_VERSION reported.

Uses the correct naming for the property based on DPC++ version,
detected through C++ type traits to check which property actually refers
to a fully defined type.

This commit also works around a bug in DPC++ version 2025.1. The constructor
with no parameter of class `include_files` was only declared, but never
defined. Calling it when creating a SYCL source kernel bundle therefore
leads to references to undefined symbols with DPC++ version 2025.1. This
change works around this issue by calling an alternative constructor,
which is defined in the release.

Signed-off-by: Lukas Sommer <lukas.sommer@codeplay.com>
@ndgrigorian ndgrigorian force-pushed the feature/sycl-source-compilation branch from 417c4a0 to ece9fa0 Compare May 26, 2026 15:26
:class:`.SyclKernelBundle` is going to be built.
source (unicode)
SYCL source code string.
headers (list)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the description below, it should be headers (list, optional), right?

documentation of the ``registered_names`` property in the DPC++
``kernel_compiler`` extension for more information.
Default: []
copts (list)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

cdef bytes bContent
cdef const char* sContent
cdef const char* buildLogContent
for opt in copts:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails when copts is None (the default value)

dpctl.program.create_kernel_bundle_from_sycl_source(q, sycl_source)
# out : TypeError: 'NoneType' object is not iterable.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is repeated in the loops below, it make sense to add something like:

if copts is None:
    copts = []
if registered_names is None:
    registered_names = []
if headers is None:
    headers = []

DPCTLBuildOptionList_Append(BuildOpts, sOpt)

cdef DPCTLKernelNameListRef KernelNames = DPCTLKernelNameList_Create()
for name in registered_names:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

cdef DPCTLVirtualHeaderListRef VirtualHeaders
VirtualHeaders = DPCTLVirtualHeaderList_Create()

for name, content in headers:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Comment on lines +908 to +914
__dpctl_keep const DPCTLSyclContextRef Ctx,
__dpctl_keep const DPCTLSyclDeviceRef Dev,
__dpctl_keep const char *Source,
__dpctl_keep DPCTLVirtualHeaderListRef Headers,
__dpctl_keep DPCTLKernelNameListRef Names,
__dpctl_keep DPCTLBuildOptionListRef BuildOptions,
__dpctl_keep DPCTLKernelBuildLogRef BuildLog)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can any of these parameters be nullptr?
If so , should we add a nullptr check below?

Comment on lines +500 to +504
DPCTLBuildOptionList_Delete(BuildOpts)
DPCTLKernelNameList_Delete(KernelNames)
DPCTLVirtualHeaderList_Delete(VirtualHeaders)
DPCTLKernelBuildLog_Delete(BuildLog)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may leak if an unexpected exception is raised earlier


create_kernel_bundle_from_source
create_kernel_bundle_from_spirv
create_kernel_bundle_from_sycl_source
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_sycl_source_compilation_available is missing

Optional list of kernel names to register. See the
documentation of the ``registered_names`` property in the DPC++
``kernel_compiler`` extension for more information.
Default: []
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value is None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants