20 #ifndef OPM_HYPRE_INTERFACE_HPP 21 #define OPM_HYPRE_INTERFACE_HPP 23 #include <opm/simulators/linalg/hypreinterface/HypreCpuTransfers.hpp> 24 #include <opm/simulators/linalg/hypreinterface/HypreDataStructures.hpp> 25 #include <opm/simulators/linalg/hypreinterface/HypreErrorHandling.hpp> 26 #include <opm/simulators/linalg/hypreinterface/HypreSetup.hpp> 27 #include <opm/simulators/linalg/hypreinterface/HypreUtils.hpp> 31 #ifdef MM_MAX_LINE_LENGTH 32 #undef MM_MAX_LINE_LENGTH 36 #include <opm/simulators/linalg/gpuistl/detail/gpu_type_detection.hpp> 37 #include <opm/simulators/linalg/gpuistl/hypreinterface/HypreGpuTransfers.hpp> 39 #include <opm/simulators/linalg/gpuistl_hip/detail/gpu_type_detection.hpp> 40 #include <opm/simulators/linalg/gpuistl_hip/hypreinterface/HypreGpuTransfers.hpp> 78 void setSolverParameters(HYPRE_Solver solver,
const PropertyTree& prm,
bool use_gpu_backend);
83 template <
typename CommType>
84 HYPRE_IJMatrix
createMatrix(HYPRE_Int N, HYPRE_Int dof_offset,
const CommType& comm);
89 template <
typename CommType>
90 HYPRE_IJVector
createVector(HYPRE_Int N, HYPRE_Int dof_offset,
const CommType& comm);
110 template <
typename CommType,
typename MatrixType>
117 template <
typename MatrixType>
120 const ParallelInfo& par_info,
126 template <
typename MatrixType>
128 const std::vector<HYPRE_Int>& ncols,
129 const std::vector<int>& local_dune_to_local_hypre,
135 template <
typename VectorType>
137 HYPRE_IJVector hypre_vec,
138 HostDataArrays& host_arrays,
139 const DeviceDataArrays& device_arrays,
140 const ParallelInfo& par_info,
141 bool use_gpu_backend);
146 template <
typename VectorType>
149 HostDataArrays& host_arrays,
150 const DeviceDataArrays& device_arrays,
151 const ParallelInfo& par_info,
152 bool use_gpu_backend);
157 template <
typename MatrixType>
159 HYPRE_IJMatrix hypre_matrix,
160 const SparsityPattern& sparsity_pattern,
161 const HostDataArrays& host_arrays,
162 const DeviceDataArrays& device_arrays,
163 bool use_gpu_backend);
165 template <
typename VectorType>
167 HYPRE_IJVector hypre_vec,
171 bool use_gpu_backend)
173 #if HYPRE_USING_CUDA || HYPRE_USING_HIP 175 gpuistl::HypreInterface::transferGpuVectorToHypre(vec, hypre_vec, host_arrays,
176 device_arrays, par_info, use_gpu_backend);
181 device_arrays, par_info, use_gpu_backend);
185 template <
typename VectorType>
191 bool use_gpu_backend)
193 #if HYPRE_USING_CUDA || HYPRE_USING_HIP 195 gpuistl::HypreInterface::transferHypreToGpuVector(hypre_vec, vec, host_arrays,
196 device_arrays, par_info, use_gpu_backend);
201 par_info, use_gpu_backend);
205 template <
typename MatrixType>
207 HYPRE_IJMatrix hypre_matrix,
211 bool use_gpu_backend)
213 #if HYPRE_USING_CUDA || HYPRE_USING_HIP 215 gpuistl::HypreInterface::updateMatrixFromGpuSparseMatrix(matrix,
225 host_arrays, device_arrays, use_gpu_backend);
231 #endif // OPM_HYPRE_INTERFACE_HPP void transferVectorFromHypre(HYPRE_IJVector hypre_vec, VectorType &vec, HostDataArrays &host_arrays, const DeviceDataArrays &device_arrays, const ParallelInfo &par_info, bool use_gpu_backend)
Transfer vector from Hypre to any vector type (CPU or GPU)
Definition: HypreInterface.hpp:186
Type trait to detect if a type is a GPU type.
Definition: gpu_type_detection.hpp:40
Parallel domain decomposition information for HYPRE-Dune interface.
Definition: HypreDataStructures.hpp:37
void transferHypreToCpuVector(HYPRE_IJVector hypre_vec, VectorType &cpu_vec, linalg::HypreInterface::HostDataArrays &host_arrays, [[maybe_unused]] const linalg::HypreInterface::DeviceDataArrays &device_arrays, const linalg::HypreInterface::ParallelInfo &par_info, bool use_gpu_backend)
Transfer Hypre vector to CPU vector.
Definition: HypreCpuTransfers.hpp:114
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:557
void destroySolver(HYPRE_Solver solver)
Destroy Hypre solver.
Definition: HypreSetup.hpp:214
Compressed Sparse Row (CSR) sparsity pattern for HYPRE matrix assembly.
Definition: HypreDataStructures.hpp:86
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:462
HYPRE_IJMatrix createMatrix(HYPRE_Int N, HYPRE_Int dof_offset, const CommType &comm)
Create Hypre matrix.
Definition: HypreSetup.hpp:165
void destroyMatrix(HYPRE_IJMatrix matrix)
Destroy Hypre matrix.
Definition: HypreSetup.hpp:228
void transferVectorToHypre(const VectorType &vec, HYPRE_IJVector hypre_vec, HostDataArrays &host_arrays, const DeviceDataArrays &device_arrays, const ParallelInfo &par_info, bool use_gpu_backend)
Transfer vector to Hypre from any vector type (CPU or GPU)
Definition: HypreInterface.hpp:166
Host arrays for HYPRE matrix and vector data transfers.
Definition: HypreDataStructures.hpp:106
void initialize(bool use_gpu_backend)
Initialize the Hypre library and set memory/execution policy.
void updateMatrixFromCpuMatrix(const MatrixType &cpu_matrix, HYPRE_IJMatrix hypre_matrix, const linalg::HypreInterface::SparsityPattern &sparsity_pattern, const linalg::HypreInterface::HostDataArrays &host_arrays, [[maybe_unused]] const linalg::HypreInterface::DeviceDataArrays &device_arrays, bool use_gpu_backend)
Update Hypre matrix from CPU matrix Uses HYPRE_IJMatrixSetValues2 with pre-computed row_indexes...
Definition: HypreCpuTransfers.hpp:155
void destroyVector(HYPRE_IJVector vector)
Destroy Hypre vector.
Definition: HypreSetup.hpp:242
HYPRE_IJVector createVector(HYPRE_Int N, HYPRE_Int dof_offset, const CommType &comm)
Create Hypre vector.
Definition: HypreSetup.hpp:192
HYPRE_Solver createAMGSolver()
Create Hypre solver (BoomerAMG)
Definition: HypreSetup.hpp:112
ParallelInfo setupHypreParallelInfo(const CommType &comm, const MatrixType &matrix)
Setup parallel information for Hypre (automatically detects serial/parallel)
Definition: HypreSetup.hpp:258
void transferCpuVectorToHypre(const VectorType &cpu_vec, HYPRE_IJVector hypre_vec, linalg::HypreInterface::HostDataArrays &host_arrays, [[maybe_unused]] const linalg::HypreInterface::DeviceDataArrays &device_arrays, const linalg::HypreInterface::ParallelInfo &par_info, bool use_gpu_backend)
Transfer CPU vector to Hypre vector.
Definition: HypreCpuTransfers.hpp:73
void setSolverParameters(HYPRE_Solver solver, const PropertyTree &prm, bool use_gpu_backend)
Set solver parameters from property tree.
Definition: HypreSetup.hpp:128
Unified interface for Hypre operations with both CPU and GPU data structures.
Definition: HypreCpuTransfers.hpp:35
GPU device memory arrays for HYPRE operations with GPU backend.
Definition: HypreDataStructures.hpp:137
void updateMatrixValues(const MatrixType &matrix, HYPRE_IJMatrix hypre_matrix, const SparsityPattern &sparsity_pattern, const HostDataArrays &host_arrays, const DeviceDataArrays &device_arrays, bool use_gpu_backend)
Update matrix values in Hypre.
Definition: HypreInterface.hpp:206