Fix (unreported) broken BLI_task's forloop func in case we have less iterations that workers.

When called with very small range, `BLI_task_parallel_range_ex()` would generate a zero `chunk_size`,
leading to some infinite looping in `parallel_range_func` due to `parallel_range_next_iter_get` returning
true without actually increasing the counter!

So now, we ensure `chunk_size` and `num_tasks` are always at least 1 (and avoid generating too much tasks too).
This commit is contained in:
Bastien Montagne 2015-12-28 00:28:37 +01:00
parent 7ef10decdb
commit d617de965e
Notes: blender-bot 2024-01-31 11:35:08 +01:00
Referenced by commit fcc2175710, Fix own mistake in rBd617de965ea20e5d5 from late December 2015.
1 changed files with 3 additions and 1 deletions

View File

@ -706,9 +706,11 @@ void BLI_task_parallel_range_ex(
state.chunk_size = 32;
}
else {
state.chunk_size = (stop - start) / (num_tasks);
state.chunk_size = max_ii(1, (stop - start) / (num_tasks));
}
num_tasks = max_ii(1, (stop - start) / state.chunk_size);
for (i = 0; i < num_tasks; i++) {
BLI_task_pool_push(task_pool,
parallel_range_func,