From 2ee180eab678c0b21e92aa0175ad93528d9009ae Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 12 Dec 2012 07:20:34 +0000 Subject: add threshold for bmesh & openmp so its not used with low poly meshes, BM_OMP_LIMIT may need tweaking. --- source/blender/bmesh/bmesh_class.h | 1 + source/blender/bmesh/intern/bmesh_marking.c | 6 +++--- source/blender/bmesh/intern/bmesh_mesh.c | 4 ++-- source/blender/bmesh/intern/bmesh_operators.c | 8 ++++---- source/blender/editors/mesh/editmesh_utils.c | 4 ++-- 5 files changed, 12 insertions(+), 11 deletions(-) (limited to 'source/blender') diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h index 4a370a24c7d..7520164bf61 100644 --- a/source/blender/bmesh/bmesh_class.h +++ b/source/blender/bmesh/bmesh_class.h @@ -277,5 +277,6 @@ enum { * but should not error on valid cases */ #define BM_LOOP_RADIAL_MAX 10000 #define BM_NGON_MAX 100000 +#define BM_OMP_LIMIT 10000 #endif /* __BMESH_CLASS_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 6093547150c..b1ec4cde44b 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -165,7 +165,7 @@ void BM_mesh_deselect_flush(BMesh *bm) int ok; /* we can use 2 sections here because the second loop isnt checking edge selection */ -#pragma omp parallel sections +#pragma omp parallel sections if (bm->totedge + bm->totface >= BM_OMP_LIMIT) { #pragma omp section { @@ -227,7 +227,7 @@ void BM_mesh_select_flush(BMesh *bm) int ok; /* we can use 2 sections here because the second loop isnt checking edge selection */ -#pragma omp parallel sections +#pragma omp parallel sections if (bm->totedge + bm->totface >= BM_OMP_LIMIT) { #pragma omp section { @@ -848,7 +848,7 @@ void BM_mesh_elem_hflag_disable_test(BMesh *bm, const char htype, const char hfl /* fast path for deselect all, avoid topology loops * since we know all will be de-selected anyway. */ -#pragma omp parallel for schedule(dynamic) +#pragma omp parallel for schedule(dynamic) if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) for (i = 0; i < 3; i++) { BMIter iter; BMElem *ele; diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index 8d5bf46a6e5..015c040dc95 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -71,7 +71,7 @@ void BM_mesh_elem_toolflags_ensure(BMesh *bm) bm->etoolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), max_ii(512, bm->totedge), 512, 0); bm->ftoolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), max_ii(512, bm->totface), 512, 0); -#pragma omp parallel sections +#pragma omp parallel sections if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) { #pragma omp section { @@ -468,7 +468,7 @@ void BM_mesh_elem_index_ensure(BMesh *bm, const char hflag) BM_ELEM_INDEX_VALIDATE(bm, "Should Never Fail!", __func__); #endif -#pragma omp parallel sections +#pragma omp parallel sections if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) { #pragma omp section { diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index f7dcb8ba483..fbf51b7dfdf 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -599,7 +599,7 @@ void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *UNUSED(op), const char hty BMElemF *ele; int i; -#pragma omp parallel for schedule(dynamic) +#pragma omp parallel for schedule(dynamic) if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) for (i = 0; i < 3; i++) { if (htype & flag_types[i]) { BM_ITER_MESH (ele, &iter, bm, iter_types[i]) { @@ -1176,7 +1176,7 @@ static void bmo_flag_layer_alloc(BMesh *bm) bm->etoolflagpool = BLI_mempool_create(sizeof(BMFlagLayer) * bm->totflags, max_ii(512, bm->totedge), 512, 0); bm->ftoolflagpool = BLI_mempool_create(sizeof(BMFlagLayer) * bm->totflags, max_ii(512, bm->totface), 512, 0); -#pragma omp parallel sections +#pragma omp parallel sections if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) { #pragma omp section { @@ -1257,7 +1257,7 @@ static void bmo_flag_layer_free(BMesh *bm) bm->etoolflagpool = BLI_mempool_create(new_totflags_size, bm->totedge, 512, 0); bm->ftoolflagpool = BLI_mempool_create(new_totflags_size, bm->totface, 512, 0); -#pragma omp parallel sections +#pragma omp parallel sections if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) { #pragma omp section { @@ -1328,7 +1328,7 @@ static void bmo_flag_layer_clear(BMesh *bm) BMIter iter; const int totflags_offset = bm->totflags - 1; -#pragma omp parallel sections +#pragma omp parallel sections if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) { /* now go through and memcpy all the flag */ #pragma omp section diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 61bce9f8d1e..17a9c7df41b 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -409,7 +409,7 @@ void EDBM_index_arrays_ensure(BMEditMesh *em, const char htype) em->face_index = MEM_mallocN(sizeof(void **) * em->bm->totface, "em->face_index"); } -#pragma omp parallel sections +#pragma omp parallel sections if (em->bm->totvert + em->bm->totedge + em->bm->totface >= BM_OMP_LIMIT) { #pragma omp section { @@ -1306,7 +1306,7 @@ void EDBM_mesh_reveal(BMEditMesh *em) /* Use tag flag to remember what was hidden before all is revealed. * BM_ELEM_HIDDEN --> BM_ELEM_TAG */ -#pragma omp parallel for schedule(dynamic) +#pragma omp parallel for schedule(dynamic) if (em->bm->totvert + em->bm->totedge + em->bm->totface >= BM_OMP_LIMIT) for (i = 0; i < 3; i++) { BM_ITER_MESH (ele, &iter, em->bm, iter_types[i]) { BM_elem_flag_set(ele, BM_ELEM_TAG, BM_elem_flag_test(ele, BM_ELEM_HIDDEN)); -- cgit v1.2.3