From fc863c63e6327469d61330231be3d0a754c6696b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 4 Dec 2023 17:55:48 +0100 Subject: [PATCH] BMesh: don't make threading threshold dependent on debug/release build While it may be useful to detect threading issues for low poly meshes in debug builds, it can also cause confusion when one breaks but not the other. Further, having this logic for just a handlful bmesh functions while everything else does not makes little sense. --- source/blender/bmesh/bmesh_class.hh | 8 ++------ source/blender/bmesh/intern/bmesh_marking.cc | 4 ++-- source/blender/bmesh/intern/bmesh_mesh_normals.cc | 6 +++--- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/source/blender/bmesh/bmesh_class.hh b/source/blender/bmesh/bmesh_class.hh index db3a854b31e..47cb2b23435 100644 --- a/source/blender/bmesh/bmesh_class.hh +++ b/source/blender/bmesh/bmesh_class.hh @@ -664,9 +664,5 @@ typedef bool (*BMLoopPairFilterFunc)(const BMLoop *, const BMLoop *, void *user_ #define BM_LOOP_RADIAL_MAX 10000 #define BM_NGON_MAX 100000 -/* setting zero so we can catch bugs in OpenMP/BMesh */ -#ifdef DEBUG -# define BM_OMP_LIMIT 0 -#else -# define BM_OMP_LIMIT 10000 -#endif +/* Minimum number of elements before using threading. */ +#define BM_THREAD_LIMIT 10000 diff --git a/source/blender/bmesh/intern/bmesh_marking.cc b/source/blender/bmesh/intern/bmesh_marking.cc index 78c885e205e..147c8295c24 100644 --- a/source/blender/bmesh/intern/bmesh_marking.cc +++ b/source/blender/bmesh/intern/bmesh_marking.cc @@ -381,7 +381,7 @@ static void bm_mesh_select_mode_flush_vert_to_edge(BMesh *bm) TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); - settings.use_threading = bm->totedge >= BM_OMP_LIMIT; + settings.use_threading = bm->totedge >= BM_THREAD_LIMIT; settings.userdata_chunk = &chunk_data; settings.userdata_chunk_size = sizeof(chunk_data); settings.func_reduce = bm_mesh_select_mode_flush_reduce_fn; @@ -397,7 +397,7 @@ static void bm_mesh_select_mode_flush_edge_to_face(BMesh *bm) TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); - settings.use_threading = bm->totface >= BM_OMP_LIMIT; + settings.use_threading = bm->totface >= BM_THREAD_LIMIT; settings.userdata_chunk = &chunk_data; settings.userdata_chunk_size = sizeof(chunk_data); settings.func_reduce = bm_mesh_select_mode_flush_reduce_fn; diff --git a/source/blender/bmesh/intern/bmesh_mesh_normals.cc b/source/blender/bmesh/intern/bmesh_mesh_normals.cc index ccee6daddff..83aa6316a8f 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_normals.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_normals.cc @@ -212,7 +212,7 @@ static void bm_mesh_verts_calc_normals(BMesh *bm, TaskParallelSettings settings; BLI_parallel_mempool_settings_defaults(&settings); - settings.use_threading = bm->totvert >= BM_OMP_LIMIT; + settings.use_threading = bm->totvert >= BM_THREAD_LIMIT; if (vcos == nullptr) { BM_iter_parallel(bm, BM_VERTS_OF_MESH, bm_vert_calc_normals_cb, nullptr, &settings); @@ -242,7 +242,7 @@ void BM_mesh_normals_update_ex(BMesh *bm, const BMeshNormalsUpdate_Params *param /* Calculate all face normals. */ TaskParallelSettings settings; BLI_parallel_mempool_settings_defaults(&settings); - settings.use_threading = bm->totedge >= BM_OMP_LIMIT; + settings.use_threading = bm->totedge >= BM_THREAD_LIMIT; BM_iter_parallel(bm, BM_FACES_OF_MESH, bm_face_calc_normals_cb, nullptr, &settings); } @@ -1356,7 +1356,7 @@ static void bm_mesh_loops_calc_normals(BMesh *bm, const bool do_rebuild, const float split_angle_cos) { - if (bm->totloop < BM_OMP_LIMIT) { + if (bm->totloop < BM_THREAD_LIMIT) { bm_mesh_loops_calc_normals__single_threaded(bm, vcos, fnos,