-
Notifications
You must be signed in to change notification settings - Fork 770
[SYCL][Doc] Add spec for "sycl" to kernel compiler #11985
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
[SYCL][Doc] Add spec for "sycl" to kernel compiler #11985
Conversation
Update the proposed specification for the kernel compiler to allow kernels to be written in the SYCL language, using the new proposed "free function kernel" format.
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Outdated
Show resolved
Hide resolved
Require the source string to `#include <sycl/sycl.hpp>` in order to get the content of that header. Clarify that this header and other standard headers are available even without the `include_files` property.
These details are provided by other extensions. | ||
This extension provides support for kernels written in SYCL according to the | ||
"free function kernel" syntax defined in | ||
link:../proposed/sycl_ext_oneapi_free_function_kernels.asciidoc[ |
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.
Is this available somewhere?
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.
No, it's not implemented yet. I expect that we will implement that extension at the same time as the new additions to "sycl_ext_oneapi_kernel_compiler" that are described in this PR.
Runtime compilation is an urgently needed feature of SYCL in project development. Thanks for your specification. Also out of curiosity, may the kernel compiler support using inline PTX assembly in SYCL kernel? opencl example. Inline Assembly makes rich low-level hardware features available to programmers. |
The new overload of `create_kernel_bundle_from_source` should also take a property list.
Hi @DongBaiYue, I think this is not strongly related to this extension. Runtime compilation should work for kernels that use any of the SYCL features that available in normal kernels. I'm not sure if normal SYCL kernels can contain PTX assembly, but @AerialMantis might know. |
In d49df13 we decided that the source code string must contain `#include <sycl/sycl.hpp>`, but that commit forgot to add this include to all the examples.
We decided to switch the syntax for identifying a free function kernel. We now use a compile time property instead of a special macro.
Attention reviewers: I do not plan any more changes to this PR. If you have more comments, please make them soon. |
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Outdated
Show resolved
Hide resolved
Marking this PR as "draft" only to prevent it from being merged until after these new APIs have been implemented. This is a new process I'm trying out for cases where we make proposed changes to an extension specification that is already implemented. When these new changes are implemented, we can merge this PR. That way, the extension specification in the repo will always reflect what is currently implemented. |
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Show resolved
Hide resolved
include_files(const std::string &name, const std::string &content); (1) | ||
include_files(const std::vector<std::string> &names, (2) | ||
const std::vector<std::string> &contents); | ||
}; |
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 have some reservations about this include_files struct.
We know for the first implementation that we are likely going to have to write out a temporary .cpp file and invoke clang++ -fsycl
on it. So now we have to also write out the include files? What about #include "path/to/file.h"
? Will we then be parsing this and instantiating directories?
I presume we need to disambiguate #include "local/path.h"
from #include <system/path.h>
?
Users can't link in libraries ( even if has a header ), and there is only the one TU. Supporting #include
suggests the opposite. Maybe a note proscribing it is needed?
I do see the value in that if a user has a simple function that they want to both use in the host application and call from their kernel, this allows them to do so. And, if clang were to ever have an invocation API (like ocloc) then I guess this aligns with that.
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.
One of the reasons we added the include_files
property is for parity with CUDA, which has a similar feature in NVRTC. By adding the feature to SYCL, we make it easier to migrate code automatically using the SYCLomatic tool.
I was thinking that our implementation could create a temporary "include" directory and then write out the include_files
header files into that directory. When we invoke clang, we can add a -I
switch pointing at the temporary include directory.
Note that you don't need to parse any #include
strings from the source code to get the file name paths. The include_files
properties contains a list of (Name, Content) pairs. Each Name is the relative pathname of an include file, so you can just use this Name string verbatim.
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Outdated
Show resolved
Hide resolved
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.
Thanks for the careful review! See responses below.
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Outdated
Show resolved
Hide resolved
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.
Current text looks good to me 👍
We decided to remove support for `range_kernel` from the free function kernel spec, so change all the examples to use `nd_range_kernel` instead. The proposed `this_kernel` namespace was changed to `this_work_item` and it is no longer in the experimental namespace.
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Outdated
Show resolved
Hide resolved
SYCL language support on the part of the kernel_compiler is specified here: #11985 However, that specification is not presently realizable. We need more support from the FE and post link tool to get the demangled names propagated through. But it is usable before that, with constraints about using extern "C" or knowing the mangled kernel name. We have folk that want to test in the interim. I've refrained from updating the spec, and instead this interim support in our experimental extension will be snuck in until it can be completed in full - then we'll update the spec to release it properly.
Clarify that the _Name_ from an `include_files` entry could contain directory components.
This pull request is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be automatically closed in 30 days. |
This PR adds full support for the `registered_kernel_names` property to query kernels by their souce code name (and instantiate template kernels), leveraging the new `[[__sycl_detail__::__registered_kernels__(...)]]` attribute added in #16485 and #16821. Also, `kernel_bundle::ext_oneapi_get_raw_kernel_name` is implemented following the draft spec #11985. --------- Signed-off-by: Julian Oppermann <julian.oppermann@codeplay.com>
Merging this extension, as the core functionality is implemented now that #17032 has been merged. Smaller tweaks to API naming and implementation-specific notes will be added through follow-up PRs. |
Update the proposed specification for the kernel compiler to allow
kernels to be written in the SYCL language, using the new proposed
"free function kernel" format.
This PR also adds some more features to the kernel compiler for
parity with cuda's nvrtc.