@@ -242,3 +242,142 @@ _{endnote}_]
242242
243243|====
244244
245+ === New free function for linking
246+
247+ This extension adds the following new free functions to create and build a
248+ kernel bundle in `ext_oneapi_source` state.
249+
250+ |====
251+ a|
252+ [frame=all,grid=none]
253+ !====
254+ a!
255+ [source,c++]
256+ ----
257+ namespace sycl::ext::oneapi::experimental {
258+
259+ template<typename PropertyListT = empty_properties_t>
260+ kernel_bundle<bundle_state::executable>
261+ link(const std::vector<kernel_bundle<bundle_state::object>>& objectBundles,
262+ const std::vector<device>& devs, PropertyListT props = {});
263+
264+ } // namespace sycl::ext::oneapi::experimental
265+ ----
266+ !====
267+
268+ _Constraints:_ Available only when `PropertyListT` is an instance of
269+ `sycl::ext::oneapi::experimental::properties` which contains no properties
270+ other than those listed below in the section "New properties for the
271+ `link` function".
272+
273+ _Effects:_ Duplicate device images from `objectBundles` are eliminated as though
274+ they were joined via `join()`, then the remaining device images are translated
275+ into one or more new device images of state `bundle_state::executable`, and a
276+ new kernel bundle is created to contain these new device images. The new bundle
277+ represents all of the kernels in `objectBundles` that are compatible with at
278+ least one of the devices in `devs`. Any remaining kernels (those that are not
279+ compatible with any of the devices in `devs`) are not linked and not represented
280+ in the new bundle.
281+
282+ The new bundle has the same associated context as those in `objectBundles`, and
283+ the new bundle’s set of associated devices is `devs` (with duplicate devices
284+ removed).
285+
286+ _Returns:_ The new kernel bundle.
287+
288+ _Throws:_
289+
290+ * An `exception` with the `errc::invalid` error code if the bundles in
291+ `objectBundles` do not all have the same associated context.
292+
293+ * An `exception` with the `errc::invalid` error code if any of the devices in
294+ `devs` are not in the set of associated devices for any of the bundles in
295+ `objectBundles` (as defined by `kernel_bundle::get_devices()`) or if the `devs`
296+ vector is empty.
297+
298+ * An `exception` with the `errc::build` error code if the online link operation
299+ fails.
300+
301+
302+ a|
303+ [frame=all,grid=none]
304+ !====
305+ a!
306+ [source]
307+ ----
308+
309+ namespace sycl::ext::oneapi::experimental {
310+
311+ template<typename PropertyListT = empty_properties_t> (1)
312+ kernel_bundle<bundle_state::executable>
313+ link(const kernel_bundle<bundle_state::object>& objectBundle,
314+ const std::vector<device>& devs, PropertyListT props = {});
315+
316+ template<typename PropertyListT = empty_properties_t> (2)
317+ kernel_bundle<bundle_state::executable>
318+ link(const std::vector<kernel_bundle<bundle_state::object>>& objectBundles,
319+ PropertyListT props = {});
320+
321+ template<typename PropertyListT = empty_properties_t> (3)
322+ kernel_bundle<bundle_state::executable>
323+ link(const kernel_bundle<bundle_state::object>& objectBundle,
324+ PropertyListT props = {});
325+
326+ } // namespace sycl::ext::oneapi::experimental
327+ ----
328+ !====
329+
330+ _Effects (1):_ Equivalent to `link({objectBundle}, devs, props)`.
331+
332+ _Effects (2):_ Equivalent to `link(objectBundles, devs, props)`, where `devs` is
333+ the intersection of associated devices in common for all bundles in
334+ `objectBundles`.
335+
336+ _Effects (3):_ Equivalent to
337+ `link({objectBundle}, objectBundle.get_devices(), props)`.
338+
339+
340+ |====
341+
342+ === New properties for the `link` function
343+
344+ This extension adds the following properties, which can be used in conjunction
345+ with the `link` function that is defined above:
346+
347+ |====
348+ a|
349+ [frame=all,grid=none]
350+ !====
351+ a!
352+ [source,c++]
353+ ----
354+ namespace sycl::ext::oneapi::experimental {
355+
356+ struct fast_link {
357+ fast_link(bool do_fast_link = true); (1)
358+
359+ bool value;
360+ };
361+ using fast_link_key = fast_link;
362+
363+ template<> struct is_property_key<fast_link_key> : std::true_type {};
364+
365+ } // namespace sycl::ext::oneapi::experimental
366+ ----
367+ !====
368+
369+ This property instructs the `link` operation to do "fast linking". Enabling this
370+ instructs the implementation to use device binary images that have been
371+ pre-compiled.
372+
373+ For example, SYCLBIN files may contain ahead-of-time compiled binary images
374+ together with just-in-time compiled binary images, with the kernels and exported
375+ functions potentially overlapping. When fast-linking is enabled, the
376+ implementation will try to use the ahead-of-time compiled binary images over
377+ their just-in-time compiled counterparts.
378+
379+ _Effects (1):_ Creates a new `fast_link` property with a boolean value
380+ indicating whether the `link` operation should do fast-linking.
381+
382+ |====
383+
0 commit comments