-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL][Doc] Add proposed range_type extension #15962
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
dm-vodopyanov
merged 6 commits into
intel:sycl
from
Pennycook:sycl_ext_oneapi_range_type
Aug 12, 2025
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0e6c8fc
[SYCL][Doc] Add proposed range_type extension
Pennycook c53b75b
Simplify error behavior and wording
Pennycook 4d248cb
Add section about -fsycl-id-queries-fit-in-int
Pennycook 81fda8c
Clarify that range_type attaches to functions
Pennycook dbc52d3
Add implementation notes to range_type proposal
Pennycook 9e872a2
Fix interaction between monospace and italics
Pennycook 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
152 changes: 152 additions & 0 deletions
152
sycl/doc/extensions/proposed/sycl_ext_oneapi_range_type.asciidoc
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,152 @@ | ||
| = sycl_ext_oneapi_range_type | ||
|
|
||
| :source-highlighter: coderay | ||
| :coderay-linenums-mode: table | ||
|
|
||
| // This section needs to be after the document title. | ||
| :doctype: book | ||
| :toc2: | ||
| :toc: left | ||
| :encoding: utf-8 | ||
| :lang: en | ||
| :dpcpp: pass:[DPC++] | ||
| :endnote: —{nbsp}end{nbsp}note | ||
|
|
||
| // Set the default source code type in this document to C++, | ||
| // for syntax highlighting purposes. This is needed because | ||
| // docbook uses c++ and html5 uses cpp. | ||
| :language: {basebackend@docbook:c++:cpp} | ||
|
|
||
|
|
||
| == Notice | ||
|
|
||
| [%hardbreaks] | ||
| Copyright (C) 2024 Intel Corporation. All rights reserved. | ||
|
|
||
| Khronos(R) is a registered trademark and SYCL(TM) and SPIR(TM) are trademarks | ||
| of The Khronos Group Inc. OpenCL(TM) is a trademark of Apple Inc. used by | ||
| permission by Khronos. | ||
|
|
||
|
|
||
| == Contact | ||
|
|
||
| To report problems with this extension, please open a new issue at: | ||
|
|
||
| https://github.com/intel/llvm/issues | ||
|
|
||
|
|
||
| == Dependencies | ||
|
|
||
| This extension is written against the SYCL 2020 revision 9 specification. All | ||
| references below to the "core SYCL specification" or to section numbers in the | ||
| SYCL specification refer to that revision. | ||
|
|
||
| This extension also depends on the following other SYCL extensions: | ||
|
|
||
| * link:../experimental/sycl_ext_oneapi_kernel_properties.asciidoc[ | ||
| sycl_ext_oneapi_kernel_properties] | ||
|
|
||
|
|
||
| == Status | ||
|
|
||
| This is a proposed extension specification, intended to gather community | ||
| feedback. Interfaces defined in this specification may not be implemented yet | ||
| or may be in a preliminary state. The specification itself may also change in | ||
| incompatible ways before it is finalized. *Shipping software products should | ||
| not rely on APIs defined in this specification.* | ||
|
|
||
|
|
||
| == Overview | ||
|
|
||
| The maximum number of work-items that can be launched in a single kernel | ||
| depends on multiple factors. | ||
| SYCL 2020 says that the total number of work-items must be representable as a | ||
| `size_t`, but several implementations (including {dpcpp}) provide optimization | ||
| options to assert that kernels will not require the full range of a `size_t`. | ||
|
|
||
| This extension proposes a new kernel property that allows developers to declare | ||
| the range requirements of individual kernels, providing more fine-grained | ||
| control than existing compiler options and improved error behavior. | ||
|
|
||
| The property described in this extension is an advanced feature that most | ||
| applications should not need to use. | ||
| In most cases, applications get the best performance without using this | ||
| property. | ||
|
|
||
|
|
||
| == Specification | ||
|
|
||
| === Feature test macro | ||
|
|
||
| This extension provides a feature-test macro as described in the core SYCL | ||
| specification. An implementation supporting this extension must predefine the | ||
| macro `SYCL_EXT_ONEAPI_RANGE_TYPE` to one of the values defined in the table | ||
| below. Applications can test for the existence of this macro to determine if | ||
| the implementation supports this feature, or applications can test the macro's | ||
| value to determine which of the extension's features the implementation | ||
| supports. | ||
|
|
||
| [%header,cols="1,5"] | ||
| |=== | ||
| |Value | ||
| |Description | ||
|
|
||
| |1 | ||
| |The APIs of this experimental extension are not versioned, so the | ||
| feature-test macro always has this value. | ||
| |=== | ||
|
|
||
| === New kernel property | ||
|
|
||
| ```c++ | ||
| namespace sycl::ext::oneapi::experimental { | ||
|
|
||
| struct range_type_key { | ||
| template <typename T> | ||
| using value_t = property_value<range_type_key, T>; | ||
| }; | ||
|
|
||
| template <typename T> | ||
| inline constexpr range_type_key::value_t<T> range_type; | ||
|
|
||
| } // namespace sycl::ext::oneapi::experimental | ||
| ``` | ||
|
|
||
| |=== | ||
| |Property|Description | ||
|
|
||
| |`range_type` | ||
| |The `range_type` property is an assertion by the application that the kernel | ||
| will never be launched with more than `std::numeric_limits<T>::max()` | ||
| work-items. | ||
| If the kernel is launched with more than this many work-items, the | ||
| implementation must throw a synchronous `exception` with the `errc::nd_range` | ||
| error code. | ||
|
|
||
| `T` must be an integral type. | ||
|
|
||
| |=== | ||
|
|
||
| == Usage example | ||
|
|
||
| ```c++ | ||
| namespace syclex = sycl::ext::oneapi::experimental; | ||
|
|
||
| struct SmallKernel | ||
| { | ||
| // Declare that this kernel supports at most 2^31-1 work-items. | ||
| auto get(syclex::properties_tag) const { | ||
| return syclex::properties{syclex::range_type<int>}; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should that be |
||
| } | ||
| }; | ||
|
|
||
| ... | ||
|
|
||
| // Throws an exception with errc::nd_range error code. | ||
| // (because 2147483648 > 2147483647) | ||
| q.parallel_for(2147483648, SmallKernel()); | ||
| ``` | ||
|
|
||
| == Issues | ||
|
|
||
| None. | ||
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.
I'd suggest "can achieve the best performance without using this property". Otherwise one can read that the property might even be harmful.