Finite Volume Solver  prototype
A framework to build finite volume solvers for the AG Klein at the Freie Universität Berlin.
Execution.hpp
Go to the documentation of this file.
1 // Copyright (c) 2019 Maikel Nadolski
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 
21 #ifndef FUB_EXECUTION_HPP
22 #define FUB_EXECUTION_HPP
23 
24 #include "fub/ext/omp.hpp"
25 #include <optional>
26 
27 namespace fub {
28 namespace execution {
29 
30 struct SequentialTag {};
31 inline constexpr SequentialTag seq{};
32 
33 struct SimdTag {};
34 inline constexpr SimdTag simd{};
35 
36 struct OpenMpTag {};
37 inline constexpr OpenMpTag openmp{};
38 
40 inline constexpr OpenMpSimdTag openmp_simd{};
41 
42 } // namespace execution
43 
44 namespace detail {
45 template <typename Tag, typename T> struct LocalType {
46  using type = std::optional<T>;
47 };
48 template <typename T> struct LocalType<execution::OpenMpTag, T> {
49  using type = OmpLocal<T>;
50 };
51 template <typename T> struct LocalType<execution::OpenMpSimdTag, T> {
52  using type = OmpLocal<T>;
53 };
54 } // namespace detail
55 template <typename Tag, typename T>
56 using Local = typename detail::LocalType<Tag, T>::type;
57 
58 template <typename T> const T& Min(const std::optional<T>& x) { return *x; }
59 
60 template <typename T> const T& Min(const OmpLocal<T>& x) { return x.Min(); }
61 
62 } // namespace fub
63 
64 #endif
Definition: omp.hpp:42
const T & Min() const noexcept
Definition: omp.hpp:123
constexpr SequentialTag seq
Definition: Execution.hpp:31
constexpr OpenMpTag openmp
Definition: Execution.hpp:37
constexpr OpenMpSimdTag openmp_simd
Definition: Execution.hpp:40
constexpr SimdTag simd
Definition: Execution.hpp:34
The fub namespace.
Definition: AnyBoundaryCondition.hpp:31
typename detail::LocalType< Tag, T >::type Local
Definition: Execution.hpp:56
const T & Min(const std::optional< T > &x)
Definition: Execution.hpp:58
Definition: Execution.hpp:39
Definition: Execution.hpp:36
Definition: Execution.hpp:30
Definition: Execution.hpp:33