20 #ifndef OPM_HYPRE_INTERFACE_HPP 21 #define OPM_HYPRE_INTERFACE_HPP 23 #include <opm/simulators/linalg/gpuistl/hypreinterface/HypreCpuTransfers.hpp> 24 #include <opm/simulators/linalg/gpuistl/hypreinterface/HypreDataStructures.hpp> 25 #include <opm/simulators/linalg/gpuistl/hypreinterface/HypreErrorHandling.hpp> 26 #include <opm/simulators/linalg/gpuistl/hypreinterface/HypreGpuTransfers.hpp> 27 #include <opm/simulators/linalg/gpuistl/hypreinterface/HypreSetup.hpp> 28 #include <opm/simulators/linalg/gpuistl/hypreinterface/HypreUtils.hpp> 32 #ifdef MM_MAX_LINE_LENGTH 33 #undef MM_MAX_LINE_LENGTH 36 #include <opm/simulators/linalg/gpuistl/detail/gpu_type_detection.hpp> 80 void setSolverParameters(HYPRE_Solver solver,
const PropertyTree& prm,
bool use_gpu_backend);
85 template <
typename CommType>
86 HYPRE_IJMatrix
createMatrix(HYPRE_Int N, HYPRE_Int dof_offset,
const CommType& comm);
91 template <
typename CommType>
92 HYPRE_IJVector
createVector(HYPRE_Int N, HYPRE_Int dof_offset,
const CommType& comm);
112 template <
typename CommType,
typename MatrixType>
118 template <
typename MatrixType>
119 SparsityPattern
setupSparsityPattern(
const MatrixType& matrix,
const ParallelInfo& par_info,
bool owner_first);
124 template <
typename MatrixType>
126 const std::vector<HYPRE_Int>& ncols,
127 const std::vector<int>& local_dune_to_local_hypre,
133 template <
typename VectorType>
135 HYPRE_IJVector hypre_vec,
136 HostArrays& host_arrays,
137 const DeviceArrays& device_arrays,
138 const ParallelInfo& par_info,
139 bool use_gpu_backend);
144 template <
typename VectorType>
147 HostArrays& host_arrays,
148 const DeviceArrays& device_arrays,
149 const ParallelInfo& par_info,
150 bool use_gpu_backend);
155 template <
typename MatrixType>
157 HYPRE_IJMatrix hypre_matrix,
158 const SparsityPattern& sparsity_pattern,
159 const HostArrays& host_arrays,
160 const DeviceArrays& device_arrays,
161 bool use_gpu_backend);
163 template <
typename VectorType>
165 HYPRE_IJVector hypre_vec,
169 bool use_gpu_backend)
171 #if HYPRE_USING_CUDA || HYPRE_USING_HIP 173 transferGpuVectorToHypre(vec, hypre_vec, host_arrays, device_arrays, par_info, use_gpu_backend);
181 template <
typename VectorType>
187 bool use_gpu_backend)
189 #if HYPRE_USING_CUDA || HYPRE_USING_HIP 191 transferHypreToGpuVector(hypre_vec, vec, host_arrays, device_arrays, par_info, use_gpu_backend);
199 template <
typename MatrixType>
201 HYPRE_IJMatrix hypre_matrix,
205 bool use_gpu_backend)
207 #if HYPRE_USING_CUDA || HYPRE_USING_HIP 209 updateMatrixFromGpuSparseMatrix(
210 matrix, hypre_matrix, sparsity_pattern, host_arrays, device_arrays, use_gpu_backend);
215 matrix, hypre_matrix, sparsity_pattern, host_arrays, device_arrays, use_gpu_backend);
223 #endif // OPM_HYPRE_INTERFACE_HPP Type trait to detect if a type is a GPU type.
Definition: gpu_type_detection.hpp:40
Unified interface for Hypre operations with both CPU and GPU data structures.
Definition: HypreCpuTransfers.hpp:29
HYPRE_Solver createAMGSolver()
Create Hypre BoomerAMG solver.
Definition: HypreSetup.hpp:117
Host arrays for HYPRE matrix and vector data transfers.
Definition: HypreDataStructures.hpp:106
void destroyMatrix(HYPRE_IJMatrix matrix)
Destroy Hypre matrix.
Definition: HypreSetup.hpp:233
void initialize([[maybe_unused]] bool use_gpu_backend)
Initialize the Hypre library and set memory/execution policy.
Definition: HypreSetup.hpp:89
GPU device memory arrays for HYPRE operations with GPU backend.
Definition: HypreDataStructures.hpp:137
HYPRE_IJMatrix createMatrix(HYPRE_Int N, HYPRE_Int dof_offset, const CommType &comm)
Create Hypre matrix.
Definition: HypreSetup.hpp:170
void updateMatrixFromCpuMatrix(const MatrixType &cpu_matrix, HYPRE_IJMatrix hypre_matrix, const SparsityPattern &sparsity_pattern, const HypreHostDataArrays &host_arrays, [[maybe_unused]] const HypreDeviceDataArrays &device_arrays, bool use_gpu_backend)
Update Hypre matrix from CPU matrix Uses HYPRE_IJMatrixSetValues2 with pre-computed row_indexes...
Definition: HypreCpuTransfers.hpp:187
void updateMatrixValues(const MatrixType &matrix, HYPRE_IJMatrix hypre_matrix, const SparsityPattern &sparsity_pattern, const HostArrays &host_arrays, const DeviceArrays &device_arrays, bool use_gpu_backend)
Update matrix values in Hypre.
Definition: HypreInterface.hpp:200
void transferVectorToHypre(const VectorType &vec, HYPRE_IJVector hypre_vec, HostArrays &host_arrays, const DeviceArrays &device_arrays, const ParallelInfo &par_info, bool use_gpu_backend)
Transfer vector to Hypre from any vector type (CPU or GPU)
Definition: HypreInterface.hpp:164
HYPRE_IJVector createVector(HYPRE_Int N, HYPRE_Int dof_offset, const CommType &comm)
Create Hypre vector.
Definition: HypreSetup.hpp:197
void transferCpuVectorToHypre(const VectorType &cpu_vec, HYPRE_IJVector hypre_vec, HypreHostDataArrays &host_arrays, [[maybe_unused]] const HypreDeviceDataArrays &device_arrays, const ParallelInfo &par_info, bool use_gpu_backend)
Transfer CPU vector to Hypre vector.
Definition: HypreCpuTransfers.hpp:67
ParallelInfo setupHypreParallelInfo(const CommType &comm, const MatrixType &matrix)
Setup parallel information for Hypre (automatically detects serial/parallel)
Definition: HypreSetup.hpp:263
void transferHypreToCpuVector(HYPRE_IJVector hypre_vec, VectorType &cpu_vec, HypreHostDataArrays &host_arrays, [[maybe_unused]] const HypreDeviceDataArrays &device_arrays, const ParallelInfo &par_info, bool use_gpu_backend)
Transfer Hypre vector to CPU vector.
Definition: HypreCpuTransfers.hpp:127
SparsityPattern setupSparsityPattern(const MatrixType &matrix, const ParallelInfo &par_info, bool owner_first)
Setup sparsity pattern from matrix (automatically detects CPU/GPU type)
Definition: HypreSetup.hpp:467
void destroyVector(HYPRE_IJVector vector)
Destroy Hypre vector.
Definition: HypreSetup.hpp:247
A small, fixed‑dimension MiniVector class backed by std::array that can be used in both host and CUD...
Definition: AmgxInterface.hpp:37
void setSolverParameters(HYPRE_Solver solver, const PropertyTree &prm, bool use_gpu_backend)
Set solver parameters from property tree.
Definition: HypreSetup.hpp:133
void transferVectorFromHypre(HYPRE_IJVector hypre_vec, VectorType &vec, HostArrays &host_arrays, const DeviceArrays &device_arrays, const ParallelInfo &par_info, bool use_gpu_backend)
Transfer vector from Hypre to any vector type (CPU or GPU)
Definition: HypreInterface.hpp:182
Compressed Sparse Row (CSR) sparsity pattern for HYPRE matrix assembly.
Definition: HypreDataStructures.hpp:86
std::vector< HYPRE_Int > computeRowIndexes(const MatrixType &matrix, const std::vector< HYPRE_Int > &ncols, const std::vector< int > &local_dune_to_local_hypre, bool owner_first)
Compute row indexes for HYPRE_IJMatrixSetValues2.
Definition: HypreSetup.hpp:636
Parallel domain decomposition information for HYPRE-Dune interface.
Definition: HypreDataStructures.hpp:37
void destroySolver(HYPRE_Solver solver)
Destroy Hypre solver.
Definition: HypreSetup.hpp:219