From 4bd9fda69ce412c456a7f542b3d4c9076d0875b6 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Wed, 4 Oct 2017 12:35:58 +0100 Subject: COMPMID-603: Fix OMPScheduler. Adds ThreadInfo in the OMPScheduler. Change-Id: I760ff9ea8af0431e024b4a4b1fc77ff88980f51a Reviewed-on: http://mpd-gerrit.cambridge.arm.com/90158 Reviewed-by: Michalis Spyrou Reviewed-by: Anthony Barbier Tested-by: Anthony Barbier --- src/runtime/OMP/OMPScheduler.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/runtime/OMP') diff --git a/src/runtime/OMP/OMPScheduler.cpp b/src/runtime/OMP/OMPScheduler.cpp index be8164121e..1dd2511990 100644 --- a/src/runtime/OMP/OMPScheduler.cpp +++ b/src/runtime/OMP/OMPScheduler.cpp @@ -51,32 +51,34 @@ unsigned int OMPScheduler::num_threads() const void OMPScheduler::set_num_threads(unsigned int num_threads) { const unsigned int num_cores = omp_get_max_threads(); - _num_threads = num_threads == 0 ? num_cores : num_threads; + _num_threads = (num_threads == 0) ? num_cores : num_threads; } void OMPScheduler::schedule(ICPPKernel *kernel, unsigned int split_dimension) { ARM_COMPUTE_ERROR_ON_MSG(!kernel, "The child class didn't set the kernel"); + ThreadInfo info; + info.cpu_info = _info; + const Window &max_window = kernel->window(); const unsigned int num_iterations = max_window.num_iterations(split_dimension); - const unsigned int num_threads = std::min(num_iterations, _num_threads); + info.num_threads = std::min(num_iterations, _num_threads); - if(!kernel->is_parallelisable() || 1 == num_threads) + if(!kernel->is_parallelisable() || info.num_threads == 1) { - kernel->run(max_window); + kernel->run(max_window, info); } else { - #pragma omp parallel num_threads(num_threads) + #pragma omp parallel num_threads(info.num_threads) { #pragma omp for - for(unsigned int t = 0; t < num_threads; ++t) + for(int t = 0; t < info.num_threads; ++t) { - Window win = max_window.split_window(split_dimension, t, num_threads); - win.set_thread_id(t); - win.set_num_threads(num_threads); - kernel->run(win); + Window win = max_window.split_window(split_dimension, t, info.num_threads); + info.thread_id = t; + kernel->run(win, info); } } } -- cgit v1.2.1