Skip to content
Snippets Groups Projects
Commit a3aaecfd authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Revert unwanted inclusion of threadpool chunking

parent 09b53141
Branches
Tags
1 merge request!266Cube root
...@@ -59,22 +59,14 @@ void *threadpool_runner(void *data) { ...@@ -59,22 +59,14 @@ void *threadpool_runner(void *data) {
pthread_mutex_unlock(&tp->thread_mutex); pthread_mutex_unlock(&tp->thread_mutex);
/* The index of the mapping task we will work on next. */ /* The index of the mapping task we will work on next. */
while (1) { size_t task_ind;
/* Desired chunk size. */ while ((task_ind = atomic_add(&tp->map_data_count, tp->map_data_chunk)) <
size_t chunk_size = tp->map_data_size) {
(tp->map_data_size - tp->map_data_count) / (2 * tp->num_threads); const int num_elements = task_ind + tp->map_data_chunk > tp->map_data_size
if (chunk_size > tp->map_data_chunk) chunk_size = tp->map_data_chunk; ? tp->map_data_size - task_ind
if (chunk_size < 1) chunk_size = 1; : tp->map_data_chunk;
/* 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. */
tp->map_function((char *)tp->map_data + (tp->map_data_stride * task_ind), 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);
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment