DPC++ Runtime
Runtime libraries for oneAPI DPC++
atomic_fence.hpp
Go to the documentation of this file.
1 //==---- atomic_fence.hpp - SYCL_ONEAPI_extended_atomics atomic_fence ------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
11 #include <CL/__spirv/spirv_ops.hpp>
12 #include <sycl/detail/spirv.hpp>
14 
15 #ifndef __SYCL_DEVICE_ONLY__
16 #include <atomic>
17 #endif
18 
19 namespace sycl {
21 namespace ext::oneapi {
22 namespace detail {
23 using namespace sycl::detail;
24 }
25 
26 __SYCL2020_DEPRECATED("use sycl::atomic_fence instead")
27 static inline void atomic_fence(memory_order order, memory_scope scope) {
28 #ifdef __SYCL_DEVICE_ONLY__
29  auto SPIRVOrder = detail::spirv::getMemorySemanticsMask(order);
30  auto SPIRVScope = detail::spirv::getScope(scope);
31  __spirv_MemoryBarrier(SPIRVScope, static_cast<uint32_t>(SPIRVOrder));
32 #else
33  (void)scope;
34  auto StdOrder = detail::getStdMemoryOrder(order);
35  atomic_thread_fence(StdOrder);
36 #endif
37 }
38 
39 } // namespace ext::oneapi
40 
41 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
42 } // namespace sycl
#define __SYCL_INLINE_VER_NAMESPACE(X)
#define __SYCL2020_DEPRECATED(message)
static std::memory_order getStdMemoryOrder(__spv::MemorySemanticsMask::Flag)
Definition: atomic.hpp:84
static void atomic_fence(memory_order order, memory_scope scope)
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14
__SYCL_CONVERGENT__ SYCL_EXTERNAL void __spirv_MemoryBarrier(__spv::Scope Memory, uint32_t Semantics) noexcept
Definition: spirv_ops.cpp:36