Enabled openmp multithreading for multires/subsurf again, but only
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 22 Jun 2010 15:09:41 +0000 (15:09 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 22 Jun 2010 15:09:41 +0000 (15:09 +0000)
if there are >= 1 million faces estimated in the resulting mesh.

(merge from render25 branch)

source/blender/blenkernel/intern/CCGSubSurf.c
source/blender/blenkernel/intern/CCGSubSurf.h
source/blender/blenkernel/intern/multires.c

index 8fad398..bbd68fb 100644 (file)
@@ -1159,7 +1159,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
        int normalDataOffset = ss->normalDataOffset;
        int vertDataSize = ss->meshIFC.vertDataSize;
 
-       //#pragma omp parallel for private(ptrIdx) schedule(static)
+       #pragma omp parallel for private(ptrIdx) if(numEffectedF*edgeSize*edgeSize*4 >= CCG_OMP_LIMIT)
        for (ptrIdx=0; ptrIdx<numEffectedF; ptrIdx++) {
                CCGFace *f = (CCGFace*) effectedF[ptrIdx];
                int S, x, y;
@@ -1285,7 +1285,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
                }
        }
 
-       //#pragma omp parallel for private(ptrIdx) schedule(static)
+       #pragma omp parallel for private(ptrIdx) if(numEffectedF*edgeSize*edgeSize*4 >= CCG_OMP_LIMIT)
        for (ptrIdx=0; ptrIdx<numEffectedF; ptrIdx++) {
                CCGFace *f = (CCGFace*) effectedF[ptrIdx];
                int S, x, y;
@@ -1351,7 +1351,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
        int vertDataSize = ss->meshIFC.vertDataSize;
        void *q = ss->q, *r = ss->r;
 
-       //#pragma omp parallel for private(ptrIdx) schedule(static)
+       #pragma omp parallel for private(ptrIdx) if(numEffectedF*edgeSize*edgeSize*4 >= CCG_OMP_LIMIT)
        for (ptrIdx=0; ptrIdx<numEffectedF; ptrIdx++) {
                CCGFace *f = (CCGFace*) effectedF[ptrIdx];
                int S, x, y;
@@ -1685,17 +1685,17 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
                }
        }
 
-       //#pragma omp parallel private(ptrIdx)
+       #pragma omp parallel private(ptrIdx) if(numEffectedF*edgeSize*edgeSize*4 >= CCG_OMP_LIMIT)
        {
                void *q, *r;
 
-               //#pragma omp critical
+               #pragma omp critical
                {
                        q = MEM_mallocN(ss->meshIFC.vertDataSize, "CCGSubsurf q");
                        r = MEM_mallocN(ss->meshIFC.vertDataSize, "CCGSubsurf r");
                }
 
-               //#pragma omp for schedule(static)
+               #pragma omp for schedule(static)
                for (ptrIdx=0; ptrIdx<numEffectedF; ptrIdx++) {
                        CCGFace *f = (CCGFace*) effectedF[ptrIdx];
                        int S, x, y;
@@ -1779,7 +1779,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
                        }
                }
 
-               //#pragma omp critical
+               #pragma omp critical
                {
                        MEM_freeN(q);
                        MEM_freeN(r);
@@ -1791,14 +1791,14 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
        gridSize = 1 + (1<<((nextLvl)-1));
        cornerIdx = gridSize-1;
 
-       //#pragma omp parallel for private(i) schedule(static)
+       #pragma omp parallel for private(i) if(numEffectedF*edgeSize*edgeSize*4 >= CCG_OMP_LIMIT)
        for (i=0; i<numEffectedE; i++) {
                CCGEdge *e = effectedE[i];
                VertDataCopy(EDGE_getCo(e, nextLvl, 0), VERT_getCo(e->v0, nextLvl));
                VertDataCopy(EDGE_getCo(e, nextLvl, edgeSize-1), VERT_getCo(e->v1, nextLvl));
        }
 
-       //#pragma omp parallel for private(i) schedule(static)
+       #pragma omp parallel for private(i) if(numEffectedF*edgeSize*edgeSize*4 >= CCG_OMP_LIMIT)
        for (i=0; i<numEffectedF; i++) {
                CCGFace *f = effectedF[i];
                int S, x;
index 12212c7..34d6842 100644 (file)
@@ -39,6 +39,10 @@ typedef enum {
 
 /***/
 
+#define CCG_OMP_LIMIT  1000000
+
+/***/
+
 typedef struct _CCGSubSurf CCGSubSurf;
 
 CCGSubSurf*    ccgSubSurf_new  (CCGMeshIFC *ifc, int subdivisionLevels, CCGAllocatorIFC *allocatorIFC, CCGAllocatorHDL allocator);
index d567e0f..aab9f2a 100644 (file)
@@ -560,7 +560,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, int invert, int
        dGridSize = multires_side_tot[totlvl];
        dSkip = (dGridSize-1)/(gridSize-1);
 
-       //#pragma omp parallel for private(i) schedule(static)
+       #pragma omp parallel for private(i) if(me->totface*gridSize*gridSize*4 >= CCG_OMP_LIMIT)
        for(i = 0; i < me->totface; ++i) {
                const int numVerts = mface[i].v4 ? 4 : 3;
                MDisps *mdisp = &mdisps[i];
@@ -568,7 +568,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, int invert, int
 
                /* when adding new faces in edit mode, need to allocate disps */
                if(!mdisp->disps)
-               //#pragma omp critical
+               #pragma omp critical
                {
                        multires_reallocate_mdisps(me, mdisps, totlvl);
                }