File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 1+ #define _CRT_SECURE_NO_WARNINGS
12#include < gtest/gtest.h>
3+ #include < tbb/global_control.h>
24
35#include < boost/mpi/communicator.hpp>
46#include < boost/mpi/environment.hpp>
@@ -56,6 +58,12 @@ int main(int argc, char** argv) {
5658 boost::mpi::environment env (argc, argv);
5759 boost::mpi::communicator world;
5860
61+ const char * omp_env = std::getenv (" OMP_NUM_THREADS" );
62+ int num_threads = (omp_env != nullptr ) ? std::atoi (omp_env) : 1 ;
63+
64+ // Limit the number of threads in TBB
65+ tbb::global_control control (tbb::global_control::max_allowed_parallelism, num_threads);
66+
5967 ::testing::InitGoogleTest (&argc, argv);
6068
6169 auto & listeners = ::testing::UnitTest::GetInstance ()->listeners ();
Original file line number Diff line number Diff line change 1+ #define _CRT_SECURE_NO_WARNINGS
12#include < gtest/gtest.h>
3+ #include < tbb/global_control.h>
4+
5+ int main (int argc, char ** argv) {
6+ const char * omp_env = std::getenv (" OMP_NUM_THREADS" );
7+ int num_threads = (omp_env != nullptr ) ? std::atoi (omp_env) : 1 ;
8+
9+ // Limit the number of threads in TBB
10+ tbb::global_control control (tbb::global_control::max_allowed_parallelism, num_threads);
211
3- int main (int argc, char **argv) {
412 ::testing::InitGoogleTest (&argc, argv);
513 return RUN_ALL_TESTS ();
614}
You can’t perform that action at this time.
0 commit comments