BLI_task: change BLI_task_parallel_range_ex() to just take a bool whether to use threading or not, instead of threshold.
From recent experience, turns out we often do want to use something else than basic range of parallelized forloop as control parameter over threads usage, so now BLI func only takes a boolean, and caller defines best check for its own case.
This commit is contained in:
@@ -119,7 +119,7 @@ void BLI_task_parallel_range_ex(
|
|||||||
void *userdata_chunk,
|
void *userdata_chunk,
|
||||||
const size_t userdata_chunk_size,
|
const size_t userdata_chunk_size,
|
||||||
TaskParallelRangeFunc func,
|
TaskParallelRangeFunc func,
|
||||||
const int range_threshold,
|
const bool use_threading,
|
||||||
const bool use_dynamic_scheduling);
|
const bool use_dynamic_scheduling);
|
||||||
void BLI_task_parallel_range(
|
void BLI_task_parallel_range(
|
||||||
int start, int stop,
|
int start, int stop,
|
||||||
|
@@ -874,14 +874,9 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array,
|
|||||||
cb_data.i = i;
|
cb_data.i = i;
|
||||||
cb_data.depth = depth;
|
cb_data.depth = depth;
|
||||||
|
|
||||||
if (num_leafs > KDOPBVH_THREAD_LEAF_THRESHOLD) {
|
BLI_task_parallel_range_ex(
|
||||||
BLI_task_parallel_range_ex(i, end_j, &cb_data, NULL, 0, non_recursive_bvh_div_nodes_task_cb, 0, false);
|
i, end_j, &cb_data, NULL, 0, non_recursive_bvh_div_nodes_task_cb,
|
||||||
}
|
num_leafs > KDOPBVH_THREAD_LEAF_THRESHOLD, false);
|
||||||
else {
|
|
||||||
for (j = i; j < end_j; j++) {
|
|
||||||
non_recursive_bvh_div_nodes_task_cb(&cb_data, NULL, j);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1266,14 +1261,9 @@ BVHTreeOverlap *BLI_bvhtree_overlap(
|
|||||||
data[j].thread = j;
|
data[j].thread = j;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tree1->totleaf > KDOPBVH_THREAD_LEAF_THRESHOLD) {
|
BLI_task_parallel_range_ex(
|
||||||
BLI_task_parallel_range_ex(0, thread_num, data, NULL, 0, bvhtree_overlap_task_cb, 0, false);
|
0, thread_num, data, NULL, 0, bvhtree_overlap_task_cb,
|
||||||
}
|
tree1->totleaf > KDOPBVH_THREAD_LEAF_THRESHOLD, false);
|
||||||
else {
|
|
||||||
for (j = 0; j < thread_num; j++) {
|
|
||||||
bvhtree_overlap_task_cb(data, NULL, j);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0; j < thread_num; j++)
|
for (j = 0; j < thread_num; j++)
|
||||||
total += BLI_stack_count(data[j].overlap);
|
total += BLI_stack_count(data[j].overlap);
|
||||||
|
@@ -643,8 +643,8 @@ static void parallel_range_func(
|
|||||||
* (similar to OpenMP's firstprivate).
|
* (similar to OpenMP's firstprivate).
|
||||||
* \param userdata_chunk_size Memory size of \a userdata_chunk.
|
* \param userdata_chunk_size Memory size of \a userdata_chunk.
|
||||||
* \param func Callback function.
|
* \param func Callback function.
|
||||||
* \param range_threshold Minimum size of processed range to start using tasks
|
* \param use_threading If \a true, actually split-execute loop in threads, else just do a sequential forloop
|
||||||
* (below this, loop is done in main thread only).
|
* (allows caller to use any kind of test to switch on parallelization or not).
|
||||||
* \param use_dynamic_scheduling If \a true, the whole range is divided in a lot of small chunks (of size 32 currently),
|
* \param use_dynamic_scheduling If \a true, the whole range is divided in a lot of small chunks (of size 32 currently),
|
||||||
* otherwise whole range is split in a few big chunks (num_threads * 2 chunks currently).
|
* otherwise whole range is split in a few big chunks (num_threads * 2 chunks currently).
|
||||||
*/
|
*/
|
||||||
@@ -654,7 +654,7 @@ void BLI_task_parallel_range_ex(
|
|||||||
void *userdata_chunk,
|
void *userdata_chunk,
|
||||||
const size_t userdata_chunk_size,
|
const size_t userdata_chunk_size,
|
||||||
TaskParallelRangeFunc func,
|
TaskParallelRangeFunc func,
|
||||||
const int range_threshold,
|
const bool use_threading,
|
||||||
const bool use_dynamic_scheduling)
|
const bool use_dynamic_scheduling)
|
||||||
{
|
{
|
||||||
TaskScheduler *task_scheduler;
|
TaskScheduler *task_scheduler;
|
||||||
@@ -667,7 +667,7 @@ void BLI_task_parallel_range_ex(
|
|||||||
/* If it's not enough data to be crunched, don't bother with tasks at all,
|
/* If it's not enough data to be crunched, don't bother with tasks at all,
|
||||||
* do everything from the main thread.
|
* do everything from the main thread.
|
||||||
*/
|
*/
|
||||||
if (stop - start < range_threshold) {
|
if (!use_threading) {
|
||||||
const bool use_userdata_chunk = (userdata_chunk_size != 0) && (userdata_chunk != NULL);
|
const bool use_userdata_chunk = (userdata_chunk_size != 0) && (userdata_chunk != NULL);
|
||||||
void *userdata_chunk_local = NULL;
|
void *userdata_chunk_local = NULL;
|
||||||
|
|
||||||
@@ -733,7 +733,7 @@ void BLI_task_parallel_range(
|
|||||||
void *userdata,
|
void *userdata,
|
||||||
TaskParallelRangeFunc func)
|
TaskParallelRangeFunc func)
|
||||||
{
|
{
|
||||||
BLI_task_parallel_range_ex(start, stop, userdata, NULL, 0, func, 64, false);
|
BLI_task_parallel_range_ex(start, stop, userdata, NULL, 0, func, (stop - start) > 64, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef MALLOCA
|
#undef MALLOCA
|
||||||
|
@@ -210,7 +210,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
|||||||
UVWarpData data = {.mpoly = mpoly, .mloop = mloop, .mloopuv = mloopuv,
|
UVWarpData data = {.mpoly = mpoly, .mloop = mloop, .mloopuv = mloopuv,
|
||||||
.dvert = dvert, .defgrp_index = defgrp_index,
|
.dvert = dvert, .defgrp_index = defgrp_index,
|
||||||
.warp_mat = warp_mat, .axis_u = axis_u, .axis_v = axis_v};
|
.warp_mat = warp_mat, .axis_u = axis_u, .axis_v = axis_v};
|
||||||
BLI_task_parallel_range_ex(0, numPolys, &data, NULL, 0, uv_warp_compute, 1000, false);
|
BLI_task_parallel_range_ex(0, numPolys, &data, NULL, 0, uv_warp_compute, numPolys > 1000, false);
|
||||||
|
|
||||||
dm->dirty |= DM_DIRTY_TESS_CDLAYERS;
|
dm->dirty |= DM_DIRTY_TESS_CDLAYERS;
|
||||||
|
|
||||||
|
@@ -176,7 +176,8 @@ static void get_vert2geom_distance(int numVerts, float (*v_cos)[3],
|
|||||||
data.dist[1] = dist_e;
|
data.dist[1] = dist_e;
|
||||||
data.dist[2] = dist_f;
|
data.dist[2] = dist_f;
|
||||||
|
|
||||||
BLI_task_parallel_range_ex(0, numVerts, &data, &data_chunk, sizeof(data_chunk), vert2geom_task_cb, 10000, false);
|
BLI_task_parallel_range_ex(
|
||||||
|
0, numVerts, &data, &data_chunk, sizeof(data_chunk), vert2geom_task_cb, numVerts > 10000, false);
|
||||||
|
|
||||||
if (dist_v)
|
if (dist_v)
|
||||||
free_bvhtree_from_mesh(&treeData_v);
|
free_bvhtree_from_mesh(&treeData_v);
|
||||||
|
Reference in New Issue
Block a user