From a3aaecfdcd06395d4090c9f13c7b9f2ea29df722 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Mon, 10 Oct 2016 03:11:54 +0100 Subject: [PATCH] Revert unwanted inclusion of threadpool chunking --- src/threadpool.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/threadpool.c b/src/threadpool.c index 6bc887d96c..4ef75954b3 100644 --- a/src/threadpool.c +++ b/src/threadpool.c @@ -59,22 +59,14 @@ void *threadpool_runner(void *data) { pthread_mutex_unlock(&tp->thread_mutex); /* The index of the mapping task we will work on next. */ - while (1) { - /* Desired chunk size. */ - size_t chunk_size = - (tp->map_data_size - tp->map_data_count) / (2 * tp->num_threads); - if (chunk_size > tp->map_data_chunk) chunk_size = tp->map_data_chunk; - if (chunk_size < 1) chunk_size = 1; - - /* Get a chunk and check its size. */ - size_t task_ind = atomic_add(&tp->map_data_count, chunk_size); - if (task_ind >= tp->map_data_size) break; - if (task_ind + chunk_size > tp->map_data_size) - chunk_size = tp->map_data_size - task_ind; - - /* Call the mapper function. */ + size_t task_ind; + while ((task_ind = atomic_add(&tp->map_data_count, tp->map_data_chunk)) < + tp->map_data_size) { + const int num_elements = task_ind + tp->map_data_chunk > tp->map_data_size + ? tp->map_data_size - task_ind + : tp->map_data_chunk; tp->map_function((char *)tp->map_data + (tp->map_data_stride * task_ind), - chunk_size, tp->map_extra_data); + num_elements, tp->map_extra_data); } } } -- GitLab