opm-simulators
gpu_type_detection.hpp
1 /*
2  Copyright 2025 Equinor ASA
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef OPM_GPUISTL_GPU_TYPE_DETECTION_HPP
21 #define OPM_GPUISTL_GPU_TYPE_DETECTION_HPP
22 
23 #include <type_traits>
24 
25 namespace Opm::gpuistl
26 {
27 
28 // Forward declarations
29 template <typename T>
30 class GpuVector;
31 template <typename T, bool ForceLegacy>
33 template <typename T>
35 
39 template <typename T>
40 struct is_gpu_type : std::false_type {
41 };
42 
43 // Specializations for known GPU types
44 template <typename T>
45 struct is_gpu_type<GpuVector<T>> : std::true_type {
46 };
47 
48 template <typename T, bool ForceLegacy>
49 struct is_gpu_type<GpuSparseMatrixWrapper<T, ForceLegacy>> : std::true_type {
50 };
51 
52 template <typename T>
53 struct is_gpu_type<GpuSparseMatrixGeneric<T>> : std::true_type {
54 };
55 
59 template <typename T>
60 inline constexpr bool is_gpu_type_v = is_gpu_type<T>::value;
61 
62 } // namespace Opm::gpuistl
63 
64 #endif // OPM_GPUISTL_GPU_TYPE_DETECTION_HPP
The GpuSparseMatrixGeneric class uses cuSPARSE Generic API for sparse matrix operations.
Definition: gpu_type_detection.hpp:34
Type trait to detect if a type is a GPU type.
Definition: gpu_type_detection.hpp:40
The GpuSparseMatrixWrapper Checks CUDA/HIP version and dispatches a version either using the old or t...
Definition: gpu_type_detection.hpp:32
Definition: gpu_type_detection.hpp:30
constexpr bool is_gpu_type_v
Helper variable template for easier usage.
Definition: gpu_type_detection.hpp:60
A small, fixed‑dimension MiniVector class backed by std::array that can be used in both host and CUD...
Definition: AmgxInterface.hpp:37