-
Notifications
You must be signed in to change notification settings - Fork 798
[SYCL][Docs] Add sycl_ext_named_sub_group_sizes kernel properties #19795
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
Draft
steffenlarsen
wants to merge
5
commits into
intel:sycl
Choose a base branch
from
steffenlarsen:steffen/named_sg_size_prop
base: sycl
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e07b316
[SYCL] Add sycl_ext_named_sub_group_sizes kernel properties
jzc 091b728
Don't use 0 for named_sub_group_size value
jzc d8cfdb4
Fix test, add feature macro and move extension to experimental
steffenlarsen b5edd99
Add primary sub-group size device query
steffenlarsen ee6dc2c
Fix test
steffenlarsen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
45 changes: 45 additions & 0 deletions
45
sycl/include/sycl/ext/oneapi/experimental/named_sub_group_sizes.hpp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//== named_sub_group_sizes.hpp --- SYCL extension for named sub-group sizes ==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#pragma once | ||
|
||
#include <sycl/ext/oneapi/kernel_properties/properties.hpp> | ||
|
||
namespace sycl { | ||
inline namespace _V1 { | ||
namespace ext::oneapi::experimental { | ||
|
||
struct named_sub_group_size { | ||
static constexpr uint32_t primary = -1; | ||
static constexpr uint32_t automatic = -2; | ||
}; | ||
|
||
inline constexpr sub_group_size_key::value_t<named_sub_group_size::primary> | ||
sub_group_size_primary; | ||
|
||
inline constexpr sub_group_size_key::value_t<named_sub_group_size::automatic> | ||
sub_group_size_automatic; | ||
|
||
namespace detail { | ||
template <> | ||
struct PropertyMetaInfo< | ||
sub_group_size_key::value_t<named_sub_group_size::automatic>> { | ||
// sub_group_size_automatic means that the kernel can be compiled with | ||
// any sub-group size. That is, if the kernel has the sub_group_size_automatic | ||
// property, then no sycl-sub-group-size IR attribute needs to be attached. | ||
// Specializing PropertyMetaInfo for sub_group_size_automatic and setting | ||
// name to an empty string will result in no sycl-sub-group-size IR being | ||
// attached. | ||
static constexpr const char *name = ""; | ||
static constexpr const char *value = 0; | ||
}; | ||
} // namespace detail | ||
|
||
} // namespace ext::oneapi::experimental | ||
} // namespace _V1 | ||
} // namespace sycl |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// REQUIRES: aspect-usm_shared_allocations | ||
// RUN: %{build} -o %t.out | ||
// RUN: %{run} %t.out | ||
|
||
#include <sycl/detail/core.hpp> | ||
#include <sycl/ext/oneapi/experimental/named_sub_group_sizes.hpp> | ||
#include <sycl/sub_group.hpp> | ||
#include <sycl/usm.hpp> | ||
|
||
struct SGSizePrimaryKernelFunctor { | ||
SGSizePrimaryKernelFunctor(uint32_t *OutPtr) : Out{OutPtr} {} | ||
|
||
void operator()(sycl::nd_item<1> Item) const { | ||
*Out = Item.get_sub_group().get_max_local_range()[0]; | ||
} | ||
|
||
auto get(sycl::ext::oneapi::experimental::properties_tag) const { | ||
return sycl::ext::oneapi::experimental::properties{ | ||
sycl::ext::oneapi::experimental::sub_group_size_primary}; | ||
} | ||
|
||
uint32_t *Out; | ||
}; | ||
|
||
int main() { | ||
sycl::queue Q; | ||
|
||
uint32_t *OutPtr = sycl::malloc_shared<uint32_t>(1, Q); | ||
Q.parallel_for(sycl::nd_range<1>{1, 1}, SGSizePrimaryKernelFunctor{OutPtr}) | ||
.wait(); | ||
|
||
assert(*OutPtr == | ||
Q.get_device().get_info<sycl::info::device::primary_sub_group_size>()); | ||
return 0; | ||
} |
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
42 changes: 42 additions & 0 deletions
42
sycl/test/extensions/properties/properties_kernel_named_sub_group_size.cpp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// RUN: %clangxx -fsycl-device-only -S -Xclang -emit-llvm %s -o - | FileCheck %s | ||
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s | ||
// expected-no-diagnostics | ||
#include <sycl/sycl.hpp> | ||
|
||
struct SGSizePrimaryKernelFunctor { | ||
SGSizePrimaryKernelFunctor() {} | ||
|
||
void operator()(sycl::nd_item<1>) const {} | ||
|
||
auto get(sycl::ext::oneapi::experimental::properties_tag) const { | ||
return sycl::ext::oneapi::experimental::properties{ | ||
sycl::ext::oneapi::experimental::sub_group_size_primary}; | ||
} | ||
}; | ||
|
||
struct SGSizeAutoKernelFunctor { | ||
SGSizeAutoKernelFunctor() {} | ||
|
||
void operator()(sycl::nd_item<1>) const {} | ||
|
||
auto get(sycl::ext::oneapi::experimental::properties_tag) const { | ||
return sycl::ext::oneapi::experimental::properties{ | ||
sycl::ext::oneapi::experimental::sub_group_size_automatic}; | ||
} | ||
}; | ||
|
||
int main() { | ||
sycl::queue Q; | ||
sycl::nd_range<1> NDRange{6, 2}; | ||
|
||
// CHECK: spir_kernel void @{{.*}}SGSizePrimaryKernelFunctor() | ||
// CHECK-SAME: !intel_reqd_sub_group_size ![[SGSizeAttr:[0-9]+]] | ||
Q.parallel_for(NDRange, SGSizePrimaryKernelFunctor{}); | ||
|
||
// CHECK: spir_kernel void @{{.*}}SGSizeAutoKernelFunctor() | ||
// CHECK-NOT: intel_reqd_sub_group_size | ||
// CHECK-SAME: { | ||
Q.parallel_for(NDRange, SGSizeAutoKernelFunctor{}); | ||
} | ||
|
||
// CHECK: ![[SGSizeAttr]] = !{i32 -1} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
unified-runtime/scripts/core/EXP-SUB-GROUP-PRIMARY-SIZE.rst
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<% | ||
OneApi=tags['$OneApi'] | ||
x=tags['$x'] | ||
X=x.upper() | ||
%> | ||
|
||
.. _experimental-sub-group-primary-size: | ||
|
||
================================================================================ | ||
Sub-group primary size | ||
================================================================================ | ||
|
||
.. warning:: | ||
|
||
Experimental features: | ||
|
||
* May be replaced, updated, or removed at any time. | ||
* Do not require maintaining API/ABI stability of their own additions over | ||
time. | ||
* Do not require conformance testing of their own additions. | ||
|
||
|
||
Motivation | ||
-------------------------------------------------------------------------------- | ||
Some devices expose a "primary" sub-group size, which is a device-specific named | ||
size that is independent of the kernels run on it. Usually, this sub-group size | ||
can be specified by name in kernel code, but in order for the host code to know | ||
this size, the corresponding device info query is introduced. | ||
|
||
API | ||
-------------------------------------------------------------------------------- | ||
|
||
Enums | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
* ${x}_device_info_t | ||
* ${X}_DEVICE_INFO_SUB_GROUP_PRIMARY_SIZE_EXP | ||
|
||
Changelog | ||
-------------------------------------------------------------------------------- | ||
|
||
+-----------+------------------------+ | ||
| Revision | Changes | | ||
+===========+========================+ | ||
| 1.0 | Initial Draft | | ||
+-----------+------------------------+ | ||
|
||
|
||
Support | ||
-------------------------------------------------------------------------------- | ||
|
||
Adapters which support this experimental feature *must* return ${X}_RESULT_SUCCESS from | ||
the ${x}DeviceGetInfo call with the new ${X}_DEVICE_INFO_SUB_GROUP_PRIMARY_SIZE_EXP | ||
device descriptor. | ||
|
||
|
||
Contributors | ||
-------------------------------------------------------------------------------- | ||
|
||
* Steffen Larsen `[email protected] <[email protected]>`_ |
24 changes: 24 additions & 0 deletions
24
unified-runtime/scripts/core/exp-sub-group-primary-size.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# | ||
# Copyright (C) 2025 Intel Corporation | ||
# | ||
# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. | ||
# See LICENSE.TXT | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# | ||
# See YaML.md for syntax definition | ||
# | ||
--- #-------------------------------------------------------------------------- | ||
type: header | ||
desc: "Intel $OneApi Unified Runtime Experimental device descriptor for querying the primary sub-group size" | ||
ordinal: "99" | ||
--- #-------------------------------------------------------------------------- | ||
type: enum | ||
extend: true | ||
typed_etors: true | ||
desc: "Extension enum to $x_device_info_t to query primary sub-group size." | ||
name: $x_device_info_t | ||
etors: | ||
- name: SUB_GROUP_PRIMARY_SIZE_EXP | ||
value: "0x2023" | ||
desc: "[uint32_t][optional-query] return a 32-bit unsigned integer representing the primary sub-group size of the device." | ||
|
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
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
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
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to add a test here that the kernel actually executes with the primary sub-group size, as returned by
info::device::primary_sub_group_size
? Or is that covered by another test somewhere else?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it looks like this device info descriptor is still missing. I will add it. As an aside, should it be renamed to
ext_oneapi_primary_sub_group_size
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll defer to you on this -- we should do whatever is consistent with our other extensions.
sycl::info
isn't an enum, so I think we could define this assycl::ext::oneapi::info::device::primary_sub_group_size
if we wanted to. Butsycl::info::ext_oneapi_primary_sub_group_size
is fine by me, if that's what we usually do.