-
Notifications
You must be signed in to change notification settings - Fork 797
[SYCL][Doc] Add new free function queries proposal #5106
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
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0ef41cd
[SYCL][Doc] Update FreeFunctionQueries
Pennycook b657e08
Add get_linear_id()
Pennycook b21d20e
Generalize description of global iteration space
Pennycook ff5f513
Generalize description of global iteration space for item
Pennycook d58457f
Restrict get_linear_id to parallel_for
Pennycook 055e157
Make get_item() return item without an offset
Pennycook de41bf2
Resolve merge conflicts
Pennycook 05f1f77
Move documentation from experimental/ to proposed/
Pennycook 07f0cba
Restore experimental version of the extension
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
209 changes: 209 additions & 0 deletions
209
sycl/doc/extensions/FreeFunctionQueries/FreeFunctionQueries.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,209 @@ | ||
= SYCL_EXT_ONEAPI_FREE_FUNCTION_QUERIES | ||
: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 | ||
|
||
:blank: pass:[ +] | ||
|
||
// 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} | ||
|
||
== Introduction | ||
IMPORTANT: This specification is a draft. | ||
|
||
NOTE: 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. | ||
|
||
This document describes an extension that adds features for SYCL work items and groups to be available globally. | ||
|
||
== Notice | ||
|
||
Copyright (c) 2020-2021 Intel Corporation. All rights reserved. | ||
|
||
== Status | ||
|
||
Working Draft | ||
|
||
This is a preview extension specification, intended to provide early access to a feature for review and community feedback. When the feature matures, this specification may be released as a formal extension. | ||
|
||
Because the interfaces defined by this specification are not final and are subject to change they are not intended to be used by shipping software products. | ||
|
||
== Version | ||
|
||
Revision: 1 | ||
|
||
== Contact | ||
Ruslan Arutyunyan, Intel (ruslan 'dot' arutyunyan 'at' intel 'dot' com) | ||
|
||
John Pennycook, Intel (john 'dot' pennycook 'at' intel 'dot' com) | ||
|
||
== Dependencies | ||
|
||
This extension is written against the SYCL 2020 specification, Revision 4. | ||
|
||
== Feature Test Macro | ||
|
||
This extension provides a feature-test macro as described in the core SYCL | ||
specification section 6.3.3 "Feature test macros". Therefore, an implementation | ||
supporting this extension must predefine the macro `SYCL_EXT_ONEAPI_FREE_FUNCTION_QUERIES` | ||
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 APIs the implementation supports. | ||
|
||
[%header,cols="1,5"] | ||
|=== | ||
|Value |Description | ||
|1 |Initial extension version. Base features are supported. | ||
|=== | ||
|
||
== Overview | ||
|
||
The extension allows to get `sycl::id`, `sycl::item`, `sycl::nd_item`, | ||
`sycl::group` and `sycl::sub_group` instances globally, without having to | ||
explicitly pass them as arguments to each function used on the device. | ||
|
||
NOTE: Passing such instances as arguments can result in a clearer interface | ||
that is less error-prone to use. For example, if a function accepts a | ||
`sycl::group`, the caller must assume that function may call a | ||
`sycl::group_barrier` and ensure that associated control flow requirements are | ||
satisfied. It is recommended that this extension is used only when modifying | ||
existing interfaces is not feasible. | ||
|
||
== Accessing Instances of Special SYCL Classes | ||
|
||
The `sycl::ext::oneapi::this_kernel` namespace contains functionality related | ||
to the currently executing kernel. | ||
|
||
It is the user's responsibility to ensure that that these functions are called | ||
in a manner that is compatible with the kernel's launch parameters, as detailed | ||
in the definition of each function. Calling these functions from an incompatible | ||
kernel results in undefined behavior. | ||
|
||
[source,c++] | ||
---- | ||
namespace sycl { | ||
namespace ext { | ||
namespace oneapi { | ||
namespace this_kernel { | ||
|
||
size_t get_linear_id(); | ||
|
||
template <int Dimensions> | ||
id<Dimensions> get_id(); | ||
|
||
template <int Dimensions> | ||
item<Dimensions, false> get_item(); | ||
|
||
template <int Dimensions> | ||
nd_item<Dimensions> get_nd_item(); | ||
|
||
template <int Dimensions> | ||
group<Dimensions> get_group(); | ||
|
||
sub_group get_sub_group(); | ||
|
||
} | ||
} | ||
} | ||
} | ||
---- | ||
|
||
[source,c++] | ||
---- | ||
size_t get_linear_id(); | ||
---- | ||
_Preconditions_: The currently executing kernel must have been launched with a | ||
`sycl::range` or `sycl::nd_range` argument. | ||
|
||
_Returns_: A `size_t` representing the current work-item's linear position in | ||
the global iteration space. Multi-dimensional indices are converted into a | ||
linear index following the linearization equations defined in Section 3.11.1 of | ||
the SYCL 2020 specification. | ||
|
||
[source,c++] | ||
---- | ||
template <int Dimensions> | ||
id<Dimensions> get_id(); | ||
---- | ||
_Preconditions_: `Dimensions` must match the dimensionality of the currently | ||
executing kernel. The currently executing kernel must have been launched with a | ||
`sycl::range` or `sycl::nd_range` argument. | ||
|
||
_Returns_: A `sycl::id` instance representing the current work-item in the | ||
global iteration space. | ||
|
||
[source,c++] | ||
---- | ||
template <int Dimensions> | ||
item<Dimensions, false> get_item(); | ||
---- | ||
_Preconditions_: `Dimensions` must match the dimensionality of the currently | ||
executing kernel. The currently executing kernel must have been launched with a | ||
`sycl::range` or `sycl::nd_range` argument. | ||
Pennycook marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
_Returns_: A `sycl::item` instance representing the current work-item in the | ||
global iteration space. | ||
|
||
NOTE: The `offset` parameter to `parallel_for` is deprecated in SYCL 2020, as | ||
is the ability of an `item` to carry an offset. This extension returns an | ||
`item` where the `WithOffset` template parameter is set to `false` to prevent | ||
usage of the new queries in conjunction with deprecated functionality. The | ||
return type of `get_item()` is expected to change when the `offset` parameter | ||
is removed in a future version of the SYCL specification. | ||
|
||
[source,c++] | ||
---- | ||
template <int Dimensions> | ||
nd_item<Dimensions> get_nd_item(); | ||
---- | ||
_Preconditions_: `Dimensions` must match the dimensionality of the currently | ||
executing kernel. The currently executing kernel must have been launched with a | ||
`sycl::nd_range` argument. | ||
|
||
_Returns_: A `sycl::nd_item` instance representing the current work-item in a | ||
`sycl::nd_range`. | ||
|
||
[source,c++] | ||
---- | ||
template <int Dimensions> | ||
group<Dimensions> get_group(); | ||
---- | ||
_Preconditions_: `Dimensions` must match the dimensionality of the currently | ||
executing kernel. The currently executing kernel must have been launched with a | ||
`sycl::nd_range` argument. | ||
|
||
_Returns_: A `sycl::group` instance representing the work-group to which the | ||
current work-item belongs. | ||
|
||
[source,c++] | ||
---- | ||
sub_group get_sub_group(); | ||
---- | ||
_Preconditions_: The currently executing kernel must have been launched with a | ||
`sycl::nd_range` argument. | ||
|
||
_Returns_: A `sycl::sub_group` instance representing the sub-group to which the | ||
current work-item belongs. | ||
|
||
== Issues | ||
|
||
. Can undefined behavior be avoided or detected? | ||
-- | ||
*UNRESOLVED*: Good run-time errors would likely require support for device-side | ||
assertions or exceptions, while good compile-time errors would likely require | ||
some additional compiler modifications and/or kernel properties. | ||
-- | ||
|
||
//. asd | ||
//+ | ||
//-- | ||
//*RESOLUTION*: Not resolved. | ||
//-- |
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.
Uh oh!
There was an error while loading. Please reload this page.