diff --git a/CMakeLists.txt b/CMakeLists.txt index 30cfe278f..4ad65424f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -289,6 +289,20 @@ if(OpenCL_FOUND) endif() endif() +if(USE_HYPRE AND USE_MPI) + find_package(HYPRE) + if(HYPRE_FOUND) + set(HAVE_HYPRE 1) + list(APPEND opm-simulators_LIBRARIES HYPRE::HYPRE) + else() + message(WARNING "Hypre requested but not found. Continuing without Hypre support.") + set(USE_HYPRE OFF) + endif() +elseif(USE_HYPRE) + message(WARNING "Hypre requested but MPI not activated. Continuing without Hypre support.") + set(USE_HYPRE OFF) + set(HYPRE_FOUND OFF) +endif() macro (config_hook) opm_need_version_of ("dune-common") @@ -396,6 +410,12 @@ macro (files_hook) endmacro (files_hook) macro (tests_hook) + if(HYPRE_FOUND) + list(APPEND tests_SOURCES tests/test_HyprePreconditionerCPU.cpp) + if(HYPRE_USING_CUDA OR HYPRE_USING_HIP) + list(APPEND tests_SOURCES tests/test_HyprePreconditionerGPU.cpp) + endif() + endif() endmacro (tests_hook) @@ -692,6 +712,14 @@ if(CUDA_FOUND) PROPERTIES LABELS ${gpu_label}) endif() +if(HYPRE_FOUND) + if (HYPRE_USING_CUDA) + set_tests_properties(HyprePreconditionerGPU PROPERTIES LABELS gpu_cuda) + elseif (HYPRE_USING_HIP) + set_tests_properties(HyprePreconditionerGPU PROPERTIES LABELS gpu_hip) + endif() +endif() + if(USE_GPU_BRIDGE) if(OpenCL_FOUND) target_link_libraries( opmsimulators PUBLIC ${OpenCL_LIBRARIES} ) @@ -722,18 +750,3 @@ endif() install(DIRECTORY doc/man1 DESTINATION ${CMAKE_INSTALL_MANDIR} FILES_MATCHING PATTERN "*.1") -if(USE_HYPRE) - find_package(HYPRE) - if(HYPRE_FOUND) - set(HAVE_HYPRE 1) - target_link_libraries(opmsimulators PUBLIC HYPRE::HYPRE) - if (HYPRE_USING_CUDA) - set_tests_properties(HyprePreconditionerGPU PROPERTIES LABELS gpu_cuda) - elseif (HYPRE_USING_HIP) - set_tests_properties(HyprePreconditionerGPU PROPERTIES LABELS gpu_hip) - endif() - else() - message(WARNING "Hypre requested but not found. Continuing without Hypre support.") - set(USE_HYPRE OFF) - endif() -endif() diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index e67d7667e..e3ece638b 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -492,13 +492,6 @@ if(HDF5_FOUND) list(APPEND TEST_SOURCE_FILES tests/test_HDF5Serializer.cpp) endif() -if(HYPRE_FOUND) - list(APPEND TEST_SOURCE_FILES tests/test_HyprePreconditionerCPU.cpp) - if(HYPRE_USING_CUDA OR HYPRE_USING_HIP) - list(APPEND TEST_SOURCE_FILES tests/test_HyprePreconditionerGPU.cpp) - endif() -endif() - list (APPEND TEST_DATA_FILES tests/equil_base.DATA tests/equil_capillary.DATA diff --git a/opm-simulators-prereqs.cmake b/opm-simulators-prereqs.cmake index 2af64605f..453a80102 100644 --- a/opm-simulators-prereqs.cmake +++ b/opm-simulators-prereqs.cmake @@ -57,8 +57,6 @@ set (opm-simulators_DEPS # packages from ROCm framework "rocblas" "rocsparse" - # HYPRE solver library - "HYPRE" # OPM dependency "opm-common REQUIRED" "opm-grid REQUIRED"