Skip to content

[SYCL] Throw runtime exception when kernel uses work group scratch memory but has not been launched with the work_group_scratch_size property#21850

Open
lbushi25 wants to merge 14 commits intointel:syclfrom
lbushi25:diagnose_work_group_scratch_memory_error
Open

[SYCL] Throw runtime exception when kernel uses work group scratch memory but has not been launched with the work_group_scratch_size property#21850
lbushi25 wants to merge 14 commits intointel:syclfrom
lbushi25:diagnose_work_group_scratch_memory_error

Conversation

@lbushi25
Copy link
Copy Markdown
Contributor

In light of #20651, this PR implements a runtime exception with error code errc::memory_allocation when a kernel uses work group scratch memory but that it has not been submitted with the work_group_scratch_size kernel launch property.

This is done mainly by adding a new device binary image property that indicates to the runtime whether a kernel uses work group scratch memory, through a direct or indirect call to the function get_work_group_scratch_memory.

@lbushi25 lbushi25 marked this pull request as ready for review April 22, 2026 19:30
@lbushi25 lbushi25 requested review from a team as code owners April 22, 2026 19:30
@lbushi25 lbushi25 requested a review from uditagarwal97 April 22, 2026 19:30
Comment thread llvm/include/llvm/Support/PropertySetIO.h
Comment thread sycl/test-e2e/WorkGroupScratchMemory/missing_launch_property.cpp
Comment thread llvm/lib/SYCLPostLink/ComputeModuleRuntimeInfo.cpp Outdated
Comment thread llvm/lib/SYCLLowerIR/LowerWGLocalMemory.cpp
Comment thread llvm/test/SYCLLowerIR/work_group_static.ll
Comment thread llvm/test/SYCLLowerIR/work_group_static.ll Outdated
Copy link
Copy Markdown
Collaborator

@iclsrc iclsrc left a comment

Choose a reason for hiding this comment

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

This PR adds a new property set SYCL/work group dynamic local mem that is emitted by the compiler for kernels using __sycl_dynamicLocalMemoryPlaceholder, and a corresponding runtime check that throws errc::memory_allocation when such a kernel is submitted without the work_group_scratch_size launch property.

The overall design is sound. A few issues are worth addressing before merge.

Comment thread sycl/test-e2e/WorkGroupScratchMemory/missing_launch_property.cpp
Comment thread llvm/lib/SYCLPostLink/ComputeModuleRuntimeInfo.cpp Outdated
Comment thread sycl/include/sycl/handler.hpp
Comment thread llvm/test/SYCLLowerIR/work_group_static.ll
Comment thread sycl/source/detail/program_manager/program_manager.cpp
@lbushi25 lbushi25 requested a review from YuriPlyakhin April 23, 2026 15:38
ret void
}

; CHECK-NOT: "sycl-work-group-scratch"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this check-not is always true and can be removed.
; CHECK: @__sycl_kernel_D{{.*}} #[[STATIC_MEM_ATTRS:[0-9]+]] covers what needs to be checked.

Copy link
Copy Markdown
Contributor

@YuriPlyakhin YuriPlyakhin left a comment

Choose a reason for hiding this comment

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

Review for PropertySet changes and SYCLLowerIR: LGTM. just one small nit left.

@lbushi25
Copy link
Copy Markdown
Contributor Author

@intel/llvm-reviewers-runtime friendly ping!

Comment thread sycl/source/detail/program_manager/program_manager.cpp
?SetHostTask@handler@_V1@sycl@@AEAAXV?$function@$$A6AXVinterop_handle@_V1@sycl@@@Z@std@@@Z
?SetHostTask@handler@_V1@sycl@@AEAAXV?$function@$$A6AXXZ@std@@@Z
?SetHostTaskFromExtEnqueueFunctions@handler@_V1@sycl@@AEAAXV?$function@$$A6AXXZ@std@@@Z
?SetKernelLaunchpropertiesIfNotEmpty@handler@_V1@sycl@@AEAAXAEBU?$PropsHolder@Uwork_group_scratch_size@experimental@oneapi@ext@_V1@sycl@@Ucache_config@2intel@456@Uuse_root_sync_key@23456@Uwork_group_progress_key@23456@Usub_group_progress_key@23456@Uwork_item_progress_key@23456@U?$cluster_size@$00@cuda@23456@U?$cluster_size@$01@cuda@23456@U?$cluster_size@$02@cuda@23456@@kernel_launch_properties_v1@detail@23@@Z
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@lbushi25 This change breaks ABI. We should restore SetKernelLaunchpropertiesIfNotEmpty

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

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.

5 participants