add threshold for bmesh & openmp so its not used with low poly meshes, BM_OMP_LIMIT may need tweaking.

This commit is contained in:
Campbell Barton
2012-12-12 07:20:34 +00:00
parent 3e8b56b321
commit 2ee180eab6
5 changed files with 12 additions and 11 deletions

View File

@@ -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__ */

View File

@@ -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;

View File

@@ -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
{

View File

@@ -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

View File

@@ -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));