Skip to content

[SYCL] Implement sycl_khr_max_work_group_queries - #22921

Open
HPS-1 wants to merge 5 commits into
intel:syclfrom
HPS-1:khr_max_work_group
Open

[SYCL] Implement sycl_khr_max_work_group_queries#22921
HPS-1 wants to merge 5 commits into
intel:syclfrom
HPS-1:khr_max_work_group

Conversation

@HPS-1

@HPS-1 HPS-1 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

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

HPS-1 added 2 commits August 11, 2026 07:16
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>
@HPS-1
HPS-1 marked this pull request as ready for review August 13, 2026 14:46
@HPS-1
HPS-1 requested review from a team as code owners August 13, 2026 14:46
@HPS-1
HPS-1 requested a review from cperkinsintel August 13, 2026 14:46

@bratpiorka bratpiorka left a comment

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.

OpenCL LGTM

Copilot AI left a comment

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.

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.hpp and exported it via umbrella headers.
  • Wired new KHR device info queries into sycl::detail::device_impl and added explicit template instantiations in sycl/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 cperkinsintel left a comment

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.

Looks like ABI symbols need to be updated. otherwise LGTM

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