alpaka
Abstraction Library for Parallel Kernel Acceleration
MemFenceOmp2Blocks.hpp
Go to the documentation of this file.
1 /* Copyright 2022 Jan Stephan, Bernhard Manfred Gruber, Andrea Bocci
2  * SPDX-License-Identifier: MPL-2.0
3  */
4 
5 #pragma once
6 
9 
10 #ifdef ALPAKA_ACC_CPU_B_OMP2_T_SEQ_ENABLED
11 
12 # if _OPENMP < 200203
13 # error If ALPAKA_ACC_CPU_B_OMP2_T_SEQ_ENABLED is set, the compiler has to support OpenMP 2.0 or higher!
14 # endif
15 
16 namespace alpaka
17 {
18  //! The CPU OpenMP 2.0 block memory fence.
19  class MemFenceOmp2Blocks : public interface::Implements<ConceptMemFence, MemFenceOmp2Blocks>
20  {
21  };
22 
23  namespace trait
24  {
25  template<>
26  struct MemFence<MemFenceOmp2Blocks, memory_scope::Block>
27  {
28  static auto mem_fence(MemFenceOmp2Blocks const&, memory_scope::Block const&)
29  {
30  // Only one thread per block allowed -> no memory fence required on block level
31  }
32  };
33 
34  template<>
35  struct MemFence<MemFenceOmp2Blocks, memory_scope::Grid>
36  {
37  static auto mem_fence(MemFenceOmp2Blocks const&, memory_scope::Grid const&)
38  {
39 # pragma omp flush
40  }
41  };
42 
43  template<>
44  struct MemFence<MemFenceOmp2Blocks, memory_scope::Device>
45  {
47  {
48 # pragma omp flush
49  }
50  };
51  } // namespace trait
52 } // namespace alpaka
53 
54 #endif
The CPU OpenMP 2.0 block memory fence.
The alpaka accelerator library.
Tag used in class inheritance hierarchies that describes that a specific interface (TInterface) is im...
Definition: Interface.hpp:15
Memory fences are observed by all threads in the same block.
Definition: Traits.hpp:20
Memory fences are observed by all threads on the device.
Definition: Traits.hpp:30
Memory fences are observed by all threads in the same grid.
Definition: Traits.hpp:25
static auto mem_fence(MemFenceOmp2Blocks const &, memory_scope::Block const &)
static auto mem_fence(MemFenceOmp2Blocks const &, memory_scope::Device const &)
static auto mem_fence(MemFenceOmp2Blocks const &, memory_scope::Grid const &)
The mem_fence trait.
Definition: Traits.hpp:39