|
8 | 8 |
|
9 | 9 | #pragma once |
10 | 10 |
|
| 11 | +#include <sycl/ext/oneapi/experimental/syclbin_properties.hpp> |
11 | 12 | #include <sycl/ext/oneapi/properties/properties.hpp> |
12 | 13 | #include <sycl/kernel_bundle.hpp> |
13 | 14 |
|
|
24 | 25 |
|
25 | 26 | namespace sycl { |
26 | 27 | inline namespace _V1 { |
| 28 | + |
| 29 | +namespace detail { |
| 30 | +__SYCL_EXPORT std::shared_ptr<detail::kernel_bundle_impl> |
| 31 | +link_impl(const std::vector<kernel_bundle<bundle_state::object>> &ObjectBundles, |
| 32 | + const std::vector<device> &Devs, bool FastLink); |
| 33 | +} |
| 34 | + |
27 | 35 | namespace ext::oneapi::experimental { |
28 | 36 |
|
29 | 37 | template <bundle_state State, typename PropertyListT = empty_properties_t> |
@@ -77,6 +85,58 @@ get_kernel_bundle(const context &Ctxt, const std::filesystem::path &Filename, |
77 | 85 | } |
78 | 86 | #endif |
79 | 87 |
|
| 88 | +template <typename PropertyListT = empty_properties_t, |
| 89 | + typename = std::enable_if_t<detail::all_are_properties_of_v< |
| 90 | + sycl::detail::link_props, PropertyListT>>> |
| 91 | +kernel_bundle<bundle_state::executable> |
| 92 | +link(const std::vector<kernel_bundle<bundle_state::object>> &ObjectBundles, |
| 93 | + const std::vector<device> &Devs, PropertyListT Props = {}) { |
| 94 | + std::vector<device> UniqueDevices = |
| 95 | + sycl::detail::removeDuplicateDevices(Devs); |
| 96 | + |
| 97 | + bool UseFastLink = [&]() { |
| 98 | + if constexpr (Props.template has_property<fast_link>()) |
| 99 | + return Props.template get_property<fast_link>().value; |
| 100 | + return false; |
| 101 | + }(); |
| 102 | + |
| 103 | + sycl::detail::KernelBundleImplPtr Impl = |
| 104 | + sycl::detail::link_impl(ObjectBundles, UniqueDevices, UseFastLink); |
| 105 | + return detail::createSyclObjFromImpl< |
| 106 | + kernel_bundle<sycl::bundle_state::executable>>(std::move(Impl)); |
| 107 | +} |
| 108 | + |
| 109 | +template <typename PropertyListT = empty_properties_t, |
| 110 | + typename = std::enable_if_t<detail::all_are_properties_of_v< |
| 111 | + sycl::detail::link_props, PropertyListT>>> |
| 112 | +kernel_bundle<bundle_state::executable> |
| 113 | +link(const kernel_bundle<bundle_state::object> &ObjectBundle, |
| 114 | + const std::vector<device> &Devs, PropertyListT Props = {}) { |
| 115 | + return link(std::vector<kernel_bundle<bundle_state::object>>{ObjectBundle}, |
| 116 | + Devs, Props); |
| 117 | +} |
| 118 | + |
| 119 | +template <typename PropertyListT = empty_properties_t, |
| 120 | + typename = std::enable_if_t<detail::all_are_properties_of_v< |
| 121 | + sycl::detail::link_props, PropertyListT>>> |
| 122 | +kernel_bundle<bundle_state::executable> |
| 123 | +link(const std::vector<kernel_bundle<bundle_state::object>> &ObjectBundles, |
| 124 | + PropertyListT Props = {}) { |
| 125 | + std::vector<sycl::device> IntersectDevices = |
| 126 | + sycl::detail::find_device_intersection(ObjectBundles); |
| 127 | + return link(ObjectBundles, IntersectDevices, Props); |
| 128 | +} |
| 129 | + |
| 130 | +template <typename PropertyListT = empty_properties_t, |
| 131 | + typename = std::enable_if_t<detail::all_are_properties_of_v< |
| 132 | + sycl::detail::link_props, PropertyListT>>> |
| 133 | +kernel_bundle<bundle_state::executable> |
| 134 | +link(const kernel_bundle<bundle_state::object> &ObjectBundle, |
| 135 | + PropertyListT Props = {}) { |
| 136 | + return link(std::vector<kernel_bundle<bundle_state::object>>{ObjectBundle}, |
| 137 | + ObjectBundle.get_devices(), Props); |
| 138 | +} |
| 139 | + |
80 | 140 | } // namespace ext::oneapi::experimental |
81 | 141 | } // namespace _V1 |
82 | 142 | } // namespace sycl |
0 commit comments