Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/intern/task_iterator.c
| Show First 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | static void task_parallel_iterator_do(const TaskParallelSettings *settings, | ||||
| state->iter_shared.spin_lock = &spin_lock; | state->iter_shared.spin_lock = &spin_lock; | ||||
| void *userdata_chunk = settings->userdata_chunk; | void *userdata_chunk = settings->userdata_chunk; | ||||
| const size_t userdata_chunk_size = settings->userdata_chunk_size; | const size_t userdata_chunk_size = settings->userdata_chunk_size; | ||||
| void *userdata_chunk_local = NULL; | void *userdata_chunk_local = NULL; | ||||
| void *userdata_chunk_array = NULL; | void *userdata_chunk_array = NULL; | ||||
| const bool use_userdata_chunk = (userdata_chunk_size != 0) && (userdata_chunk != NULL); | const bool use_userdata_chunk = (userdata_chunk_size != 0) && (userdata_chunk != NULL); | ||||
| TaskPool *task_pool = BLI_task_pool_create(state, TASK_PRIORITY_HIGH); | TaskPool *task_pool = BLI_task_pool_create(state, TASK_PRIORITY_HIGH, TASK_ISOLATION_ON); | ||||
| if (use_userdata_chunk) { | if (use_userdata_chunk) { | ||||
| userdata_chunk_array = MALLOCA(userdata_chunk_size * num_tasks); | userdata_chunk_array = MALLOCA(userdata_chunk_size * num_tasks); | ||||
| } | } | ||||
| for (size_t i = 0; i < num_tasks; i++) { | for (size_t i = 0; i < num_tasks; i++) { | ||||
| if (use_userdata_chunk) { | if (use_userdata_chunk) { | ||||
| userdata_chunk_local = (char *)userdata_chunk_array + (userdata_chunk_size * i); | userdata_chunk_local = (char *)userdata_chunk_array + (userdata_chunk_size * i); | ||||
| ▲ Show 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | if (!use_threading) { | ||||
| for (void *item = BLI_mempool_iterstep(&iter); item != NULL; | for (void *item = BLI_mempool_iterstep(&iter); item != NULL; | ||||
| item = BLI_mempool_iterstep(&iter)) { | item = BLI_mempool_iterstep(&iter)) { | ||||
| func(userdata, item); | func(userdata, item); | ||||
| } | } | ||||
| return; | return; | ||||
| } | } | ||||
| task_pool = BLI_task_pool_create(&state, TASK_PRIORITY_HIGH); | task_pool = BLI_task_pool_create(&state, TASK_PRIORITY_HIGH, TASK_ISOLATION_ON); | ||||
| num_threads = BLI_task_scheduler_num_threads(); | num_threads = BLI_task_scheduler_num_threads(); | ||||
| /* The idea here is to prevent creating task for each of the loop iterations | /* The idea here is to prevent creating task for each of the loop iterations | ||||
| * and instead have tasks which are evenly distributed across CPU cores and | * and instead have tasks which are evenly distributed across CPU cores and | ||||
| * pull next item to be crunched using the threaded-aware BLI_mempool_iter. | * pull next item to be crunched using the threaded-aware BLI_mempool_iter. | ||||
| */ | */ | ||||
| num_tasks = num_threads + 2; | num_tasks = num_threads + 2; | ||||
| Show All 16 Lines | |||||