From 115458b53e5e98ee6bc8cd97fcc38cdc51f89df7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 28 Jul 2014 15:47:32 +0600 Subject: Fix T41193: 2.71 use 100% of CPU at sculpt Issue wascaused by the famous OpenMP crap in MSVC2013, so only way is to use openmp threading if number of BVH nodes is high enough. Made it 8 for now, which seems to work rather fine on my laptop and adult dragon from sintel. But maybe it's to be adjusted a bit more. --- source/blender/blenkernel/intern/pbvh.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern/pbvh.c') diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index e4e6105fe8c..7bdce4e19d5 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -50,6 +50,13 @@ #define STACK_FIXED_DEPTH 100 +/* Setting zero so we can catch bugs in OpenMP/PBVH. */ +#ifdef DEBUG +# define PBVH_OMP_LIMIT 0 +#else +# define PBVH_OMP_LIMIT 8 +#endif + typedef struct PBVHStack { PBVHNode *node; int revisiting; @@ -965,7 +972,7 @@ static void pbvh_update_normals(PBVH *bvh, PBVHNode **nodes, * can only update vertices marked with ME_VERT_PBVH_UPDATE. */ -#pragma omp parallel for private(n) schedule(static) +#pragma omp parallel for private(n) schedule(static) if (totnode > PBVH_OMP_LIMIT) for (n = 0; n < totnode; n++) { PBVHNode *node = nodes[n]; @@ -1009,7 +1016,7 @@ static void pbvh_update_normals(PBVH *bvh, PBVHNode **nodes, } } -#pragma omp parallel for private(n) schedule(static) +#pragma omp parallel for private(n) schedule(static) if (totnode > PBVH_OMP_LIMIT) for (n = 0; n < totnode; n++) { PBVHNode *node = nodes[n]; @@ -1046,7 +1053,7 @@ void pbvh_update_BB_redraw(PBVH *bvh, PBVHNode **nodes, int totnode, int flag) int n; /* update BB, redraw flag */ -#pragma omp parallel for private(n) schedule(static) +#pragma omp parallel for private(n) schedule(static) if (totnode > PBVH_OMP_LIMIT) for (n = 0; n < totnode; n++) { PBVHNode *node = nodes[n]; -- cgit v1.2.3