File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 11#include < gtest/gtest.h>
2+ #include < tbb/global_control.h>
23
34#include < boost/mpi/communicator.hpp>
45#include < boost/mpi/environment.hpp>
@@ -56,6 +57,12 @@ int main(int argc, char** argv) {
5657 boost::mpi::environment env (argc, argv);
5758 boost::mpi::communicator world;
5859
60+ const char * omp_env = std::getenv (" OMP_NUM_THREADS" );
61+ int num_threads = (omp_env != nullptr ) ? std::atoi (omp_env) : 1 ;
62+
63+ // Limit the number of threads in TBB
64+ tbb::global_control control (tbb::global_control::max_allowed_parallelism, num_threads);
65+
5966 ::testing::InitGoogleTest (&argc, argv);
6067
6168 auto & listeners = ::testing::UnitTest::GetInstance ()->listeners ();
Original file line number Diff line number Diff line change 11#include < gtest/gtest.h>
2+ #include < tbb/global_control.h>
3+
4+ int main (int argc, char ** argv) {
5+ const char * omp_env = std::getenv (" OMP_NUM_THREADS" );
6+ int num_threads = (omp_env != nullptr ) ? std::atoi (omp_env) : 1 ;
7+
8+ // Limit the number of threads in TBB
9+ tbb::global_control control (tbb::global_control::max_allowed_parallelism, num_threads);
210
3- int main (int argc, char **argv) {
411 ::testing::InitGoogleTest (&argc, argv);
512 return RUN_ALL_TESTS ();
613}
You can’t perform that action at this time.
0 commit comments