NeoFOAM
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
executor.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2023 NeoFOAM authors
3#pragma once
4
5#include <string>
6#include <variant>
7
12
13namespace NeoFOAM
14{
15
16using Executor = std::variant<SerialExecutor, CPUExecutor, GPUExecutor>;
17
24[[nodiscard]] inline bool operator==(const Executor& lhs, const Executor& rhs)
25{
26 return std::visit(
27 []<typename ExecLhs,
28 typename ExecRhs>([[maybe_unused]] const ExecLhs&, [[maybe_unused]] const ExecRhs&)
29 {
30 if constexpr (std::is_same_v<ExecLhs, ExecRhs>)
31 {
32 return typename ExecLhs::exec() == typename ExecRhs::exec();
33 }
34 else
35 {
36 return false;
37 }
38 },
39 lhs,
40 rhs
41 );
42};
43
51[[nodiscard]] inline bool operator!=(const Executor& lhs, const Executor& rhs)
52{
53 return !(lhs == rhs);
54};
55
56} // namespace NeoFOAM
bool operator!=(const Executor &lhs, const Executor &rhs)
Checks if two executors are not equal, i.e. they are not of the same type.
Definition executor.hpp:51
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
Definition executor.hpp:16
bool operator==(const Executor &lhs, const Executor &rhs)
Checks if two executors are equal, i.e. they are of the same type.
Definition executor.hpp:24