alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
MemFenceGenericSycl.hpp
Go to the documentation of this file.
1/* Copyright 2023 Jan Stephan, Luca Ferragina, Andrea Bocci
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#pragma once
6
8
9#ifdef ALPAKA_ACC_SYCL_ENABLED
10
11# include <sycl/sycl.hpp>
12
13namespace alpaka
14{
15 namespace detail
16 {
17 template<typename TAlpakaMemScope>
18 struct SyclFenceProps
19 {
20 };
21
22 template<>
23 struct SyclFenceProps<alpaka::memory_scope::Block>
24 {
25 static constexpr auto scope = sycl::memory_scope::work_group;
26 };
27
28 template<>
29 struct SyclFenceProps<alpaka::memory_scope::Device>
30 {
31 static constexpr auto scope = sycl::memory_scope::device;
32 };
33
34 template<>
35 struct SyclFenceProps<alpaka::memory_scope::Grid>
36 {
37 static constexpr auto scope = sycl::memory_scope::device;
38 };
39 } // namespace detail
40
41 //! The SYCL memory fence.
42 class MemFenceGenericSycl : public interface::Implements<ConceptMemFence, MemFenceGenericSycl>
43 {
44 };
45} // namespace alpaka
46
47namespace alpaka::trait
48{
49 template<typename TMemScope>
50 struct MemFence<MemFenceGenericSycl, TMemScope>
51 {
52 static auto mem_fence(MemFenceGenericSycl const&, TMemScope const&)
53 {
54 static constexpr auto scope = alpaka::detail::SyclFenceProps<TMemScope>::scope;
55 sycl::atomic_fence(sycl::memory_order::acq_rel, scope);
56 }
57 };
58} // namespace alpaka::trait
59
60#endif
The accelerator traits.
The alpaka accelerator library.
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_ACC auto mem_fence(TMemFence const &fence, TMemScope const &scope) -> void
Issues memory fence instructions.
Definition Traits.hpp:61