-
Notifications
You must be signed in to change notification settings - Fork 16.2k
[SYCL] Add platform enumeration and info query using liboffload #166927
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
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
f6c7d92
[SYCL] Add platform enumeration and info query using liboffload (#2)
KseniyaTikhomirova 6d4d748
add partial spec and base for std::hash support
KseniyaTikhomirova 32e352f
fix comments
KseniyaTikhomirova 0dab958
early init of platforms
KseniyaTikhomirova 17004f9
remove unique_ptr, make ref const, add operator==
KseniyaTikhomirova 3a00063
fix installation
KseniyaTikhomirova dd8603f
fix format
KseniyaTikhomirova e10d953
remove offload codes from distributed headers
KseniyaTikhomirova ec9f858
change ref to impl to raw ptr
KseniyaTikhomirova c4d78c5
add asserts for impl
KseniyaTikhomirova cdb9dc1
apply proposed impl of get_info
KseniyaTikhomirova 5ef2ccc
fix leftover of base class impl w/o friend funcs
KseniyaTikhomirova 1c8fbaa
fix comments
KseniyaTikhomirova 0da4c95
remove file common.hpp
KseniyaTikhomirova 3a7367b
fix code-review comments
KseniyaTikhomirova 02b8db9
fix more comments
KseniyaTikhomirova 6fb819c
fix doc
KseniyaTikhomirova d6e34e1
fix comments
KseniyaTikhomirova 605ac55
remove device macro from hash impl
KseniyaTikhomirova 3bd9d15
remove from backend enum
KseniyaTikhomirova a3d8ea6
fix comments
KseniyaTikhomirova 315c7af
fix comments
KseniyaTikhomirova 9c2cf16
align style
KseniyaTikhomirova 3f78ff9
enable l0
KseniyaTikhomirova be62545
return get_backend_info declaration
KseniyaTikhomirova 1ca2ca6
fix comments
KseniyaTikhomirova 2767396
fix last comments
KseniyaTikhomirova 5944913
Merge branch 'main' into add_get_platforms
KseniyaTikhomirova 9f24a18
fix assert text
KseniyaTikhomirova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // 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 | ||
| /// This file contains the declaration of the SYCL enum class backend that is | ||
| /// implementation-defined and is populated with a unique identifier for each | ||
| /// SYCL backend that the SYCL implementation can support. | ||
| /// | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef _LIBSYCL___IMPL_BACKEND_HPP | ||
| #define _LIBSYCL___IMPL_BACKEND_HPP | ||
|
|
||
| #include <sycl/__impl/detail/config.hpp> | ||
|
|
||
| #include <string_view> | ||
| #include <type_traits> | ||
|
|
||
| _LIBSYCL_BEGIN_NAMESPACE_SYCL | ||
|
|
||
| // SYCL 2020 4.1. Backends. | ||
| enum class backend : unsigned char { | ||
| opencl = 0, | ||
| level_zero, | ||
| cuda, | ||
| hip, | ||
| }; | ||
|
|
||
| namespace detail { | ||
| template <typename T> struct is_backend_info_desc : std::false_type {}; | ||
| } // namespace detail | ||
tahonermann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // SYCL 2020 4.5.1.1. Type traits backend_traits. | ||
| template <backend Backend> class backend_traits; | ||
|
|
||
| template <backend Backend, typename SyclType> | ||
| using backend_input_t = | ||
| typename backend_traits<Backend>::template input_type<SyclType>; | ||
| template <backend Backend, typename SyclType> | ||
| using backend_return_t = | ||
| typename backend_traits<Backend>::template return_type<SyclType>; | ||
|
|
||
| _LIBSYCL_END_NAMESPACE_SYCL | ||
|
|
||
| #endif // _LIBSYCL___IMPL_BACKEND_HPP | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // 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 | ||
| /// This file contains helper functions used to navigate between SYCL interface | ||
| /// objects and their corresponding implementation objects. | ||
| /// | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef _LIBSYCL___IMPL_DETAIL_OBJ_UTILS_HPP | ||
| #define _LIBSYCL___IMPL_DETAIL_OBJ_UTILS_HPP | ||
|
|
||
| #include <sycl/__impl/detail/config.hpp> | ||
|
|
||
| #include <cassert> | ||
| #include <memory> | ||
| #include <optional> | ||
| #include <type_traits> | ||
| #include <utility> | ||
|
|
||
| _LIBSYCL_BEGIN_NAMESPACE_SYCL | ||
|
|
||
| namespace detail { | ||
|
|
||
| // SYCL interface classes are required to contain an `impl` data member | ||
| // which points to the corresponding implementation object. The data | ||
| // member is required to be accessible by the `ImpUtils` class. SYCL | ||
| // interface classes that declare the data member private or protected | ||
| // are required to befriend the `ImpUtils` class. | ||
| struct ImplUtils { | ||
| // Helper function to access an implementation object from a SYCL interface | ||
| // object. | ||
| template <typename SyclObject> | ||
| static const decltype(SyclObject::impl) & | ||
| getSyclObjImpl(const SyclObject &Obj) { | ||
| assert(Obj.impl && "every constructor should create an impl"); | ||
| return Obj.impl; | ||
| } | ||
|
|
||
| // Helper function to create a SYCL interface object from an implementation. | ||
| template <typename SyclObject, typename Impl> | ||
| static SyclObject createSyclObjFromImpl(Impl &&ImplObj) { | ||
| if constexpr (std::is_same_v<decltype(SyclObject::impl), | ||
| std::shared_ptr<std::decay_t<Impl>>>) | ||
| return SyclObject{ImplObj.shared_from_this()}; | ||
| else | ||
| return SyclObject{std::forward<Impl>(ImplObj)}; | ||
| } | ||
| }; | ||
|
|
||
| template <typename SyclObject> | ||
| auto getSyclObjImpl(const SyclObject &Obj) | ||
| -> decltype(ImplUtils::getSyclObjImpl(Obj)) { | ||
| return ImplUtils::getSyclObjImpl(Obj); | ||
| } | ||
|
|
||
| template <typename SyclObject, typename Impl> | ||
| SyclObject createSyclObjFromImpl(Impl &&ImplObj) { | ||
| return ImplUtils::createSyclObjFromImpl<SyclObject>( | ||
| std::forward<Impl>(ImplObj)); | ||
| } | ||
|
|
||
| // SYCL 2020 4.5.2. Common reference semantics (std::hash support). | ||
| template <typename T> struct HashBase { | ||
| size_t operator()(const T &Obj) const { | ||
| auto &Impl = sycl::detail::getSyclObjImpl(Obj); | ||
| return std::hash<std::decay_t<decltype(Impl)>>{}(Impl); | ||
| } | ||
| }; | ||
|
|
||
| } // namespace detail | ||
|
|
||
| _LIBSYCL_END_NAMESPACE_SYCL | ||
|
|
||
| #endif // _LIBSYCL___IMPL_DETAIL_OBJ_UTILS_HPP |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.