diff --git a/tests/mpi_test_main.cpp b/tests/mpi_test_main.cpp index 51b222c08669e17f2e15e4b458f5210484e126b3..10314a4dc3b071aa065c36820261e7f596ab7a25 100644 --- a/tests/mpi_test_main.cpp +++ b/tests/mpi_test_main.cpp @@ -18,12 +18,17 @@ #include <cstdlib> #include <filesystem> +#include <thread> int main(int argc, char* argv[]) { parallel::Messenger::create(argc, argv); - Kokkos::initialize({4, -1, -1, true}); + + const int nb_max_threads = std::max(std::thread::hardware_concurrency(), 1u); + const int nb_threads = std::max(nb_max_threads / parallel::Messenger::getInstance().size(), 1ul); + + Kokkos::initialize({nb_threads, -1, -1, true}); PETScWrapper::initialize(argc, argv); @@ -56,6 +61,9 @@ main(int argc, char* argv[]) session.useConfigData(data); } + std::cout << "Using " << nb_threads << " threads per process [" << nb_threads << "x" + << parallel::Messenger::getInstance().size() << "]\n"; + // Disable outputs from tested classes to the standard output std::cout.setstate(std::ios::badbit); diff --git a/tests/test_main.cpp b/tests/test_main.cpp index 91d9a080ae7fc9957a2088bd9213217b1d3d52f5..3eff2f31167d8aa3e6a776d8daaf3b00e75316c9 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -15,11 +15,15 @@ #include <MeshDataBaseForTests.hpp> +#include <thread> + int main(int argc, char* argv[]) { parallel::Messenger::create(argc, argv); - Kokkos::initialize({4, -1, -1, true}); + const int nb_threads = std::max(std::thread::hardware_concurrency(), 1u); + + Kokkos::initialize({nb_threads, -1, -1, true}); PETScWrapper::initialize(argc, argv); SLEPcWrapper::initialize(argc, argv); @@ -32,6 +36,8 @@ main(int argc, char* argv[]) if (config.listReporters() or config.listTags() or config.listTests()) { result = session.run(); } else { + std::cout << "Using " << nb_threads << " threads\n"; + // Disable outputs from tested classes to the standard output std::cout.setstate(std::ios::badbit);