Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions cpp/daal/src/threading/threading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,19 +268,22 @@ DAAL_EXPORT void _daal_static_threader_for(size_t n, const void * a, daal::funct
const size_t nthreads = _daal_threader_get_max_threads();
const size_t nblocks_per_thread = n / nthreads + !!(n % nthreads);

tbb::parallel_for(
tbb::blocked_range<size_t>(0, nthreads, 1),
[&](tbb::blocked_range<size_t> r) {
const size_t tid = r.begin();
const size_t begin = tid * nblocks_per_thread;
const size_t end = n < begin + nblocks_per_thread ? n : begin + nblocks_per_thread;

for (size_t i = begin; i < end; ++i)
{
func(i, tid, a);
}
},
tbb::static_partitioner());
tbb::task_arena tmp_arena(nthreads);
tmp_arena.execute([&] {
tbb::parallel_for(
tbb::blocked_range<size_t>(0, nthreads, 1),
[&](tbb::blocked_range<size_t> r) {
const size_t tid = r.begin();
const size_t begin = tid * nblocks_per_thread;
const size_t end = n < begin + nblocks_per_thread ? n : begin + nblocks_per_thread;

for (size_t i = begin; i < end; ++i)
{
func(i, tid, a);
}
},
tbb::static_partitioner());
});
}
else
{
Expand Down
Loading