-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL][Doc] Add sycl_ext_oneapi_raw_kernel_arg #12098
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
steffenlarsen
merged 6 commits into
intel:sycl
from
Pennycook:sycl_ext_oneapi_raw_kernel_arg
Dec 8, 2023
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f2535ed
[SYCL][Doc] Add sycl_ext_oneapi_raw_kernel_arg
Pennycook 453e45f
Clarify that raw_kernel_arg is a view
Pennycook f8e4a00
Clarify raw arguments must be trivially copyable
Pennycook 6fbabe6
Remove incorrect sentence about set_arg(s) types
Pennycook 399fba8
Wrap at 80 columns
Pennycook 6d7874a
Clarify note about lack of set_args overload
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
149 changes: 149 additions & 0 deletions
149
sycl/doc/extensions/proposed/sycl_ext_oneapi_raw_kernel_arg.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,149 @@ | ||
= sycl_ext_oneapi_raw_kernel_arg | ||
|
||
: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) 2023-2023 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 8 specification. All | ||
references below to the "core SYCL specification" or to section numbers in the | ||
SYCL specification refer to that revision. | ||
|
||
|
||
== 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 | ||
|
||
When launching kernels that are represented as `sycl::kernel` objects, | ||
developers must pass arguments via the `set_arg` or `set_args` functions. | ||
|
||
There are situations where developers would like to pass a raw byte | ||
representation of the kernel argument to the backend (e.g., when a single | ||
`parallel_for` in the source code is used to invoke multiple kernels with | ||
different arguments types, or when passing an argument to a built-in kernel | ||
for which there is no equivalent type defined on the host). | ||
|
||
=== Usage example | ||
|
||
[source,c++] | ||
---- | ||
int a; | ||
char* opaque_type; | ||
int nbytes; | ||
... | ||
h.set_arg(0, a); | ||
h.set_arg(1, sycl::ext::oneapi::raw_kernel_arg(opaque_type, nbytes)); | ||
h.parallel_for(range, kernel); | ||
---- | ||
|
||
|
||
== 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_RAW_KERNEL_ARG` 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 | ||
|Initial version of this extension. | ||
|=== | ||
|
||
=== The `raw_kernel_arg` class | ||
|
||
This extension adds a new `raw_kernel_arg` class that can be used to declare | ||
kernel arguments via a raw byte representation. | ||
|
||
[source,c++] | ||
---- | ||
namespace sycl::ext::oneapi { | ||
|
||
class raw_kernel_arg { | ||
public: | ||
raw_kernel_arg(void* bytes, size_t count); | ||
}; | ||
|
||
} // namespace sycl::ext::oneapi | ||
---- | ||
|
||
[source,c++] | ||
---- | ||
raw_kernel_arg(void* bytes, size_t count); | ||
---- | ||
_Preconditions_: `bytes` must point to an array of at least `count` bytes, | ||
which is the byte representation of a kernel argument that is trivially | ||
copyable. | ||
|
||
_Effects_: Constructs a `raw_kernel_arg` representing a view of the `count` | ||
bytes starting at the address specified by `bytes`. | ||
|
||
=== Using a raw kernel argument | ||
|
||
Instances of `raw_kernel_arg` are passed to kernels via the existing `set_arg` | ||
and `set_args` functions defined by the SYCL specification. | ||
|
||
This extension adds a new overload of `set_arg`, as defined below. | ||
|
||
[_Note:_ Since the definition of `set_args` says that it acts "as if each | ||
argument in `args` was passed to `set_arg` ", adding a new overload of | ||
`set_arg` is sufficient to change the behavior of `set_args`. _{endnote}_] | ||
|
||
[source,c++] | ||
---- | ||
void set_arg(int argIndex, sycl::ext::oneapi::raw_kernel_arg&& arg); | ||
steffenlarsen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
---- | ||
_Effects_: Sets the kernel argument associated with index `argIndex` using the | ||
bytes represented by `arg`. | ||
|
||
|
||
== 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.
Uh oh!
There was an error while loading. Please reload this page.