-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Add prototype of ExtendedAtomics features #1826
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
13 commits
Select commit
Hold shift + click to select a range
9ac71c6
[SYCL] Add prototype of ExtendedAtomics features
Pennycook 4f9e9b0
[SYCL] Adopt detail::bit_cast in atomic_ref
Pennycook 4b6f467
[SYCL] Add missing StorageClass to SPIR-V atomics
Pennycook ae15ff1
[SYCL][Doc] Update ExtendedAtomics status
Pennycook 8409896
[SYCL] Apply clang-format-9 to atomic_ref.hpp
Pennycook f6894df
[SYCL][CUDA] Add XFAIL to failing atomic_ref tests
Pennycook 0962402
[SYCL] Address warnings in detail/spirv.hpp
Pennycook eb26fbc
[SYCL] Avoid unnused argument warnings for host
Pennycook 01af47f
[SYCL] Disable atomic_ref tests on FPGA
Pennycook bf9ad71
Merge remote-tracking branch 'upstream/sycl' into extended-atomics-pr…
Pennycook 240e6af
[SYCL] Add missing break statements
Pennycook 21bb880
[SYCL] Use LLVM convention for ExtendedAtomics
Pennycook 3cba898
[SYCL] Apply clang-format-9 to spirv.hpp
Pennycook 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
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,13 @@ | ||
//==---------------- atomic.hpp - SYCL_INTEL_extended_atomics --------------==// | ||
// | ||
// 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 <CL/sycl/intel/atomic_enums.hpp> | ||
#include <CL/sycl/intel/atomic_fence.hpp> | ||
#include <CL/sycl/intel/atomic_ref.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,103 @@ | ||
//==---------------- atomic_enums.hpp - SYCL_INTEL_extended_atomics enums --==// | ||
// | ||
// 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 <CL/__spirv/spirv_ops.hpp> | ||
#include <CL/sycl/access/access.hpp> | ||
#include <CL/sycl/detail/defines.hpp> | ||
#include <CL/sycl/detail/helpers.hpp> | ||
|
||
#ifndef __SYCL_DEVICE_ONLY__ | ||
#include <atomic> | ||
#endif | ||
#include <type_traits> | ||
|
||
__SYCL_INLINE_NAMESPACE(cl) { | ||
namespace sycl { | ||
namespace intel { | ||
|
||
enum class memory_order : int { | ||
relaxed, | ||
acquire, | ||
__consume_unsupported, // helps optimizer when mapping to std::memory_order | ||
release, | ||
acq_rel, | ||
seq_cst | ||
}; | ||
__SYCL_INLINE_CONSTEXPR memory_order memory_order_relaxed = | ||
memory_order::relaxed; | ||
__SYCL_INLINE_CONSTEXPR memory_order memory_order_acquire = | ||
memory_order::acquire; | ||
__SYCL_INLINE_CONSTEXPR memory_order memory_order_release = | ||
memory_order::release; | ||
__SYCL_INLINE_CONSTEXPR memory_order memory_order_acq_rel = | ||
memory_order::acq_rel; | ||
__SYCL_INLINE_CONSTEXPR memory_order memory_order_seq_cst = | ||
memory_order::seq_cst; | ||
|
||
enum class memory_scope : int { | ||
work_item, | ||
sub_group, | ||
work_group, | ||
device, | ||
system | ||
}; | ||
__SYCL_INLINE_CONSTEXPR memory_scope memory_scope_work_item = | ||
memory_scope::work_item; | ||
__SYCL_INLINE_CONSTEXPR memory_scope memory_scope_sub_group = | ||
memory_scope::sub_group; | ||
__SYCL_INLINE_CONSTEXPR memory_scope memory_scope_work_group = | ||
memory_scope::work_group; | ||
__SYCL_INLINE_CONSTEXPR memory_scope memory_scope_device = memory_scope::device; | ||
__SYCL_INLINE_CONSTEXPR memory_scope memory_scope_system = memory_scope::system; | ||
|
||
#ifndef __SYCL_DEVICE_ONLY__ | ||
namespace detail { | ||
// Cannot use switch statement in constexpr before C++14 | ||
Pennycook marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Nested ternary conditions in else branch required for C++11 | ||
#if __cplusplus >= 201402L | ||
static inline constexpr std::memory_order | ||
getStdMemoryOrder(::cl::sycl::intel::memory_order order) { | ||
switch (order) { | ||
case memory_order::relaxed: | ||
return std::memory_order_relaxed; | ||
case memory_order::__consume_unsupported: | ||
return std::memory_order_consume; | ||
case memory_order::acquire: | ||
return std::memory_order_acquire; | ||
case memory_order::release: | ||
return std::memory_order_release; | ||
case memory_order::acq_rel: | ||
return std::memory_order_acq_rel; | ||
case memory_order::seq_cst: | ||
return std::memory_order_seq_cst; | ||
} | ||
} | ||
#else | ||
static inline constexpr std::memory_order | ||
getStdMemoryOrder(::cl::sycl::intel::memory_order order) { | ||
return (order == memory_order::relaxed) | ||
? std::memory_order_relaxed | ||
: (order == memory_order::__consume_unsupported) | ||
? std::memory_order_consume | ||
: (order == memory_order::acquire) | ||
? std::memory_order_acquire | ||
: (order == memory_order::release) | ||
? std::memory_order_release | ||
: (order == memory_order::acq_rel) | ||
? std::memory_order_acq_rel | ||
: std::memory_order_seq_cst; | ||
} | ||
#endif // __cplusplus | ||
} // namespace detail | ||
#endif // __SYCL_DEVICE_ONLY__ | ||
|
||
} // namespace intel | ||
} // namespace sycl | ||
} // __SYCL_INLINE_NAMESPACE(cl) |
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.
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.
Just a question: Is 'half' type expected to be supported too eventually?
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.
Good question. OpenCL only defines atomics for 32- and 64-bit types, which is what I've started with here.
C++ allows an
atomic_ref
to be constructed from anyTriviallyCopyable
type, and I think eventually that's where we'd like to end up. Whether theatomic_ref
for a given type is implemented on top of native instructions, a compare-exchange loop, a global lock, etc, would then be implementation-defined and device-specific.We haven't yet defined exactly what sort of device queries we'll want to support for testing atomic functionality. If you have any ideas for what the feature sets should look like, or if there are any queries that would be useful for implementing reductions, please let me know!