From 0fe457767bd9e1be09cdeb02d442e231febbceb9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com>
Date: Thu, 17 Oct 2024 19:15:55 +0200
Subject: [PATCH] Set maximum number of threads to 8 for unit tests

---
 tests/mpi_test_main.cpp | 2 +-
 tests/test_main.cpp     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/mpi_test_main.cpp b/tests/mpi_test_main.cpp
index 728845ac4..cd7447977 100644
--- a/tests/mpi_test_main.cpp
+++ b/tests/mpi_test_main.cpp
@@ -28,7 +28,7 @@ main(int argc, char* argv[])
   parallel::Messenger::create(argc, argv);
 
   const int nb_max_threads = std::max(std::thread::hardware_concurrency(), 1u);
-  int nb_threads           = std::max(nb_max_threads / parallel::Messenger::getInstance().size(), 1ul);
+  int nb_threads           = std::min(std::max(nb_max_threads / parallel::Messenger::getInstance().size(), 1ul), 8ul);
 
   Catch::Session session;
 
diff --git a/tests/test_main.cpp b/tests/test_main.cpp
index 84b15f758..c4fca371e 100644
--- a/tests/test_main.cpp
+++ b/tests/test_main.cpp
@@ -23,7 +23,7 @@ int
 main(int argc, char* argv[])
 {
   parallel::Messenger::create(argc, argv);
-  int nb_threads = std::max(std::thread::hardware_concurrency() / 2, 1u);
+  int nb_threads = std::min(std::max(std::thread::hardware_concurrency() / 2, 1u), 8u);
 
   Catch::Session session;
 
-- 
GitLab