Silence some annoying warnings when doing full build with strict flags
[blender.git] / intern / elbeem / intern / loop_tools.h
1 /** \file elbeem/intern/loop_tools.h
2  *  \ingroup elbeem
3  */
4
5 // advance pointer in main loop
6 #define ADVANCE_POINTERS(p)     \
7         ccel += (QCELLSTEP*(p));        \
8         tcel += (QCELLSTEP*(p));        \
9         pFlagSrc+= (p); \
10         pFlagDst+= (p); \
11         i+= (p);
12
13 #define MAX_CALC_ARR 4
14
15 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
16 // init region vars
17 #define  GRID_REGION_INIT()   \
18         const int istart = -1+gridLoopBound; \
19         const int iend   = mLevel[mMaxRefine].lSizex-1-gridLoopBound; \
20         LbmFloat calcCurrentMass=0; \
21         LbmFloat calcCurrentVolume=0; \
22         int      calcCellsFilled=0; \
23         int      calcCellsEmptied=0; \
24         int      calcNumUsedCells=0; \
25         /* This is a generic macro, and now all it's users are using all variables. */ \
26         (void)calcCurrentMass; \
27         (void)calcCellsFilled  \
28
29
30
31
32 //  -----------------------------------------------------------------------------------
33 // serial stuff
34 #if PARALLEL!=1
35
36 #define PERFORM_USQRMAXCHECK USQRMAXCHECK(usqr,ux,uy,uz, mMaxVlen, mMxvx,mMxvy,mMxvz);
37 #define LIST_EMPTY(x) mListEmpty.push_back( x );
38 #define LIST_FULL(x)  mListFull.push_back( x );
39 #define FSGR_ADDPART(x)  mpParticles->addFullParticle( x );
40
41 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
42 #define  GRID_REGION_START()  \
43         { /* main_region */ \
44         int kstart=getForZMinBnd(), kend=getForZMaxBnd(mMaxRefine); \
45         if(gridLoopBound>0){ kstart=getForZMin1(), kend=getForZMax1(mMaxRefine); } \
46         int kdir = 1; \
47         int jstart = gridLoopBound; \
48         int jend   = mLevel[mMaxRefine].lSizey-gridLoopBound; \
49         const int id=0; \
50         LbmFloat *ccel = NULL, *tcel = NULL; \
51         CellFlagType *pFlagSrc=NULL, *pFlagDst=NULL; \
52         if(mLevel[mMaxRefine].setCurr==1) { \
53         kdir = -1; \
54         int temp = kend; \
55         kend = kstart-1; \
56         kstart = temp-1; \
57         temp = id; /* dummy remove warning */ \
58         } \
59
60
61
62         
63
64 //  -----------------------------------------------------------------------------------
65 #else // PARALLEL==1
66
67 //#include "paraloop.h"
68 #define PERFORM_USQRMAXCHECK USQRMAXCHECK(usqr,ux,uy,uz, calcMaxVlen, calcMxvx,calcMxvy,calcMxvz);
69 #define LIST_EMPTY(x)    calcListEmpty.push_back( x );
70 #define LIST_FULL(x)     calcListFull.push_back( x );
71 #define FSGR_ADDPART(x)  calcListParts.push_back( x );
72
73
74 // parallel region
75 //was: # pragma omp parallel default(shared) 
76 #if COMPRESSGRIDS!=1
77         // requires compressed grids...!
78         ERROR!
79 #endif
80
81 // loop start
82 #define  GRID_REGION_START()  \
83         { \
84          \
85          \
86         if(mSizez<2) { \
87         mPanic = 1; \
88         errFatal("ParaLoop::2D","Not valid...!", SIMWORLD_GENERICERROR); \
89         } \
90          \
91          \
92         vector<LbmPoint> calcListFull; \
93         vector<LbmPoint> calcListEmpty; \
94         vector<ParticleObject> calcListParts; \
95         LbmFloat calcMxvx, calcMxvy, calcMxvz, calcMaxVlen; \
96         calcMxvx = calcMxvy = calcMxvz = calcMaxVlen = 0.0; \
97         calcListEmpty.reserve(mListEmpty.capacity() / omp_get_num_threads() ); \
98         calcListFull.reserve( mListFull.capacity()  / omp_get_num_threads() ); \
99         calcListParts.reserve(mSizex); \
100          \
101          \
102         const int id = omp_get_thread_num(); \
103         const int Nthrds = omp_get_num_threads(); \
104          \
105          \
106          \
107          \
108          \
109         int kdir = 1; \
110          \
111         int kstart=getForZMinBnd(), kend=getForZMaxBnd(mMaxRefine); \
112         if(gridLoopBound>0){ kstart=getForZMin1(); kend=getForZMax1(mMaxRefine); } \
113         LbmFloat *ccel = NULL, *tcel = NULL; \
114         CellFlagType *pFlagSrc=NULL, *pFlagDst=NULL; \
115          \
116          \
117         if(mLevel[mMaxRefine].setCurr==1) { \
118         kdir = -1; \
119         int temp = kend; \
120         kend = kstart-1; \
121         kstart = temp-1; \
122         } \
123          \
124         const int Nj = mLevel[mMaxRefine].lSizey; \
125         int jstart = 0+( (id * Nj ) / Nthrds ); \
126         int jend   = 0+(((id+1) * Nj ) / Nthrds ); \
127         if( ((Nj/Nthrds) *Nthrds) != Nj) { \
128         errMsg("LbmFsgrSolver","Invalid domain size Nj="<<Nj<<" Nthrds="<<Nthrds); \
129         } \
130          \
131         if(jstart<gridLoopBound) jstart = gridLoopBound; \
132         if(jend>mLevel[mMaxRefine].lSizey-gridLoopBound) jend = mLevel[mMaxRefine].lSizey-gridLoopBound; \
133          \
134         debMsgStd("ParaLoop::OMP",DM_MSG,"Thread:"<<id<<" i:"<<istart<<"-"<<iend<<" j:"<<jstart<<"-"<<jend<<", k:"<<kstart<<"-"<<kend<<"  ", 1); \
135          \
136
137
138
139
140 // para GRID LOOP END is parainc3 
141
142 #endif // PARALLEL==1
143
144
145 //  -----------------------------------------------------------------------------------
146
147 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
148 #define  GRID_LOOP_START()   \
149         for(int k=kstart;k!=kend;k+=kdir) { \
150         pFlagSrc = &RFLAG(lev, istart, jstart, k, SRCS(lev)); \
151         pFlagDst = &RFLAG(lev, istart, jstart, k, TSET(lev)); \
152         ccel = RACPNT(lev,     istart, jstart, k, SRCS(lev)); \
153         tcel = RACPNT(lev,     istart, jstart, k, TSET(lev)); \
154         for(int j=jstart;j!=jend;++j) { \
155         /* for(int i=0;i<mLevel[lev].lSizex-2;   ) { */ \
156         for(int i=istart;i!=iend;   ) { \
157         ADVANCE_POINTERS(1); \
158
159
160
161
162 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
163 #define  GRID_LOOPREG_END()  \
164          \
165         } /* i */ \
166         int i=0; \
167         ADVANCE_POINTERS(2*gridLoopBound); \
168         } /* j */ \
169         /* COMPRESSGRIDS!=1 */ \
170         /* int i=0;  */ \
171         /* ADVANCE_POINTERS(mLevel[lev].lSizex*2);  */ \
172         } /* all cell loop k,j,i */ \
173         if(doReduce) { } /* dummy remove warning */ \
174         } /* main_region */ \
175          \
176
177
178
179
180 // old loop for COMPRESSGRIDS==0
181 #define old__GRID_LOOP_START() \
182   for(int k=kstart;k<kend;++k) { \
183           for(int j=1;j<mLevel[lev].lSizey-1;++j) { \
184                 for(int i=0;i<mLevel[lev].lSizex-2;   ) {
185
186