Skip to content

[SYCL][NFC] Move KernelWrapper outside the sycl::handler #19511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: sycl
Choose a base branch
from

Conversation

uditagarwal97
Copy link
Contributor

@uditagarwal97 uditagarwal97 commented Jul 18, 2025

KernelWrapper is also used in the no-handler submission path, so moving this struct outside the handler class into the detail:: namespace. This PR also moves functions like kernel_single_task that are called by KernelWrapper outside the sycl::handler class.


processProperties<detail::isKernelESIMD<KernelName>()>(
KernelFunc.get(ext::oneapi::experimental::properties_tag{}));
h->processLaunchProperties(
Copy link
Contributor

Choose a reason for hiding this comment

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

I would consider removing the properties parsing from the KernelWrapper class - we could avoid passing the handler to the wrap function. Also, I feel that it might be cleaner, if the KernelWrapper is responsible just for wrapping of the kernel. I think the utility functions for property processing may still be in this header, but maybe as separate functions. Does it make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll make that change in a follow up PR.

/// the same, thus unnecessary increasing compilation time.
template <bool IsESIMDKernel,
typename PropertiesT = ext::oneapi::experimental::empty_properties_t>
void processProperties([[maybe_unused]] PropertiesT Props) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function is now only doing the validation, right? Maybe it can be called "validateProperties" or something similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll be decoupling property processing from KernelWrapper in a subsequent PR, so I'll rename this method then.

@slawekptak
Copy link
Contributor

slawekptak commented Jul 18, 2025

This change looks great, thanks Udit!

@uditagarwal97 uditagarwal97 changed the title [SYCL][NFC] Move Kernel Wrapper outside the handler. [SYCL][NFC] Move KernelWrapper outside the sycl::handler Jul 21, 2025
@uditagarwal97 uditagarwal97 marked this pull request as ready for review July 21, 2025 16:37
@uditagarwal97 uditagarwal97 requested review from a team as code owners July 21, 2025 16:37
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR moves the KernelWrapper struct and related kernel launch functions outside the sycl::handler class into the detail:: namespace to support their use in no-handler submission paths. The refactoring creates a new kernel_launch_helper.hpp header containing the moved code while updating references throughout the codebase.

  • Moved KernelWrapper and KernelWrapperSingletonFuncs from handler class to detail:: namespace
  • Created new header sycl/kernel_launch_helper.hpp for kernel launch utilities
  • Updated template parameter types and function calls to accommodate the new namespace structure

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

File Description
sycl/kernel_launch_helper.hpp New header containing moved KernelWrapper and kernel launch functions
sycl/handler.hpp Removed kernel wrapper code and updated references to use detail:: namespace
Test files Updated expected error locations from handler.hpp to kernel_launch_helper.hpp
sycl_detail_core.hpp.cpp Updated include dependency order due to header reorganization

Copy link
Contributor

@sarnex sarnex left a comment

Choose a reason for hiding this comment

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

esimd test change lgtm

@sarnex sarnex requested a review from a team July 21, 2025 16:41
Comment on lines 3645 to 3646
template <WrapAs, typename, typename, typename, typename, typename, typename>
friend struct detail::KernelWrapper;
Copy link
Contributor

Choose a reason for hiding this comment

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

How much do you need? Would it be reasonable to use HandlerAccess above instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I understand your question correctly, the idea is to reuse KernelWrapper for no-handler submission path, so it would be better to keep HandlerAccess and KernelWrapper separate.

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