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, Tapish Narwal
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#pragma once
6
9
10#ifdef ALPAKA_ACC_SYCL_ENABLED
11
12# include <sycl/sycl.hpp>
13
14namespace alpaka
15{
16 namespace detail
17 {
18 template<typename TAlpakaMemScope>
19 struct SyclFenceProps
20 {
21 };
22
23 template<>
24 struct SyclFenceProps<alpaka::memory_scope::Block>
25 {
26 static constexpr auto scope = sycl::memory_scope::work_group;
27 };
28
29 template<>
30 struct SyclFenceProps<alpaka::memory_scope::Device>
31 {
32 static constexpr auto scope = sycl::memory_scope::device;
33 };
34
35 template<>
36 struct SyclFenceProps<alpaka::memory_scope::Grid>
37 {
38 static constexpr auto scope = sycl::memory_scope::device;
39 };
40 } // namespace detail
41
42 //! The SYCL memory fence.
43 class MemFenceGenericSycl : public interface::Implements<ConceptMemFence, MemFenceGenericSycl>
44 {
45 };
46} // namespace alpaka
47
48namespace alpaka::trait
49{
50 template<>
51 struct MemFenceDefaultOrder<MemFenceGenericSycl>
52 {
53 using type = mem_order::AcqRel;
54 static constexpr auto value = mem_order::acq_rel;
55 };
56
57 template<MemoryOrder TMemOrder, MemoryScope TMemScope>
58 struct MemFence<MemFenceGenericSycl, TMemOrder, TMemScope>
59 {
60 static auto mem_fence(MemFenceGenericSycl const&, TMemOrder order, TMemScope const&)
61 {
62 static constexpr auto scope = alpaka::detail::SyclFenceProps<TMemScope>::scope;
63 sycl::atomic_fence(MemOrderSycl::get(order), scope);
64 }
65 };
66} // namespace alpaka::trait
67
68#endif
static constexpr AcqRel acq_rel
The accelerator traits.
The alpaka accelerator library.
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_ACC auto mem_fence(TMemFence const &fence, TMemOrder order, TMemScope const &scope) -> void
Issues memory fence instructions.
Definition Traits.hpp:80