-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Provide SYCL 2020 function objects #3868
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
15 commits
Select commit
Hold shift + click to select a range
676f3f1
[SYCL] Provided some aliases to sycl
maximdimakov 67ba8c9
Clang-format fix
maximdimakov 588661b
Merge sycl
maximdimakov 272e536
Added explicit alias for sycl::plus
maximdimakov f133539
Added explicit sycl::plus
maximdimakov df9c728
Added sycl function objects
maximdimakov cab4e5c
Providing function objects for sycl
maximdimakov b459bab
Tests changed for using sycl function objects
maximdimakov c92f0c4
Added explicit aliases to remained function objects
maximdimakov 1cfb090
Fixed in code
maximdimakov 0c4c22c
Addressed to review comments
maximdimakov 946420b
Clang-format fix
maximdimakov d391c62
Merge with sycl branch
maximdimakov a8399f9
Fixes in the code
maximdimakov ca6223a
Replaced one function
maximdimakov 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,57 @@ | ||
//==----------- functional.hpp --- SYCL functional -------------------------==// | ||
// | ||
// 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 <functional> | ||
|
||
__SYCL_INLINE_NAMESPACE(cl) { | ||
namespace sycl { | ||
|
||
template <typename T = void> using plus = std::plus<T>; | ||
template <typename T = void> using multiplies = std::multiplies<T>; | ||
template <typename T = void> using bit_or = std::bit_or<T>; | ||
template <typename T = void> using bit_xor = std::bit_xor<T>; | ||
template <typename T = void> using bit_and = std::bit_and<T>; | ||
|
||
template <typename T = void> struct minimum { | ||
T operator()(const T &lhs, const T &rhs) const { | ||
return std::less<T>()(lhs, rhs) ? lhs : rhs; | ||
} | ||
}; | ||
|
||
template <> struct minimum<void> { | ||
struct is_transparent {}; | ||
template <typename T, typename U> | ||
auto operator()(T &&lhs, U &&rhs) const -> | ||
typename std::common_type<T &&, U &&>::type { | ||
return std::less<>()(std::forward<const T>(lhs), std::forward<const U>(rhs)) | ||
? std::forward<T>(lhs) | ||
: std::forward<U>(rhs); | ||
} | ||
}; | ||
|
||
template <typename T = void> struct maximum { | ||
T operator()(const T &lhs, const T &rhs) const { | ||
return std::greater<T>()(lhs, rhs) ? lhs : rhs; | ||
} | ||
}; | ||
|
||
template <> struct maximum<void> { | ||
struct is_transparent {}; | ||
template <typename T, typename U> | ||
auto operator()(T &&lhs, U &&rhs) const -> | ||
typename std::common_type<T &&, U &&>::type { | ||
return std::greater<>()(std::forward<const T>(lhs), | ||
std::forward<const U>(rhs)) | ||
? std::forward<T>(lhs) | ||
: std::forward<U>(rhs); | ||
} | ||
}; | ||
|
||
} // namespace sycl | ||
} // __SYCL_INLINE_NAMESPACE(cl) |
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
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
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.