is_gpu_operator.hpp
Go to the documentation of this file.
1/*
2 Copyright 2025 Equinor ASA
3
4 This file is part of the Open Porous Media project (OPM).
5 OPM is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 OPM is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with OPM. If not, see <http://www.gnu.org/licenses/>.
15*/
16
17#ifndef OPM_IS_GPU_OPERATOR_HEADER
18#define OPM_IS_GPU_OPERATOR_HEADER
19
20#include <type_traits>
21
22#if HAVE_CUDA // Avoid including GpuVector.hpp if CUDA
23 // is not enabled to avoid linking errors.
25#endif
26namespace Opm {
27
36template <typename T>
38{
39#if HAVE_CUDA
40 // TODO: This can be done more thoroughly by checking if range and matrix also is a gpu operator, but this
41 // works for now.
42 static constexpr bool value
43 = std::is_same_v<typename T::domain_type, Opm::gpuistl::GpuVector<typename T::field_type>>;
44#else
45 // If CUDA is not enabled, we assume that the operator is not a GPU operator.
46 static constexpr bool value = false;
47#endif
48};
49
50template <typename T>
52
53
62 template <typename T>
64 {
65 #if HAVE_CUDA
66
67 static constexpr bool value
68 = std::is_same_v<T, Opm::gpuistl::GpuSparseMatrix<typename T::field_type>>;
69 #else
70 // If CUDA is not enabled, we assume that the matrix is not a GPU matrix.
71 static constexpr bool value = false;
72 #endif
73 };
74
75 template <typename T>
77
78} // namespace Opm
79
80#endif // OPM_IS_GPU_OPERATOR_HEADER
Definition: blackoilboundaryratevector.hh:39
static constexpr bool is_gpu_matrix_v
Definition: is_gpu_operator.hpp:76
static constexpr bool is_gpu_operator_v
Definition: is_gpu_operator.hpp:51
Check if a given operator is a GPU matrix.
Definition: is_gpu_operator.hpp:64
static constexpr bool value
Definition: is_gpu_operator.hpp:71
Check if a given operator is a GPU operator.
Definition: is_gpu_operator.hpp:38
static constexpr bool value
Definition: is_gpu_operator.hpp:46