Skip to content
Snippets Groups Projects
Commit 743a0d8f authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Change thread allocation policy for tests to avoid oversubscription

Oversubscription can degrade parallel performances substantially
parent 53bc01a0
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment