in benchmarks/simple_pool_benchmark.cpp [72:92]
void BM_tbb2(benchmark::State& state) {
const int num_threads = state.range(0);
const int num_elements = state.range(1);
for (auto UNUSED_VAR : state) {
tbb::task_scheduler_init initsched(num_threads);
tbb::task_group g;
for (int i = 0; i < num_elements; ++i) {
g.run([num_elements]() {
int num = std::sqrt(num_elements);
tbb::task_group g2;
for (int j = 0; j < num; ++j) {
auto* work = g_work;
g2.run([j, work]() { work[tid() & 1023] += j; });
}
g2.wait();
});
}
g.wait();
}
}