NeoN
A framework for CFD software
Loading...
Searching...
No Matches
executor.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2023 - 2025 NeoN authors
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
7#include <string>
8#include <variant>
9
13#include "NeoN/core/error.hpp"
14
15namespace NeoN
16{
17
18using Executor = std::variant<SerialExecutor, CPUExecutor, GPUExecutor>;
19
20/* @brief calls Kokkos::fence to wait for GPU kernels to be finished */
21inline void fence(const Executor& exec)
22{
23 if (std::holds_alternative<NeoN::GPUExecutor>(exec))
24 {
25 Kokkos::fence();
26 }
27}
28
35[[nodiscard]] inline bool operator==(const Executor& lhs, const Executor& rhs)
36{
37 return std::visit(
38 []<typename ExecLhs,
39 typename ExecRhs>([[maybe_unused]] const ExecLhs&, [[maybe_unused]] const ExecRhs&)
40 {
41 if constexpr (std::is_same_v<ExecLhs, ExecRhs>)
42 {
43 return typename ExecLhs::exec() == typename ExecRhs::exec();
44 }
45 else
46 {
47 return false;
48 }
49 },
50 lhs,
51 rhs
52 );
53};
54
62[[nodiscard]] inline bool operator!=(const Executor& lhs, const Executor& rhs)
63{
64 return !(lhs == rhs);
65};
66
67} // namespace NeoN
Definition array.hpp:20
void fence(const Executor &exec)
Definition executor.hpp:21
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
Definition executor.hpp:18
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:35
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:62