From 6fa9c25ba53f69f6c23585c4c764a0e7c1a5ff9b Mon Sep 17 00:00:00 2001 From: jakobtorben Date: Tue, 26 Nov 2024 14:55:27 +0100 Subject: [PATCH] Move Hypre initialization and finalization out to Main --- opm/simulators/flow/Main.cpp | 12 ++++++++++++ opm/simulators/linalg/HyprePreconditioner.hpp | 3 --- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/opm/simulators/flow/Main.cpp b/opm/simulators/flow/Main.cpp index 1d40593ed..963fee78b 100644 --- a/opm/simulators/flow/Main.cpp +++ b/opm/simulators/flow/Main.cpp @@ -35,6 +35,10 @@ #include #endif +#if HAVE_HYPRE +#include +#endif + namespace Opm { Main::Main(int argc, char** argv, bool ownMPI) @@ -88,6 +92,10 @@ Main::~Main() } #endif // HAVE_MPI +#if HAVE_HYPRE + HYPRE_Finalize(); +#endif + if (ownMPI_) { FlowGenericVanguard::setCommunication(nullptr); } @@ -163,6 +171,10 @@ void Main::initMPI() #endif #endif // HAVE_MPI + +#if HAVE_HYPRE + HYPRE_Initialize(); +#endif } void Main::handleVersionCmdLine_(int argc, char** argv, diff --git a/opm/simulators/linalg/HyprePreconditioner.hpp b/opm/simulators/linalg/HyprePreconditioner.hpp index 6435effa6..c773fd6ab 100644 --- a/opm/simulators/linalg/HyprePreconditioner.hpp +++ b/opm/simulators/linalg/HyprePreconditioner.hpp @@ -55,8 +55,6 @@ public: use_gpu_ = prm_.get("use_gpu", false); - HYPRE_Initialize(); - // Set memory location and execution policy if (use_gpu_) { HYPRE_SetMemoryLocation(HYPRE_MEMORY_DEVICE); @@ -155,7 +153,6 @@ public: if (indices_device_) { hypre_TFree(indices_device_, HYPRE_MEMORY_DEVICE); } - HYPRE_Finalize(); } void update() override {