157157----
158158class device {
159159
160+ bool ext_oneapi_can_build(ext::oneapi::experimental::source_language lang);
161+
162+ };
163+ ----
164+ !====
165+
166+ _Returns:_ The value `true` only if the device supports the
167+ `ext::oneapi::experimental::build` function on kernel bundles written in the
168+ source language `lang`.
169+
170+ a|
171+ [frame=all,grid=none]
172+ !====
173+ a!
174+ [source,c++]
175+ ----
176+ class device {
177+
160178bool ext_oneapi_can_compile(ext::oneapi::experimental::source_language lang);
161179
162180};
163181----
164182!====
165183
166- _Returns:_ The value `true` only if the device supports kernel bundles written
167- in the source language `lang`.
184+ _Returns:_ The value `true` only if the device supports the
185+ `ext::oneapi::experimental::compile` function on kernel bundles written in the
186+ source language `lang`.
187+
168188|====
169189
170190=== New free functions to create and build kernel bundles
@@ -226,8 +246,6 @@ state.
226246
227247_Throws:_
228248
229- * An `exception` with the `errc::invalid` error code if the source language
230- `lang` is not supported by any device contained by the context `ctxt`.
231249* An `exception` with the `errc::invalid` error code if the source language
232250 `lang` does not support one of the properties in `PropertyListT`.
233251* Overload (1) throws an `exception` with the `errc::invalid` error code if the
@@ -241,9 +259,11 @@ function.
241259
242260This function succeeds even if some devices in `ctxt` do not support the source
243261language `lang`.
244- However, the `build` function fails unless _all_ of its devices support `lang`.
245- Therefore, applications should take care to omit devices that do not support
246- `lang` when calling `build`.
262+ However, the `build` and `compile` functions will fail if any of its devices
263+ return `false` for `ext_oneapi_can_build(lang)` and
264+ `ext_oneapi_can_compile(lang)` respectively. Therefore, applications should take
265+ care to omit devices that do not support `lang` for the functions they intend on
266+ calling.
247267_{endnote}_]
248268
249269a|
@@ -271,8 +291,8 @@ kernel_bundle<bundle_state::executable> build(
271291
272292_Constraints:_ Available only when `PropertyListT` is an instance of
273293`sycl::ext::oneapi::experimental::properties` which contains no properties
274- other than those listed below in the section "New properties for the `build`
275- function ".
294+ other than those listed below in the section "New properties for the `build` and
295+ `compile` functions ".
276296
277297_Effects (1):_ The source code from `sourceBundle` is translated into one or more
278298device images of state `bundle_state::executable`, and a new kernel bundle is
@@ -293,16 +313,16 @@ _Returns:_ The newly created kernel bundle, which has `executable` state.
293313_Throws:_
294314
295315* An `exception` with the `errc::invalid` error code if any of the devices in
296- `devs` is not contained by the context associated with `sourceBundle`.
316+ `devs` return `false` for `ext_oneapi_can_build` with the source language of
317+ `sourceBundle`.
297318
298319* An `exception` with the `errc::invalid` error code if any of the devices in
299- `devs` does not support compilation of kernels in the source language of
300- `sourceBundle`.
320+ `devs` is not contained by the context associated with `sourceBundle`.
301321
302322* An `exception` with the `errc::invalid` error code if the source language
303323 `lang` does not support one of the properties in `PropertyListT` or if
304324 `props` contains a `build_options` property that contains an option that is
305- not supported by `lang`.
325+ not supported when building `lang`.
306326
307327* An `exception` with the `errc::build` error code if the compilation or
308328 linking operations fail.
@@ -317,6 +337,78 @@ source code used to create the kernel bundle being printed to the terminal.
317337In situations where this is undesirable, developers must ensure that the
318338exception is caught and handled appropriately.
319339_{endnote}_]
340+
341+ a|
342+ [frame=all,grid=none]
343+ !====
344+ a!
345+ [source]
346+ ----
347+ namespace sycl::ext::oneapi::experimental {
348+
349+ template<typename PropertyListT = empty_properties_t> (1)
350+ kernel_bundle<bundle_state::object> compile(
351+ const kernel_bundle<bundle_state::ext_oneapi_source>& sourceBundle,
352+ const std::vector<device>& devs, PropertyListT props={})
353+
354+ template<typename PropertyListT = empty_properties_t> (2)
355+ kernel_bundle<bundle_state::object> compile(
356+ const kernel_bundle<bundle_state::ext_oneapi_source>& sourceBundle,
357+ PropertyListT props = {})
358+
359+ } // namespace sycl::ext::oneapi::experimental
360+ ----
361+ !====
362+
363+
364+ _Constraints:_ Available only when `PropertyListT` is an instance of
365+ `sycl::ext::oneapi::experimental::properties` which contains no properties
366+ other than those listed below in the section "New properties for the `build` and
367+ `compile` functions".
368+
369+ _Effects (1):_ The source code from `sourceBundle` is translated into one or
370+ more device images of state `bundle_state::object`, and a new kernel bundle is
371+ created to contain these device images.
372+ The new bundle represents all of the kernels in `sourceBundle` that are
373+ compatible with at least one of the devices in `devs`.
374+ Any remaining kernels (those that are not compatible with any of the devices in
375+ `devs`) are not represented in the new kernel bundle.
376+
377+ The new bundle has the same associated context as `sourceBundle`, and the new
378+ bundle's set of associated devices is `devs` (with duplicate devices removed).
379+
380+ _Effects (2)_: Equivalent to
381+ `compile(sourceBundle, sourceBundle.get_devices(), props)`.
382+
383+ _Returns:_ The newly created kernel bundle, which has `object` state.
384+
385+ _Throws:_
386+
387+ * An `exception` with the `errc::invalid` error code if any of the devices in
388+ `devs` return `false` for `ext_oneapi_can_compile` with the source language of
389+ `sourceBundle`.
390+
391+ * An `exception` with the `errc::invalid` error code if any of the devices in
392+ `devs` is not contained by the context associated with `sourceBundle`.
393+
394+ * An `exception` with the `errc::invalid` error code if the source language
395+ `lang` does not support one of the properties in `PropertyListT` or if
396+ `props` contains a `build_options` property that contains an option that is
397+ not supported when compiling `lang`.
398+
399+ * An `exception` with the `errc::build` error code if the compilation operation
400+ fails. In this case, the exception `what` string provides a full build log,
401+ including descriptions of any errors, warning messages, and other
402+ diagnostics.
403+ This string is intended for human consumption, and the format may not be
404+ stable across implementations of this extension.
405+
406+ [_Note:_ An uncaught `errc::build` exception may result in some or all of the
407+ source code used to create the kernel bundle being printed to the terminal.
408+ In situations where this is undesirable, developers must ensure that the
409+ exception is caught and handled appropriately.
410+ _{endnote}_]
411+
320412|====
321413
322414=== New properties for the `create_kernel_bundle_from_source` function
@@ -384,10 +476,10 @@ _Throws (3):_
384476 entry with `name` in this property.
385477|====
386478
387- === New properties for the `build` function
479+ === New properties for the `build` and `compile` functions
388480
389481This extension adds the following properties, which can be used in conjunction
390- with the `build` function that is defined above:
482+ with the `build` and `compile` function that is defined above:
391483
392484|====
393485a|
0 commit comments