-
Notifications
You must be signed in to change notification settings - Fork 794
[SYCL] Add fast-link option for SYCLBIN #20174
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
6fe8e6b
7111c47
30017be
cc75ee8
0d62963
1400a6d
81987ad
638aa48
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 |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
|
|
||
| #pragma once | ||
|
|
||
| #include <sycl/ext/oneapi/experimental/syclbin_properties.hpp> | ||
| #include <sycl/ext/oneapi/properties/properties.hpp> | ||
| #include <sycl/kernel_bundle.hpp> | ||
|
|
||
|
|
@@ -24,6 +25,39 @@ | |
|
|
||
| namespace sycl { | ||
| inline namespace _V1 { | ||
|
|
||
| namespace detail { | ||
| __SYCL_EXPORT std::shared_ptr<detail::kernel_bundle_impl> | ||
| link_impl(const kernel_bundle<bundle_state::object> *ObjectBundles, | ||
| size_t NumObjectBundles, const std::vector<device> &Devs, | ||
| bool FastLink); | ||
|
|
||
| template < | ||
| typename PropertyListT = ext::oneapi::experimental::empty_properties_t, | ||
| typename = std::enable_if_t< | ||
| ext::oneapi::experimental::detail::all_are_properties_of_v< | ||
| ext::oneapi::experimental::detail::link_props, PropertyListT>>> | ||
| kernel_bundle<bundle_state::executable> | ||
| link_common(const kernel_bundle<bundle_state::object> *ObjectBundles, | ||
| size_t NumObjectBundles, const std::vector<device> &Devs, | ||
| PropertyListT Props = {}) { | ||
| std::vector<device> UniqueDevices = removeDuplicateDevices(Devs); | ||
|
|
||
| bool UseFastLink = [&]() { | ||
| if constexpr (Props.template has_property< | ||
| ext::oneapi::experimental::fast_link>()) | ||
| return Props.template get_property<ext::oneapi::experimental::fast_link>() | ||
| .value; | ||
| return false; | ||
| }(); | ||
|
|
||
| KernelBundleImplPtr Impl = | ||
| link_impl(ObjectBundles, NumObjectBundles, UniqueDevices, UseFastLink); | ||
| return createSyclObjFromImpl<kernel_bundle<bundle_state::executable>>( | ||
| std::move(Impl)); | ||
|
Comment on lines
+56
to
+57
Contributor
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. Any particular reason to do this here instead of inside
Contributor
Author
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. The function is templated, so we can't move all of
Contributor
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.
Yes, I think most of ABI interfaces should operate in terms of real SYCL objects. |
||
| } | ||
| } // namespace detail | ||
|
|
||
| namespace ext::oneapi::experimental { | ||
|
|
||
| template <bundle_state State, typename PropertyListT = empty_properties_t> | ||
|
|
@@ -77,6 +111,46 @@ get_kernel_bundle(const context &Ctxt, const std::filesystem::path &Filename, | |
| } | ||
| #endif | ||
|
|
||
| template <typename PropertyListT = empty_properties_t, | ||
| typename = std::enable_if_t<detail::all_are_properties_of_v< | ||
| sycl::detail::link_props, PropertyListT>>> | ||
| kernel_bundle<bundle_state::executable> | ||
| link(const std::vector<kernel_bundle<bundle_state::object>> &ObjectBundles, | ||
| const std::vector<device> &Devs, PropertyListT Props = {}) { | ||
| return sycl::detail::link_common(ObjectBundles.data(), ObjectBundles.size(), | ||
| Devs, Props); | ||
| } | ||
|
|
||
| template <typename PropertyListT = empty_properties_t, | ||
| typename = std::enable_if_t<detail::all_are_properties_of_v< | ||
| sycl::detail::link_props, PropertyListT>>> | ||
| kernel_bundle<bundle_state::executable> | ||
| link(const kernel_bundle<bundle_state::object> &ObjectBundle, | ||
| const std::vector<device> &Devs, PropertyListT Props = {}) { | ||
| return sycl::detail::link_common(&ObjectBundle, 1, Devs, Props); | ||
| } | ||
|
|
||
| template <typename PropertyListT = empty_properties_t, | ||
| typename = std::enable_if_t<detail::all_are_properties_of_v< | ||
| sycl::detail::link_props, PropertyListT>>> | ||
| kernel_bundle<bundle_state::executable> | ||
| link(const std::vector<kernel_bundle<bundle_state::object>> &ObjectBundles, | ||
| PropertyListT Props = {}) { | ||
| std::vector<sycl::device> IntersectDevices = | ||
| sycl::detail::find_device_intersection(ObjectBundles); | ||
| return link(ObjectBundles, IntersectDevices, Props); | ||
| } | ||
|
|
||
| template <typename PropertyListT = empty_properties_t, | ||
| typename = std::enable_if_t<detail::all_are_properties_of_v< | ||
| sycl::detail::link_props, PropertyListT>>> | ||
| kernel_bundle<bundle_state::executable> | ||
| link(const kernel_bundle<bundle_state::object> &ObjectBundle, | ||
| PropertyListT Props = {}) { | ||
| return link(std::vector<kernel_bundle<bundle_state::object>>{ObjectBundle}, | ||
| ObjectBundle.get_devices(), Props); | ||
| } | ||
|
|
||
| } // namespace ext::oneapi::experimental | ||
| } // namespace _V1 | ||
| } // namespace sycl | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,39 @@ | ||||||
| //==-------- syclbin_properties.hpp - SYCLBIN and tooling properties -------==// | ||||||
|
Contributor
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. AFAIK, this part of the style guide has been dropped (having file name present in the very first line).
Contributor
Author
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. Do you mean it should be
Suggested change
or should the header be dropped entirely?
Contributor
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 think it's usually //==-----------------------------------------------------------------------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
/// \file <Description>
///or something like that now. |
||||||
| // | ||||||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||||
| // See https://llvm.org/LICENSE.txt for license information. | ||||||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||||
| // | ||||||
| //===----------------------------------------------------------------------===// | ||||||
|
|
||||||
| #pragma once | ||||||
|
|
||||||
| #include <sycl/ext/oneapi/properties/properties.hpp> | ||||||
| #include <sycl/kernel_bundle.hpp> | ||||||
|
|
||||||
| namespace sycl { | ||||||
| inline namespace _V1 { | ||||||
|
|
||||||
| namespace detail { | ||||||
| struct link_props; | ||||||
| } // namespace detail | ||||||
|
|
||||||
| namespace ext::oneapi::experimental { | ||||||
|
|
||||||
| ///////////////////////// | ||||||
| // PropertyT syclex::fast_link | ||||||
| ///////////////////////// | ||||||
| struct fast_link | ||||||
| : detail::run_time_property_key<fast_link, detail::PropKind::FastLink> { | ||||||
| fast_link(bool DoFastLink = true) : value(DoFastLink) {} | ||||||
|
|
||||||
| bool value; | ||||||
| }; | ||||||
| using fast_link_key = fast_link; | ||||||
|
|
||||||
| template <> | ||||||
| struct is_property_key_of<fast_link_key, sycl::detail::link_props> | ||||||
| : std::true_type {}; | ||||||
| } // namespace ext::oneapi::experimental | ||||||
| } // namespace _V1 | ||||||
| } // namespace sycl | ||||||
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.
Do we need to throw an exception if size is zero?