diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c0f69fcf6395a96f88e74e9143e8e85730ba66e..4cca59ccceafa53cb64b475945c97f1a960ebbaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,7 +142,7 @@ endif() # Search for ParMETIS find_package(ParMETIS) -if(PARMETIS_LIBRARIES) +if(PARMETIS_LIBRARIES AND MPI_FOUND) add_library(PkgConfig::ParMETIS STATIC IMPORTED) set_property(TARGET PkgConfig::ParMETIS PROPERTY IMPORTED_LOCATION "${PARMETIS_LIBRARIES}") @@ -158,9 +158,7 @@ endif() find_package(PTScotch) -set(PUGS_HAS_PTSCOTCH ${PTScotch_FOUND}) - -if (PTScotch_FOUND) +if (PTScotch_FOUND AND MPI_FOUND) add_library(PkgConfig::PTScotch STATIC IMPORTED) set_property(TARGET PkgConfig::PTScotch PROPERTY IMPORTED_LOCATION "${PTSCOTCH_LIBRARY}") @@ -169,8 +167,10 @@ if (PTScotch_FOUND) set(PTSCOTCH_TARGET PkgConfig::PTScotch) include_directories(SYSTEM "${PTSCOTCH_INCLUDE_DIR}") + set(PUGS_HAS_PTSCOTCH TRUE) else() set(PTSCOTCH_LIBRARY "") + unset(PUGS_HAS_PTSCOTCH) endif() #------------------------------------------------------ @@ -842,9 +842,9 @@ if (MPI_FOUND) message(" MPI: ${MPI_CXX_LIBRARY_VERSION_STRING}") else() if (PUGS_ENABLE_MPI MATCHES "^OFF$") - message(" MPI: deactivated!") - elseif(NOT PARMETIS_LIBRARIES) - message(" MPI: deactivated: ParMETIS cannot be found!") + message(" MPI: explicitly deactivated!") + elseif((NOT PUGS_HAS_PARMETIS) and (NOT PUGS_HAS_PTSCOTCH)) + message(" MPI: deactivated: ParMETIS and PTScotch cannot be found!") else() if (PUGS_ENABLE_MPI MATCHES "^(AUTO|ON)$") message(" MPI: not found!") @@ -854,6 +854,26 @@ else() endif() endif() +if (PUGS_HAS_PARMETIS) + message(" ParMETIS: ${PARMETIS_LIBRARIES}") +else() + if (PUGS_HAS_MPI) + message(" ParMETIS: not found!") + else() + message(" ParMETIS: deactivated (MPI not found)") + endif() +endif() + +if (PUGS_HAS_PTSCOTCH) + message(" PTScotch: ${PTSCOTCH_LIBRARIES}") +else() + if (PUGS_HAS_MPI) + message(" PTScotch: not found!") + else() + message(" PTScotch: deactivated (MPI not found)") + endif() +endif() + if (PETSC_FOUND) message(" PETSc: ${PETSC_VERSION}") else() diff --git a/README.md b/README.md index 473b27b07ed129357a206fa59c4af7d74471de52..fc6d9da70cbc572b290c0397668724df223ff15d 100644 --- a/README.md +++ b/README.md @@ -54,12 +54,12 @@ functionalities or development tools. `pugs` integrates MPI support and should compile with any MPI-3 implementation. However in order to dispatch meshes on MPI processes -`pugs` requires `ParMETIS`. Without, MPI support will be automatically -deactivated. +`pugs` requires `ParMETIS` or `PTScotch`. Without one of them, the MPI +support will be automatically deactivated. The easiest way to enable MPI support on Debian-like systems is to run ```shell -apt install libparmetis-dev +apt install libparmetis-dev libscotch-dev ``` #### `PETSc` diff --git a/src/utils/BuildInfo.cpp b/src/utils/BuildInfo.cpp index 2413bdbaeb5712e3b7eaf96fd9d09df5e8f0a6e0..8cdb5fc83a61e4c18ed2df1a24e3ec5d52fe7bdf 100644 --- a/src/utils/BuildInfo.cpp +++ b/src/utils/BuildInfo.cpp @@ -9,6 +9,14 @@ #include <mpi.h> #endif // PUGS_HAS_MPI +#ifdef PUGS_HAS_PARMETIS +#include <parmetis.h> +#endif // PUGS_HAS_PARMETIS + +#ifdef PUGS_HAS_PTSCOTCH +#include <ptscotch.h> +#endif // PUGS_HAS_PTSCOTCH + #ifdef PUGS_HAS_PETSC #include <petsc.h> #endif // PUGS_HAS_PETSC @@ -64,6 +72,27 @@ BuildInfo::mpiLibrary() #endif // PUGS_HAS_MPI } +std::string +BuildInfo::parmetisLibrary() +{ +#ifdef PUGS_HAS_PARMETIS + return stringify(PARMETIS_MAJOR_VERSION) + "." + stringify(PARMETIS_MINOR_VERSION) + "." + + stringify(PARMETIS_SUBMINOR_VERSION); +#else // PUGS_HAS_PARMETIS + return "none"; +#endif // PUGS_HAS_PARMETIS +} + +std::string +BuildInfo::ptscotchLibrary() +{ +#ifdef PUGS_HAS_PTSCOTCH + return stringify(SCOTCH_VERSION) + "." + stringify(SCOTCH_RELEASE) + "." + stringify(SCOTCH_PATCHLEVEL); +#else // PUGS_HAS_PTSCOTCH + return "none"; +#endif // PUGS_HAS_PTSCOTCH +} + std::string BuildInfo::petscLibrary() { diff --git a/src/utils/BuildInfo.hpp b/src/utils/BuildInfo.hpp index 86f7c04f035827a936a00c9b1f42e304e33e7b26..0142b5d088e6323858116c7949cb7b0b681e2acc 100644 --- a/src/utils/BuildInfo.hpp +++ b/src/utils/BuildInfo.hpp @@ -9,6 +9,8 @@ struct BuildInfo static std::string compiler(); static std::string kokkosDevices(); static std::string mpiLibrary(); + static std::string parmetisLibrary(); + static std::string ptscotchLibrary(); static std::string petscLibrary(); static std::string slepcLibrary(); static std::string eigen3Library(); diff --git a/src/utils/PugsUtils.cpp b/src/utils/PugsUtils.cpp index ac64a50cfe0b026fe0185d79e30d4f6d648317ac..356869699a7d76f04648dce9a95d4d091a619df2 100644 --- a/src/utils/PugsUtils.cpp +++ b/src/utils/PugsUtils.cpp @@ -62,6 +62,8 @@ pugsBuildInfo() os << "compiler: " << rang::style::bold << BuildInfo::compiler() << rang::style::reset << '\n'; os << "kokkos: " << rang::style::bold << BuildInfo::kokkosDevices() << rang::style::reset << '\n'; os << "MPI: " << rang::style::bold << BuildInfo::mpiLibrary() << rang::style::reset << '\n'; + os << "ParMETIS: " << rang::style::bold << BuildInfo::parmetisLibrary() << rang::style::reset << '\n'; + os << "PTScotch: " << rang::style::bold << BuildInfo::ptscotchLibrary() << rang::style::reset << '\n'; os << "PETSc: " << rang::style::bold << BuildInfo::petscLibrary() << rang::style::reset << '\n'; os << "SLEPc: " << rang::style::bold << BuildInfo::slepcLibrary() << rang::style::reset << '\n'; os << "Eigen3: " << rang::style::bold << BuildInfo::eigen3Library() << rang::style::reset << '\n'; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1dd13e6e3ce1f23c31e046db7597a1ed2ffb947d..e0449ebcf074c55288cfc22b7fa546590ef04e98 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -142,6 +142,7 @@ add_executable (unit_tests test_OStream.cpp test_ParallelChecker_write.cpp test_ParseError.cpp + test_PartitionerOptions.cpp test_PETScUtils.cpp test_PrimalToDiamondDualConnectivityDataMapper.cpp test_PrimalToDual1DConnectivityDataMapper.cpp diff --git a/tests/test_BuildInfo.cpp b/tests/test_BuildInfo.cpp index 9414902f4d63b498e68bffd4d84b3cae32a165bd..02cf31adc012a1d900d5540838a946e828ac301c 100644 --- a/tests/test_BuildInfo.cpp +++ b/tests/test_BuildInfo.cpp @@ -12,6 +12,14 @@ #include <mpi.h> #endif // PUGS_HAS_MPI +#ifdef PUGS_HAS_PARMETIS +#include <parmetis.h> +#endif // PUGS_HAS_PARMETIS + +#ifdef PUGS_HAS_PTSCOTCH +#include <ptscotch.h> +#endif // PUGS_HAS_PTSCOTCH + #ifdef PUGS_HAS_PETSC #include <petsc.h> #endif // PUGS_HAS_PETSC @@ -57,6 +65,30 @@ TEST_CASE("BuildInfo", "[utils]") #endif // PUGS_HAS_MPI } + SECTION("ParMETIS") + { +#ifdef PUGS_HAS_PARMETIS + const std::string parmetis_library = stringify(PARMETIS_MAJOR_VERSION) + "." + stringify(PARMETIS_MINOR_VERSION) + + "." + stringify(PARMETIS_SUBMINOR_VERSION); + + REQUIRE(BuildInfo::parmetisLibrary() == parmetis_library); +#else + REQUIRE(BuildInfo::parmetisLibrary() == "none"); +#endif // PUGS_HAS_PARMETIS + } + + SECTION("PTScotch") + { +#ifdef PUGS_HAS_PTSCOTCH + const std::string ptscotch_library = + stringify(SCOTCH_VERSION) + "." + stringify(SCOTCH_RELEASE) + "." + stringify(SCOTCH_PATCHLEVEL); + + REQUIRE(BuildInfo::ptscotchLibrary() == ptscotch_library); +#else + REQUIRE(BuildInfo::ptscotchLibrary() == "none"); +#endif // PUGS_HAS_PTSCOTCH + } + SECTION("petsc") { #ifdef PUGS_HAS_PETSC diff --git a/tests/test_Partitioner.cpp b/tests/test_Partitioner.cpp index 3638a3926c9487cef416b4f91118c1920ab6006e..67ddbb11161d5ab95a065c5f1f7b6bb0dbfb1ad3 100644 --- a/tests/test_Partitioner.cpp +++ b/tests/test_Partitioner.cpp @@ -88,8 +88,8 @@ TEST_CASE("Partitioner", "[utils]") REQUIRE(assigned_ranks.size() == parallel::size()); } #else // PUGS_HAS_PARMETIS - REQUIRE(min(partitionned == 0)); - REQUIRE(max(partitionned == 0)); + REQUIRE(min(partitioned) == 0); + REQUIRE(max(partitioned) == 0); #endif // PUGS_HAS_PARMETIS } @@ -113,8 +113,8 @@ TEST_CASE("Partitioner", "[utils]") REQUIRE(assigned_ranks.size() == parallel::size()); } #else // PUGS_HAS_PTSCOTCH - REQUIRE(min(partitionned == 0)); - REQUIRE(max(partitionned == 0)); + REQUIRE(min(partitioned) == 0); + REQUIRE(max(partitioned) == 0); #endif // PUGS_HAS_PTSCOTCH } } diff --git a/tests/test_PartitionerOptions.cpp b/tests/test_PartitionerOptions.cpp index 67c016221239758914d6f457775c72d36eee1dc2..9f0605b4e15861abad28599006c1b53392d9d54d 100644 --- a/tests/test_PartitionerOptions.cpp +++ b/tests/test_PartitionerOptions.cpp @@ -9,9 +9,10 @@ TEST_CASE("PartitionerOptions", "[utils]") { SECTION("name") { - REQUIRE(name(PartitionerLibrary::parmetis) == "ParMetis"); + REQUIRE(name(PartitionerLibrary::parmetis) == "ParMETIS"); REQUIRE(name(PartitionerLibrary::ptscotch) == "PTScotch"); - REQUIRE_THROWS_WITH(PartitionerLibrary::PT__end, "unexpected error: Partitioner library name is not defined!"); + REQUIRE_THROWS_WITH(name(PartitionerLibrary::PT__end), + "unexpected error: Partitioner library name is not defined!"); WARN("not finished"); } diff --git a/tests/test_PugsUtils.cpp b/tests/test_PugsUtils.cpp index 5ba8817fcaa34ddf31f0955ed9fd118f841bd87d..175ed929467e17bc1fd29e2279f60d3a04b1a1c9 100644 --- a/tests/test_PugsUtils.cpp +++ b/tests/test_PugsUtils.cpp @@ -49,6 +49,8 @@ TEST_CASE("PugsUtils", "[utils]") os << "compiler: " << rang::style::bold << BuildInfo::compiler() << rang::style::reset << '\n'; os << "kokkos: " << rang::style::bold << BuildInfo::kokkosDevices() << rang::style::reset << '\n'; os << "MPI: " << rang::style::bold << BuildInfo::mpiLibrary() << rang::style::reset << '\n'; + os << "ParMETIS: " << rang::style::bold << BuildInfo::parmetisLibrary() << rang::style::reset << '\n'; + os << "PTScotch: " << rang::style::bold << BuildInfo::ptscotchLibrary() << rang::style::reset << '\n'; os << "PETSc: " << rang::style::bold << BuildInfo::petscLibrary() << rang::style::reset << '\n'; os << "SLEPc: " << rang::style::bold << BuildInfo::slepcLibrary() << rang::style::reset << '\n'; os << "Eigen3: " << rang::style::bold << BuildInfo::eigen3Library() << rang::style::reset << '\n';