Make benchmarks work with most recent TBB

This commit is contained in:
Kenneth Moreland 2021-06-15 10:47:34 -06:00
parent 2589e5b740
commit 218429fd6b
4 changed files with 36 additions and 9 deletions

@ -22,7 +22,7 @@
#include <sstream>
#ifdef VTKM_ENABLE_TBB
#include <tbb/task_scheduler_init.h>
#include <tbb/tbb.h>
#endif // TBB
// For the TBB implementation, the number of threads can be customized using a
@ -112,8 +112,13 @@ int main(int argc, char* argv[])
}
// Handle NumThreads command-line arg:
// TODO: Use the VTK-m library to set the number of threads (when that becomes available).
#ifdef VTKM_ENABLE_TBB
#if TBB_VERSION_MAJOR >= 2020
int numThreads = tbb::task_arena{}.max_concurrency();
#else
int numThreads = tbb::task_scheduler_init::automatic;
#endif
#endif // TBB
if (argc == 3)
@ -130,9 +135,15 @@ int main(int argc, char* argv[])
}
}
// TODO: Use the VTK-m library to set the number of threads (when that becomes available).
#ifdef VTKM_ENABLE_TBB
#if TBB_VERSION_MAJOR >= 2020
// Must not be destroyed as long as benchmarks are running:
tbb::global_control tbbControl(tbb::global_control::max_allowed_parallelism, numThreads);
#else
// Must not be destroyed as long as benchmarks are running:
tbb::task_scheduler_init init(numThreads);
#endif
#endif // TBB
// handle benchmarking related args and run benchmarks:

@ -34,7 +34,7 @@
#include <vtkm/internal/Windows.h>
#ifdef VTKM_ENABLE_TBB
#include <tbb/task_scheduler_init.h>
#include <tbb/tbb.h>
#endif
#ifdef VTKM_ENABLE_OPENMP
#include <omp.h>
@ -1243,8 +1243,13 @@ int main(int argc, char* argv[])
}
// Handle NumThreads command-line arg:
// TODO: Use the VTK-m library to set the number of threads (when that becomes available).
#ifdef VTKM_ENABLE_TBB
#if TBB_VERSION_MAJOR >= 2020
int numThreads = tbb::task_arena{}.max_concurrency();
#else
int numThreads = tbb::task_scheduler_init::automatic;
#endif
#endif // TBB
if (argc == 3)
@ -1261,9 +1266,15 @@ int main(int argc, char* argv[])
}
}
// TODO: Use the VTK-m library to set the number of threads (when that becomes available).
#ifdef VTKM_ENABLE_TBB
#if TBB_VERSION_MAJOR >= 2020
// Must not be destroyed as long as benchmarks are running:
tbb::global_control tbbControl(tbb::global_control::max_allowed_parallelism, numThreads);
#else
// Must not be destroyed as long as benchmarks are running:
tbb::task_scheduler_init init(numThreads);
#endif
#endif // TBB
// handle benchmarking related args and run benchmarks:

@ -55,7 +55,7 @@
#include <type_traits>
#ifdef VTKM_ENABLE_TBB
#include <tbb/task_scheduler_init.h>
#include <tbb/tbb.h>
#endif
#ifdef VTKM_ENABLE_OPENMP
#include <omp.h>
@ -923,11 +923,22 @@ void InitDataSet(int& argc, char** argv)
tetra = (options[TETRA] != nullptr);
// TODO: Use the VTK-m library to set the number of threads (when that becomes available).
#ifdef VTKM_ENABLE_TBB
#if TBB_VERSION_MAJOR >= 2020
if (numThreads < 1)
{
// Ask TBB how many threads are available.
numThreads = tbb::task_arena{}.max_concurrency();
}
// Must not be destroyed as long as benchmarks are running:
tbb::global_control tbbControl(tbb::global_control::max_allowed_parallelism, numThreads);
#else // TBB_VERSION_MAJOR < 2020
// Must not be destroyed as long as benchmarks are running:
tbb::task_scheduler_init init((numThreads > 0) ? numThreads
: tbb::task_scheduler_init::automatic);
#endif
#endif
#ifdef VTKM_ENABLE_OPENMP
omp_set_num_threads((numThreads > 0) ? numThreads : omp_get_max_threads());
#endif

@ -20,12 +20,6 @@
#include <vtkm/filter/ParticleAdvection.h>
#include <vtkm/worklet/particleadvection/EulerIntegrator.h>
#include <vtkm/worklet/particleadvection/RK4Integrator.h>
#ifdef VTKM_ENABLE_TBB
#include <tbb/task_scheduler_init.h>
#endif
#ifdef VTKM_ENABLE_OPENMP
#include <omp.h>
#endif
namespace