forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
[SYCL] Add platform enumeration and info query using liboffload #1
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
Closed
Closed
Changes from 18 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
7981a31
enable standalone build
KseniyaTikhomirova ceb9e0a
add offload agnostic code
KseniyaTikhomirova f9d0203
Add the rest and fix the build; no liboffload integration here yet
KseniyaTikhomirova 971443e
add part related to offload integration
KseniyaTikhomirova 260e2b2
draft of sycl-ls
KseniyaTikhomirova 9ce8393
add get_info impl
KseniyaTikhomirova 08e6e2f
fix attributes
KseniyaTikhomirova 99f1f3c
update build cmdline
KseniyaTikhomirova ede48e7
change build output dir for sycl-ls
KseniyaTikhomirova 3abb743
fix my comments
KseniyaTikhomirova 9a3ca28
try to run WF
KseniyaTikhomirova f9913fd
remove extra job
KseniyaTikhomirova e5e1971
fix dirs
KseniyaTikhomirova 7de749a
remove shared_ptr for platform
KseniyaTikhomirova 73b92f1
runner can't build it, no space left on device, removing
KseniyaTikhomirova fce9a01
fix eof
KseniyaTikhomirova 0158005
format & extra include removal
KseniyaTikhomirova 38400c0
revert incorrect changes
KseniyaTikhomirova 7357f63
use llvmSupport for sycl-ls
KseniyaTikhomirova ed1507e
remove comments to includes and fix the order
KseniyaTikhomirova 9925ce3
remove dpcpp mentioning
KseniyaTikhomirova bf07166
remove comments from exception.hpp
KseniyaTikhomirova 715a33b
tiny extra cleanup in exception.hpp
KseniyaTikhomirova d530135
change call_once to plain static
KseniyaTikhomirova be62903
change comments in offload_topology.cpp
KseniyaTikhomirova 46baff0
fix comments in offload_topology.hpp
KseniyaTikhomirova ae6c2ef
remove unnecessary include file
KseniyaTikhomirova 4cfcb73
fix limitation description
KseniyaTikhomirova 570f4c3
fix comment
KseniyaTikhomirova 219c65a
fix more comments
KseniyaTikhomirova 44009a2
remove global_handler
KseniyaTikhomirova f02d2e0
remove range for index
KseniyaTikhomirova 9fb166d
return back array
KseniyaTikhomirova e584620
move impl stuff to base class
KseniyaTikhomirova f51c6df
remove index range
KseniyaTikhomirova 6986a69
change to ref
KseniyaTikhomirova 798d6d5
remove leftover from handler removal
KseniyaTikhomirova 1165274
fix comments related to style
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // 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 <string_view> | ||
| #include <sycl/__impl/detail/config.hpp> // namespace macro | ||
| #include <type_traits> // std::false_type | ||
|
|
||
| _LIBSYCL_BEGIN_NAMESPACE_SYCL | ||
|
|
||
| // 4.1. Backends | ||
| enum class backend : char { | ||
KseniyaTikhomirova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| opencl = 1, | ||
| level_zero = 2, | ||
| cuda = 3, | ||
| all = 4, | ||
| hip = 6, | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| namespace detail { | ||
| template <typename T> struct is_backend_info_desc : std::false_type {}; | ||
| } // namespace detail | ||
|
|
||
| // 4.5.1.1. Type traits backend_traits | ||
| template <backend Backend> class backend_traits; | ||
|
|
||
| template <backend Backend, typename SYCLObjectT> | ||
| using backend_input_t = | ||
| typename backend_traits<Backend>::template input_type<SYCLObjectT>; | ||
| template <backend Backend, typename SYCLObjectT> | ||
| using backend_return_t = | ||
| typename backend_traits<Backend>::template return_type<SYCLObjectT>; | ||
|
|
||
| namespace detail { | ||
| inline std::string_view get_backend_name(const backend &Backend) { | ||
| switch (Backend) { | ||
| case backend::opencl: | ||
| return "opencl"; | ||
| case backend::level_zero: | ||
| return "level_zero"; | ||
| case backend::cuda: | ||
| return "cuda"; | ||
| case backend::hip: | ||
| return "hip"; | ||
| case backend::all: | ||
| return "all"; | ||
| } | ||
|
|
||
| return ""; | ||
| } | ||
| } // namespace detail | ||
|
|
||
| _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,65 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // 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 for tranformation between implementation | ||
| /// and SYCL's interface objects. | ||
| /// | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef _LIBSYCL___IMPL_DETAIL_IMPL_UTILS_HPP | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #define _LIBSYCL___IMPL_DETAIL_IMPL_UTILS_HPP | ||
|
|
||
| #include <sycl/__impl/detail/config.hpp> // namespace macro | ||
|
|
||
| #include <cassert> // for assert | ||
| #include <type_traits> // for add_rvalue_reference_t and others | ||
| #include <utility> // for forward | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| _LIBSYCL_BEGIN_NAMESPACE_SYCL | ||
|
|
||
| namespace detail { | ||
|
|
||
| // Helper function for extracting implementation from SYCL's interface objects. | ||
| // Note! This function relies on the fact that all SYCL interface classes | ||
| // contain "impl" field that points to implementation object. "impl" field | ||
| // should be accessible from this function. | ||
| // | ||
| // Note that due to a bug in MSVC compilers (including MSVC2019 v19.20), it | ||
| // may not recognize the usage of this function in friend member declarations | ||
| // if the template parameter name there is not equal to the name used here, | ||
| // i.e. 'Obj'. For example, using 'Obj' here and 'T' in such declaration | ||
| // would trigger that error in MSVC: | ||
| // template <class T> | ||
| // friend decltype(T::impl) detail::getSyclObjImpl(const T &SyclObject); | ||
| template <class Obj> | ||
| const decltype(Obj::impl) &getSyclObjImpl(const Obj &SyclObject) { | ||
| assert(SyclObject.impl && "every constructor should create an impl"); | ||
| return SyclObject.impl; | ||
| } | ||
|
|
||
| // Helper function for creation SYCL interface objects from implementations. | ||
| // Note! These functions rely on the fact that all SYCL interface classes | ||
| // contain "impl" field that points to implementation object. "impl" field | ||
| // should be accessible from these functions. | ||
| template <class T> | ||
| T createSyclObjFromImpl( | ||
| std::add_rvalue_reference_t<decltype(T::impl)> ImplObj) { | ||
| return T(std::forward<decltype(ImplObj)>(ImplObj)); | ||
| } | ||
|
|
||
| template <class T> | ||
| T createSyclObjFromImpl( | ||
| std::add_lvalue_reference_t<const decltype(T::impl)> ImplObj) { | ||
| return T(ImplObj); | ||
| } | ||
|
|
||
| } // namespace detail | ||
| _LIBSYCL_END_NAMESPACE_SYCL | ||
|
|
||
| #endif // _LIBSYCL___IMPL_DETAIL_IMPL_UTILS_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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // 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 macro definitions used in SYCL implementation. | ||
| /// | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef _LIBSYCL___IMPL_DETAIL_MACRO_DEFINITIONS_HPP | ||
| #define _LIBSYCL___IMPL_DETAIL_MACRO_DEFINITIONS_HPP | ||
|
|
||
| #ifndef __SYCL2020_DEPRECATED | ||
KseniyaTikhomirova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # if SYCL_LANGUAGE_VERSION == 202012L && \ | ||
| !defined(SYCL2020_DISABLE_DEPRECATION_WARNINGS) | ||
| # define __SYCL2020_DEPRECATED(message) [[deprecated(message)]] | ||
| # else | ||
| # define __SYCL2020_DEPRECATED(message) | ||
| # endif | ||
| #endif // __SYCL2020_DEPRECATED | ||
|
|
||
| static_assert(__cplusplus >= 201703L, | ||
| "DPCPP does not support C++ version earlier than C++17."); | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| #if defined(_WIN32) && !defined(_DLL) && !defined(__SYCL_DEVICE_ONLY__) | ||
| // SYCL library is designed such a way that STL objects cross DLL boundary, | ||
| // which is guaranteed to work properly only when the application uses the same | ||
| // C++ runtime that SYCL library uses. | ||
| // The appplications using sycl.dll must be linked with dynamic/release C++ MSVC | ||
| // runtime, i.e. be compiled with /MD switch. Similarly, the applications using | ||
| // sycld.dll must be linked with dynamic/debug C++ runtime and be compiled with | ||
| // /MDd switch. | ||
| // Compiler automatically adds /MD or /MDd when -fsycl switch is used. | ||
| // The options /MD and /MDd that make the code to use dynamic runtime also | ||
| // define the _DLL macro. | ||
| # define ERROR_MESSAGE \ | ||
| "SYCL library is designed to work safely with dynamic C++ runtime." \ | ||
| "Please use /MD switch with sycl.dll, /MDd switch with sycld.dll, " \ | ||
| "or -fsycl switch to set C++ runtime automatically." | ||
| # if defined(_MSC_VER) | ||
| # pragma message(ERROR_MESSAGE) | ||
| # else | ||
| # warning ERROR_MESSAGE | ||
| # endif | ||
| # undef ERROR_MESSAGE | ||
| #endif // defined(_WIN32) && !defined(_DLL) && !defined(__SYCL_DEVICE_ONLY__) | ||
|
|
||
| #endif //_LIBSYCL___IMPL_DETAIL_MACRO_DEFINITIONS_HPP | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
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 helper class SpinLock. | ||
| /// SpinLock is a synchronization primitive, that uses atomic variable and | ||
| /// causes thread trying acquire lock wait in loop while repeatedly check if | ||
| /// the lock is available. | ||
| /// | ||
| /// One important feature of this implementation is that std::atomic<bool> can | ||
| /// be zero-initialized. This allows SpinLock to have trivial constructor and | ||
| /// destructor, which makes it possible to use it in global context (unlike | ||
| /// std::mutex, that doesn't provide such guarantees). | ||
| /// | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef _LIBSYCL___IMPL_SPINLOCK_HPP | ||
| #define _LIBSYCL___IMPL_SPINLOCK_HPP | ||
|
|
||
| #include <sycl/__impl/detail/config.hpp> // namespace macro | ||
|
|
||
| #include <atomic> | ||
| #include <thread> | ||
|
|
||
| _LIBSYCL_BEGIN_NAMESPACE_SYCL | ||
|
|
||
| namespace detail { | ||
| class SpinLock { | ||
| public: | ||
| bool try_lock() { return !MLock.test_and_set(std::memory_order_acquire); } | ||
|
|
||
| void lock() { | ||
| while (MLock.test_and_set(std::memory_order_acquire)) | ||
| std::this_thread::yield(); | ||
| } | ||
| void unlock() { MLock.clear(std::memory_order_release); } | ||
|
|
||
| private: | ||
| std::atomic_flag MLock = ATOMIC_FLAG_INIT; | ||
| }; | ||
| } // namespace detail | ||
|
|
||
| _LIBSYCL_END_NAMESPACE_SYCL | ||
|
|
||
| #endif // _LIBSYCL___IMPL_SPINLOCK_HPP |
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.