-
Notifications
You must be signed in to change notification settings - Fork 796
[SYCL][NFCI] Unify queue submit paths #15776
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
steffenlarsen
merged 11 commits into
intel:sycl
from
steffenlarsen:steffen/refactor_submit_info_passing
Nov 15, 2024
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7a143ff
[SYCL][NFCI] Unify queue submit paths
steffenlarsen 454234e
Pass secondary queue through the class too
steffenlarsen b088e9a
Add windows symbols
steffenlarsen 5f27871
Merge remote-tracking branch 'intel/sycl' into steffen/refactor_submi…
steffenlarsen 059af6c
Put old interface removal behind preview
steffenlarsen 3c7f491
Fix formatting
steffenlarsen 0f49fb5
Switch to optional and references
steffenlarsen f2e0163
Fix formatting
steffenlarsen e05bb9d
Add windows symbols
steffenlarsen 4daaa7e
Apply suggestions from code review
steffenlarsen b655afb
Merge branch 'sycl' into steffen/refactor_submit_info_passing
steffenlarsen 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| //==-------- optional.hpp - limited variant of std::optional -------- C++ --==// | ||
| // | ||
| // 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 <optional> | ||
| #include <type_traits> | ||
|
|
||
| namespace sycl { | ||
| inline namespace _V1 { | ||
| namespace detail { | ||
|
|
||
| // ABI-stable implementation of optional to avoid reliance on potentially | ||
| // differing implementations of std::optional when crossing the library | ||
| // boundary. | ||
| template <typename T> class optional { | ||
| public: | ||
| constexpr optional() noexcept {} | ||
| constexpr optional(std::nullopt_t) noexcept : optional() {} | ||
|
|
||
| template <typename U> | ||
| constexpr optional(const optional<U> &Other) | ||
| : ContainsValue{Other.ContainsValue} { | ||
| new (Storage) T(Other.Value); | ||
| } | ||
| template <typename U> | ||
| constexpr optional(optional<U> &&Other) | ||
| : ContainsValue{std::move(Other.ContainsValue)} { | ||
| new (Storage) T(std::move(Other.Value)); | ||
| } | ||
|
|
||
| constexpr optional(T &&Value) : ContainsValue{true} { | ||
| new (Storage) T(std::move(Value)); | ||
| } | ||
|
|
||
| constexpr optional(const T &Value) : ContainsValue{true} { | ||
| new (Storage) T(Value); | ||
| } | ||
|
|
||
| template <typename U> | ||
| constexpr optional(const std::optional<U> &Other) : ContainsValue{Other} { | ||
| if (Other) | ||
| new (Storage) T(*Other); | ||
| } | ||
|
|
||
| ~optional() { | ||
| if (has_value()) | ||
| reinterpret_cast<T *>(Storage)->~T(); | ||
| } | ||
|
|
||
| optional &operator=(std::nullopt_t) noexcept { | ||
| if (has_value()) | ||
| reinterpret_cast<T *>(Storage)->~T(); | ||
| ContainsValue = false; | ||
| return *this; | ||
| } | ||
|
|
||
| template <typename U> optional &operator=(const optional<U> &Other) { | ||
| if (has_value()) | ||
| reinterpret_cast<T *>(Storage)->~T(); | ||
| ContainsValue = Other; | ||
| new (Storage) T(Other.Value); | ||
| return *this; | ||
| } | ||
| template <typename U> optional &operator=(optional<U> &&Other) noexcept { | ||
| if (has_value()) | ||
| reinterpret_cast<T *>(Storage)->~T(); | ||
| ContainsValue = Other; | ||
| new (Storage) T(std::move(Other.Value)); | ||
| return *this; | ||
| } | ||
|
|
||
| optional &operator=(T &&Value) { | ||
| if (has_value()) | ||
| reinterpret_cast<T *>(Storage)->~T(); | ||
| ContainsValue = true; | ||
| new (Storage) T(std::move(Value)); | ||
| return *this; | ||
| } | ||
|
|
||
| optional &operator=(const T &Value) { | ||
| if (has_value()) | ||
| reinterpret_cast<T *>(Storage)->~T(); | ||
| ContainsValue = true; | ||
| new (Storage) T(Value); | ||
| return *this; | ||
| } | ||
|
|
||
| template <typename U> optional &operator=(const std::optional<U> &Other) { | ||
| if (has_value()) | ||
| reinterpret_cast<T *>(Storage)->~T(); | ||
| ContainsValue = Other; | ||
| if (Other) | ||
| new (Storage) T(*Other); | ||
| return *this; | ||
| } | ||
|
|
||
| constexpr bool has_value() const noexcept { return ContainsValue; } | ||
| constexpr explicit operator bool() const noexcept { return has_value(); } | ||
|
|
||
| constexpr T &value() & { | ||
| if (!has_value()) | ||
| throw std::bad_optional_access{}; | ||
| return *reinterpret_cast<T *>(Storage); | ||
| } | ||
| constexpr const T &value() const & { | ||
| if (!has_value()) | ||
| throw std::bad_optional_access{}; | ||
| return *reinterpret_cast<const T *>(Storage); | ||
| } | ||
| constexpr T &&value() && { | ||
| if (!has_value()) | ||
| throw std::bad_optional_access{}; | ||
| return std::move(*reinterpret_cast<T *>(Storage)); | ||
| } | ||
| constexpr const T &&value() const && { | ||
| if (!has_value()) | ||
| throw std::bad_optional_access{}; | ||
| return std::move(*reinterpret_cast<const T *>(Storage)); | ||
| } | ||
|
|
||
| template <class U> constexpr T value_or(U &&DefaultVal) { | ||
| return has_value() ? value() : static_cast<T>(std::forward<U>(DefaultVal)); | ||
| } | ||
| template <class U> constexpr T value_or(U &&DefaultVal) const { | ||
| return has_value() ? std::move(value()) | ||
| : static_cast<T>(std::forward<U>(DefaultVal)); | ||
| } | ||
|
|
||
| constexpr T &operator*() & { return value(); } | ||
| constexpr const T &operator*() const & { return value(); } | ||
| constexpr T &&operator*() && { return value(); } | ||
| constexpr const T &&operator*() const && { return value(); } | ||
|
|
||
| private: | ||
| alignas(alignof(T)) char Storage[sizeof(T)] = {0}; | ||
| bool ContainsValue = false; | ||
| }; | ||
|
|
||
| } // namespace detail | ||
| } // namespace _V1 | ||
| } // namespace sycl | ||
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.