DPC++ Runtime
Runtime libraries for oneAPI Data Parallel C++
atomic_fence.hpp
Go to the documentation of this file.
1 //==--------- atomic_fence.hpp - SYCL 2020 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 <CL/sycl/detail/spirv.hpp>
13 #include <CL/sycl/memory_enums.hpp>
14 
15 #ifndef __SYCL_DEVICE_ONLY__
16 #include <atomic>
17 #endif
18 
20 namespace sycl {
21 
22 static inline void atomic_fence(memory_order order, memory_scope scope) {
23 #ifdef __SYCL_DEVICE_ONLY__
24  auto SPIRVOrder = detail::spirv::getMemorySemanticsMask(order);
25  auto SPIRVScope = detail::spirv::getScope(scope);
26  __spirv_MemoryBarrier(SPIRVScope, static_cast<uint32_t>(SPIRVOrder));
27 #else
28  (void)scope;
29  auto StdOrder = detail::getStdMemoryOrder(order);
30  atomic_thread_fence(StdOrder);
31 #endif
32 }
33 
34 } // namespace sycl
35 } // __SYCL_INLINE_NAMESPACE(cl)
spirv_ops.hpp
cl::sycl::memory_order
memory_order
Definition: memory_enums.hpp:16
cl::sycl::ext::oneapi::atomic_fence
static void atomic_fence(memory_order order, memory_scope scope)
Definition: atomic_fence.hpp:28
cl::sycl::memory_scope
memory_scope
Definition: memory_enums.hpp:26
cl::sycl::detail::getStdMemoryOrder
static std::memory_order getStdMemoryOrder(__spv::MemorySemanticsMask::Flag)
Definition: atomic.hpp:81
spirv.hpp
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
__spirv_MemoryBarrier
__SYCL_CONVERGENT__ SYCL_EXTERNAL void __spirv_MemoryBarrier(__spv::Scope Memory, uint32_t Semantics) noexcept
Definition: spirv_ops.cpp:36
memory_enums.hpp
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12