157
157
----
158
158
class device {
159
159
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
+
160
178
bool ext_oneapi_can_compile(ext::oneapi::experimental::source_language lang);
161
179
162
180
};
163
181
----
164
182
!====
165
183
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
+
168
188
|====
169
189
170
190
=== New free functions to create and build kernel bundles
@@ -226,8 +246,6 @@ state.
226
246
227
247
_Throws:_
228
248
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`.
231
249
* An `exception` with the `errc::invalid` error code if the source language
232
250
`lang` does not support one of the properties in `PropertyListT`.
233
251
* Overload (1) throws an `exception` with the `errc::invalid` error code if the
@@ -241,9 +259,11 @@ function.
241
259
242
260
This function succeeds even if some devices in `ctxt` do not support the source
243
261
language `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.
247
267
_{endnote}_]
248
268
249
269
a|
@@ -271,8 +291,8 @@ kernel_bundle<bundle_state::executable> build(
271
291
272
292
_Constraints:_ Available only when `PropertyListT` is an instance of
273
293
`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 ".
276
296
277
297
_Effects (1):_ The source code from `sourceBundle` is translated into one or more
278
298
device 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.
293
313
_Throws:_
294
314
295
315
* 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`.
297
318
298
319
* 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`.
301
321
302
322
* An `exception` with the `errc::invalid` error code if the source language
303
323
`lang` does not support one of the properties in `PropertyListT` or if
304
324
`props` contains a `build_options` property that contains an option that is
305
- not supported by `lang`.
325
+ not supported when building `lang`.
306
326
307
327
* An `exception` with the `errc::build` error code if the compilation or
308
328
linking operations fail.
@@ -317,6 +337,78 @@ source code used to create the kernel bundle being printed to the terminal.
317
337
In situations where this is undesirable, developers must ensure that the
318
338
exception is caught and handled appropriately.
319
339
_{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
+
320
412
|====
321
413
322
414
=== New properties for the `create_kernel_bundle_from_source` function
@@ -384,10 +476,10 @@ _Throws (3):_
384
476
entry with `name` in this property.
385
477
|====
386
478
387
- === New properties for the `build` function
479
+ === New properties for the `build` and `compile` functions
388
480
389
481
This 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:
391
483
392
484
|====
393
485
a|
0 commit comments