|
36 | 36 | #include "libmesh/enum_solver_type.h" |
37 | 37 | #include "libmesh/enum_convergence_flags.h" |
38 | 38 |
|
| 39 | +#if defined(LIBMESH_HAVE_PETSC_HYPRE) && PETSC_VERSION_LESS_THAN(3, 23, 0) && \ |
| 40 | + !PETSC_VERSION_LESS_THAN(3, 12, 0) && defined(PETSC_HAVE_HYPRE_DEVICE) |
| 41 | +#include <HYPRE_utilities.h> |
| 42 | +#endif |
| 43 | + |
39 | 44 | // C++ includes |
40 | 45 | #include <memory> |
41 | 46 | #include <string.h> |
@@ -571,6 +576,20 @@ PetscLinearSolver<T>::solve_base (SparseMatrix<T> * matrix, |
571 | 576 | // Allow command line options to override anything set programmatically. |
572 | 577 | LibmeshPetscCall(KSPSetFromOptions(_ksp)); |
573 | 578 |
|
| 579 | +#if defined(LIBMESH_HAVE_PETSC_HYPRE) && PETSC_VERSION_LESS_THAN(3, 23, 0) && \ |
| 580 | + !PETSC_VERSION_LESS_THAN(3, 12, 0) && defined(PETSC_HAVE_HYPRE_DEVICE) |
| 581 | + { |
| 582 | + // Make sure hypre has been initialized |
| 583 | + LibmeshPetscCallExternal(HYPRE_Initialize); |
| 584 | + PetscScalar * dummyarray; |
| 585 | + PetscMemType mtype; |
| 586 | + LibmeshPetscCall(VecGetArrayAndMemType(solution->vec(), &dummyarray, &mtype)); |
| 587 | + LibmeshPetscCall(VecRestoreArrayAndMemType(solution->vec(), &dummyarray)); |
| 588 | + if (PetscMemTypeHost(mtype)) |
| 589 | + LibmeshPetscCallExternal(HYPRE_SetMemoryLocation, HYPRE_MEMORY_HOST); |
| 590 | + } |
| 591 | +#endif |
| 592 | + |
574 | 593 | // If the SolverConfiguration object is provided, use it to override |
575 | 594 | // solver options. |
576 | 595 | if (this->_solver_configuration) |
|
0 commit comments