[SYCL] Implement sycl_khr_max_work_group_queries - #22921
Open
HPS-1 wants to merge 5 commits into
Open
Conversation
Signed-off-by: Hu, Peisen <peisen.hu@intel.com>
Signed-off-by: Hu, Peisen <peisen.hu@intel.com>
Signed-off-by: Hu, Peisen <peisen.hu@intel.com>
Signed-off-by: Hu, Peisen <peisen.hu@intel.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Implements the sycl_khr_max_work_group_queries extension by adding new KHR device info traits and plumbing them through device::get_info, plus adding an end-to-end test and enabling the feature test macro.
Changes:
- Added KHR extension header
sycl/khr/max_work_group_queries.hppand exported it via umbrella headers. - Wired new KHR device info queries into
sycl::detail::device_impland added explicit template instantiations insycl/source/device.cpp. - Added an e2e test validating the new queries and introduced UR OpenCL adapter handling for related UR device info enums.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| unified-runtime/source/adapters/opencl/device.cpp | Adds OpenCL adapter handling for UR max work-group query enums. |
| sycl/test/basic_tests/Inputs/khr_all.hpp | Includes the new KHR header in the “all KHR headers” test input. |
| sycl/test-e2e/Basic/max_work_group_queries.cpp | New e2e coverage for querying max work-group ranges and size. |
| sycl/source/feature_test.hpp.in | Defines SYCL_KHR_MAX_WORK_GROUP_QUERIES. |
| sycl/source/device.cpp | Adds explicit instantiations for the new KHR device::get_info queries. |
| sycl/source/detail/device_impl.hpp | Implements the KHR device::get_info dispatch/mapping to UR queries. |
| sycl/include/sycl/sycl.hpp | Exposes the new KHR header from the umbrella include. |
| sycl/include/sycl/khr/max_work_group_queries.hpp | Introduces the new KHR device info traits header. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
256
to
+260
| case UR_DEVICE_INFO_MAX_WORK_GROUPS_3D: { | ||
| /* Returns the maximum sizes of a work group for each dimension one could | ||
| * use to submit a kernel. There is no such query defined in OpenCL. So | ||
| * we'll return the maximum value. */ | ||
| static constexpr uint32_t MaxWorkItemDimensions = 3u; | ||
| static constexpr size_t Max = (std::numeric_limits<size_t>::max)(); | ||
| constexpr size_t ReturnBufferSize = 3; | ||
| cl_uint MaxWorkItemDimensions = 0; | ||
|
|
||
| struct { | ||
| size_t sizes[MaxWorkItemDimensions]; | ||
| } ReturnSizes; | ||
| CL_RETURN_ON_FAILURE(clGetDeviceInfo( |
Comment on lines
281
to
+286
| case UR_DEVICE_INFO_MAX_WORK_GROUPS: { | ||
| return ReturnValue(std::numeric_limits<size_t>::max()); | ||
| size_t Max = 0; | ||
| CL_RETURN_ON_FAILURE(clGetDeviceInfo(Device->CLDevice, | ||
| CL_DEVICE_MAX_WORK_GROUP_SIZE, | ||
| sizeof(Max), &Max, nullptr)); | ||
| assert(Max >= 0); |
| return get_info_impl<UR_DEVICE_INFO_MAX_LANES_PER_HW_THREAD>(); | ||
| } | ||
|
|
||
| // khr device traits (defined under sycl/ext/oneapi/...). |
Comment on lines
+1
to
+2
| //==-- max_work_group_queries.hpp - oneapi max work groups info traits | ||
| //------------==// |
cperkinsintel
approved these changes
Aug 18, 2026
cperkinsintel
left a comment
Contributor
There was a problem hiding this comment.
Looks like ABI symbols need to be updated. otherwise LGTM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Khr extension spec can be found here: https://github.com/KhronosGroup/SYCL-Docs/blob/main/adoc/extensions/sycl_khr_max_work_group_queries.adoc
And this implementation re-uses some code from the existing oneapi counterpart, of which the spec can be found here: https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/experimental/sycl_ext_oneapi_max_work_group_query.md