Skip to content

[SYCL] Split throwOnKernelParameterMisuse to improve compile time #17670

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

Merged
merged 3 commits into from
Mar 31, 2025
Merged
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
21 changes: 14 additions & 7 deletions sycl/include/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3754,13 +3754,13 @@ class __SYCL_EXPORT handler {
/// According to section 4.7.6.11. of the SYCL specification, a local accessor
/// must not be used in a SYCL kernel function that is invoked via single_task
/// or via the simple form of parallel_for that takes a range parameter.
template <typename KernelName, typename KernelType>
void throwOnKernelParameterMisuse() const {
using NameT =
typename detail::get_kernel_name_t<KernelName, KernelType>::name;
for (unsigned I = 0; I < detail::getKernelNumParams<NameT>(); ++I) {
const detail::kernel_param_desc_t ParamDesc =
detail::getKernelParamDesc<NameT>(I);
//
// Exception handling generates lots of code, outline it out of template
// method to improve compilation times.
void throwOnKernelParameterMisuseHelper(
int N, detail::kernel_param_desc_t (*f)(int)) const {
for (int I = 0; I < N; ++I) {
detail::kernel_param_desc_t ParamDesc = (*f)(I);
const detail::kernel_param_kind_t &Kind = ParamDesc.kind;
const access::target AccTarget =
static_cast<access::target>(ParamDesc.info & AccessTargetMask);
Expand All @@ -3779,6 +3779,13 @@ class __SYCL_EXPORT handler {
"of parallel_for that takes a range parameter.");
}
}
template <typename KernelName, typename KernelType>
void throwOnKernelParameterMisuse() const {
using NameT =
typename detail::get_kernel_name_t<KernelName, KernelType>::name;
throwOnKernelParameterMisuseHelper(detail::getKernelNumParams<NameT>(),
&detail::getKernelParamDesc<NameT>);
}

template <typename T, int Dims, access::mode AccessMode,
access::target AccessTarget,
Expand Down
1 change: 1 addition & 0 deletions sycl/test/abi/sycl_symbols_windows.dump
Original file line number Diff line number Diff line change
Expand Up @@ -4404,6 +4404,7 @@
?supportsUSMMemset2D@handler@_V1@sycl@@AEAA_NXZ
?sycl_category@_V1@sycl@@YAAEBVerror_category@std@@XZ
?throwIfActionIsCreated@handler@_V1@sycl@@AEAAXXZ
?throwOnKernelParameterMisuseHelper@handler@_V1@sycl@@AEBAXHP6A?AUkernel_param_desc_t@detail@23@H@Z@Z
?throw_asynchronous@queue@_V1@sycl@@QEAAXXZ
?unmap@experimental@oneapi@ext@_V1@sycl@@YAXPEBX_KAEBVcontext@45@@Z
?unsampledImageConstructorNotification@detail@_V1@sycl@@YAXPEAX0AEBV?$optional@W4image_target@_V1@sycl@@@std@@W4mode@access@23@PEBXIAEBUcode_location@123@@Z
Expand Down
Loading