-
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
Changes from 37 commits
7981a31
ceb9e0a
f9d0203
971443e
260e2b2
9ce8393
08e6e2f
99f1f3c
ede48e7
3abb743
9a3ca28
f9913fd
e5e1971
7de749a
73b92f1
fce9a01
0158005
38400c0
7357f63
ed1507e
9925ce3
bf07166
715a33b
d530135
be62903
46baff0
ae6c2ef
4cfcb73
570f4c3
219c65a
44009a2
f02d2e0
9fb166d
e584620
f51c6df
6986a69
798d6d5
1165274
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 |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // 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 | ||
|
|
||
| // 4.1. Backends | ||
| enum class backend : char { | ||
KseniyaTikhomirova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| opencl = 1, | ||
| level_zero = 2, | ||
| cuda = 3, | ||
| hip = 4, | ||
| all = 5, | ||
| }; | ||
|
|
||
| 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 | ||
| 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, | ||
| "SYCL RT does not support C++ version earlier than C++17."); | ||
|
|
||
| #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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // 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_OBJ_BASE_HPP | ||
| #define _LIBSYCL___IMPL_DETAIL_OBJ_BASE_HPP | ||
|
|
||
| #include <sycl/__impl/detail/config.hpp> | ||
|
|
||
| #include <cassert> | ||
| #include <type_traits> | ||
| #include <utility> | ||
|
|
||
| _LIBSYCL_BEGIN_NAMESPACE_SYCL | ||
|
|
||
| namespace detail { | ||
|
|
||
| template <class Impl, class SyclObject> class ObjBase { | ||
| public: | ||
| using ImplType = Impl; | ||
| using Base = ObjBase<Impl, SyclObject>; | ||
|
|
||
| protected: | ||
| ImplType &impl; | ||
|
|
||
| explicit ObjBase(ImplType &pImpl) : impl(pImpl) {} | ||
| ObjBase() = default; | ||
|
|
||
| static SyclObject createSyclProxy(ImplType &impl) { return SyclObject(impl); } | ||
|
|
||
| template <class Obj> | ||
| friend const typename Obj::ImplType &getSyclObjImpl(const Obj &Object); | ||
|
|
||
| template <class Obj> | ||
| friend Obj createSyclObjFromImpl( | ||
| std::add_lvalue_reference_t<typename Obj::ImplType> ImplObj); | ||
| }; | ||
|
|
||
| template <class Obj> | ||
| const typename Obj::ImplType &getSyclObjImpl(const Obj &Object) { | ||
| return Object.impl; | ||
| } | ||
|
|
||
| template <class Obj> | ||
| Obj createSyclObjFromImpl( | ||
| std::add_lvalue_reference_t<typename Obj::ImplType> ImplObj) { | ||
| return Obj::Base::createSyclProxy(ImplObj); | ||
| } | ||
|
|
||
| } // namespace detail | ||
| _LIBSYCL_END_NAMESPACE_SYCL | ||
KseniyaTikhomirova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| #endif // _LIBSYCL___IMPL_DETAIL_OBJ_BASE_HPP | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,117 @@ | ||||||
| //===----------------------------------------------------------------------===// | ||||||
| // | ||||||
| // 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 2020 Exception class | ||||||
| /// interface (4.13.2.) | ||||||
| /// | ||||||
| //===----------------------------------------------------------------------===// | ||||||
|
|
||||||
| #ifndef _LIBSYCL___IMPL_EXCEPTION_HPP | ||||||
| #define _LIBSYCL___IMPL_EXCEPTION_HPP | ||||||
|
|
||||||
| #include <sycl/__impl/detail/config.hpp> | ||||||
|
|
||||||
| #include <exception> | ||||||
| #include <memory> | ||||||
| #include <string> | ||||||
| #include <system_error> | ||||||
| #include <type_traits> | ||||||
| #include <vector> | ||||||
|
|
||||||
| _LIBSYCL_BEGIN_NAMESPACE_SYCL | ||||||
|
|
||||||
| class context; | ||||||
|
|
||||||
| enum class errc : int { | ||||||
| success = 0, | ||||||
| runtime = 1, | ||||||
| kernel = 2, | ||||||
| accessor = 3, | ||||||
| nd_range = 4, | ||||||
| event = 5, | ||||||
| kernel_argument = 6, | ||||||
| build = 7, | ||||||
| invalid = 8, | ||||||
| memory_allocation = 9, | ||||||
| platform = 10, | ||||||
| profiling = 11, | ||||||
| feature_not_supported = 12, | ||||||
| kernel_not_supported = 13, | ||||||
| backend_mismatch = 14, | ||||||
| }; | ||||||
|
|
||||||
| /// Constructs an error code using E and sycl_category() | ||||||
| _LIBSYCL_EXPORT std::error_code make_error_code(sycl::errc E) noexcept; | ||||||
|
|
||||||
| /// Obtains a reference to the static error category object for SYCL errors. | ||||||
| _LIBSYCL_EXPORT const std::error_category &sycl_category() noexcept; | ||||||
|
|
||||||
| // Derive from std::exception so uncaught exceptions are printed in c++ default | ||||||
| // exception handler. | ||||||
| // Virtual inheritance is mandated by SYCL2020. | ||||||
|
||||||
| // Virtual inheritance is mandated by SYCL2020. | |
| // Virtual inheritance is mandated by SYCL 2020. |
KseniyaTikhomirova marked this conversation as resolved.
Show resolved
Hide resolved
Outdated
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.
I don't think "ABI neutral" should be upstreamed at all. And if it should, then everything should be STL-agnostic at the ABI boundary.
Also, any idea how std::exception deals with that (e.g., in libcxx)?
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.
Some time ago I asked Greg if we should support both ABIs and the answer was: "Yes, I think we want to upstream the CXX11_ABI stuff." So we do want to support it.
regarding libcxx I will check
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.
@gmlueck , why do we need that? AFAIK, upstream PyTorch has finally moved to C++11 ABI, e.g.:
- https://discuss.pytorch.org/t/why-is-libtorch-from-pip-not-build-with-cxx11-abi/207765/2
- Nightly pytorch wheel for prerelease version 2.6 is build with C++11 ABI on, at least for CPU pytorch/pytorch#143962 (comment)
and nobody is using the ancient pre-C++11 one.
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.
Are you asking about what we should upstream, or are you asking what we should support in our downstream "intel/llvm" repo? If we do not upstream the ABI neutral stuff, but we keep it in downstream, won't that be a pain whenever we pull from upstream?
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.
Emm, yes?.. But that's still a terrible argument for upstreaming that.
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.
If there are still customers that need this functionality, why wouldn't we upstream it? If there are no customers that want it, then should we propose to remove it also from "intel/llvm"?
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.
This whole solution was a quick hack. The root cause of the problem is the dependency of our ABI to a particular STL. Even if we want to support this usage scenario, the proper fix would be to avoid any STL data types crossing ABI boundary, not just std::string.
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.
I think it's better to focus on the current and future usages rather than hold on and support older and outdated ones. Those who needs older support can still use those older releases which have it. It's actually important to encourage users to switch to newer stuff. When you are working on upstreaming changes, above becomes a rule as it's rarely of interest of community what were historic customized usages in the closed source solution.
KseniyaTikhomirova marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #ifndef __SYCL_PARAM_TRAITS_SPEC | ||
| static_assert(false, "__SYCL_PARAM_TRAITS_SPEC is required but not defined"); | ||
| #endif | ||
|
|
||
| // 4.6.2.4. Information descriptors | ||
KseniyaTikhomirova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| __SYCL_PARAM_TRAITS_SPEC(platform, version, std::string, OL_PLATFORM_INFO_VERSION) | ||
| __SYCL_PARAM_TRAITS_SPEC(platform, name, std::string, OL_PLATFORM_INFO_NAME) | ||
| __SYCL_PARAM_TRAITS_SPEC(platform, vendor, std::string, OL_PLATFORM_INFO_VENDOR_NAME) | ||
Uh oh!
There was an error while loading. Please reload this page.