-
Notifications
You must be signed in to change notification settings - Fork 765
[SYCL][Docs] Implement compile and link for source-based kernel bundles #17442
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
base: sycl
Are you sure you want to change the base?
Changes from all commits
70be072
419929a
147cb3d
7fc5202
4ef1ce4
14b44c4
3592e0d
18a0310
5472cc9
3d5ef96
a7d51ce
6d7a894
6bb6050
d947479
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -271,8 +271,8 @@ kernel_bundle<bundle_state::executable> build( | |
|
||
_Constraints:_ Available only when `PropertyListT` is an instance of | ||
`sycl::ext::oneapi::experimental::properties` which contains no properties | ||
other than those listed below in the section "New properties for the `build` | ||
function". | ||
other than those listed below in the section "New properties for the `build` and | ||
`compile` functions". | ||
|
||
_Effects (1):_ The source code from `sourceBundle` is translated into one or more | ||
device images of state `bundle_state::executable`, and a new kernel bundle is | ||
|
@@ -317,6 +317,80 @@ source code used to create the kernel bundle being printed to the terminal. | |
In situations where this is undesirable, developers must ensure that the | ||
exception is caught and handled appropriately. | ||
_{endnote}_] | ||
|
||
a| | ||
[frame=all,grid=none] | ||
!==== | ||
a! | ||
[source] | ||
---- | ||
namespace sycl::ext::oneapi::experimental { | ||
|
||
template<typename PropertyListT = empty_properties_t> (1) | ||
kernel_bundle<bundle_state::object> compile( | ||
const kernel_bundle<bundle_state::ext_oneapi_source>& sourceBundle, | ||
const std::vector<device>& devs, PropertyListT props={}) | ||
|
||
template<typename PropertyListT = empty_properties_t> (2) | ||
kernel_bundle<bundle_state::object> compile( | ||
const kernel_bundle<bundle_state::ext_oneapi_source>& sourceBundle, | ||
PropertyListT props = {}) | ||
steffenlarsen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
} // namespace sycl::ext::oneapi::experimental | ||
---- | ||
!==== | ||
|
||
|
||
_Constraints:_ Available only when `PropertyListT` is an instance of | ||
`sycl::ext::oneapi::experimental::properties` which contains no properties | ||
other than those listed below in the section "New properties for the `build` and | ||
`compile` functions". | ||
|
||
_Effects (1):_ The source code from `sourceBundle` is translated into one or | ||
more device images of state `bundle_state::object`, and a new kernel bundle is | ||
created to contain these device images. | ||
The new bundle represents all of the kernels in `sourceBundle` that are | ||
compatible with at least one of the devices in `devs`. | ||
Any remaining kernels (those that are not compatible with any of the devices in | ||
`devs`) are not represented in the new kernel bundle. | ||
|
||
The new bundle has the same associated context as `sourceBundle`, and the new | ||
bundle's set of associated devices is `devs` (with duplicate devices removed). | ||
|
||
_Effects (2)_: Equivalent to | ||
`compile(sourceBundle, sourceBundle.get_devices(), props)`. | ||
|
||
_Returns:_ The newly created kernel bundle, which has `object` state. | ||
|
||
_Throws:_ | ||
|
||
* An `exception` with the `errc::invalid` error code if `source` was not created | ||
with `source_language::sycl` or was the result of `sycl::join` taking one or | ||
more `kernel_bundle` objects not created with `source_language::sycl`. | ||
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. There is no similar restriction for It seems weird to list the The whole business about 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.
I believe we could relax this restriction to allow compiling OpenCL, SPIR-V, etc, but by allowing these source languages in object state complicates the logic for linking a little, as we wouldn't know their imported/exported symbols. There are ways we could solve that, but since my focus was on SYCL RTC kernel bundles in this initial variant, I elected to disallow them for now.
I did not consider splitting
I'm still not sure it's necessarily that big a can of worms. I agree, the wording here is a little awkward because of there not currently being any restrictions on 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. I agree that it makes sense to support only SYCL for compilation at this point. In that case, I think we need to have a query that tells the application which source languages can be compiled. Let's repurpose I'm still not convinced about 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.
Sure!
I suppose my mental model for join doesn't append the sources, just like two |
||
|
||
* An `exception` with the `errc::invalid` error code if any of the devices in | ||
`devs` is not contained by the context associated with `sourceBundle`. | ||
|
||
* An `exception` with the `errc::invalid` error code if any of the devices in | ||
`devs` does not support compilation of kernels in the source language of | ||
`sourceBundle`. | ||
|
||
* An `exception` with the `errc::invalid` error code if `props` contains an | ||
`build_options` property that specifies an invalid option. | ||
|
||
* An `exception` with the `errc::build` error code if the compilation operation | ||
fails. In this case, the exception `what` string provides a full build log, | ||
including descriptions of any errors, warning messages, and other | ||
diagnostics. | ||
This string is intended for human consumption, and the format may not be | ||
stable across implementations of this extension. | ||
|
||
[_Note:_ An uncaught `errc::build` exception may result in some or all of the | ||
source code used to create the kernel bundle being printed to the terminal. | ||
In situations where this is undesirable, developers must ensure that the | ||
exception is caught and handled appropriately. | ||
_{endnote}_] | ||
|
||
|==== | ||
|
||
=== New properties for the `create_kernel_bundle_from_source` function | ||
|
@@ -384,10 +458,10 @@ _Throws (3):_ | |
entry with `name` in this property. | ||
|==== | ||
|
||
=== New properties for the `build` function | ||
=== New properties for the `build` and `compile` functions | ||
|
||
This extension adds the following properties, which can be used in conjunction | ||
with the `build` function that is defined above: | ||
with the `build` and `compile` function that is defined above: | ||
|
||
|==== | ||
a| | ||
|
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.
Please, describe a use-case that you want to cover.
This change looks controversial since the interface becomes sophisticated.
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 agree, I am not married to this solution, but it is a result of what I think is a bad design around the module splitter. That is, the module splitter isn't an independent tool, yet it defines its own option "allow-device-image-dependencies". As an alternative solution, I can move this option to the tools using it, i.e. sycl-post-link, sycl-module-split, clang-linker-wrapper and the SYCL kernel compiler. Thoughts?
If we agree, I can open a separate PR doing that. I figure it can be done neatly in separation.
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.
cl::opt<bool> AllowDeviceImageDependencies
can be removed and replaced by a member inModuleSplitterBase
class.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.
My thought exactly! Something like #18060?