Little project: Getting fluidsim multithreaded.
authorDaniel Genrich <daniel.genrich@gmx.net>
Sun, 16 Sep 2007 16:33:42 +0000 (16:33 +0000)
committerDaniel Genrich <daniel.genrich@gmx.net>
Sun, 16 Sep 2007 16:33:42 +0000 (16:33 +0000)
Can be actuvated by adding "PARALLEL" to compiler flags in elbeem folder.
-----
Code already works for MAX_THREADS=1 so there seems to be some bug in openMP code in paraloopstart.h

Help appeciated :)

intern/elbeem/intern/paraloop.h [new file with mode: 0644]
intern/elbeem/intern/paraloopend.h [new file with mode: 0644]
intern/elbeem/intern/paraloopstart.h [new file with mode: 0644]

diff --git a/intern/elbeem/intern/paraloop.h b/intern/elbeem/intern/paraloop.h
new file mode 100644 (file)
index 0000000..e8bef64
--- /dev/null
@@ -0,0 +1,51 @@
+
+#define PERFORM_USQRMAXCHECK \
+_Pragma("omp critical") {\
+USQRMAXCHECK(usqr,ux,uy,uz, mMaxVlen, mMxvx,mMxvy,mMxvz); \
+} \
+
+
+#define LIST_EMPTY(x) \
+_Pragma("omp critical") {\
+mListEmpty.push_back( x ); }
+
+#define LIST_FULL(x) \
+_Pragma("omp critical") {\
+mListFull.push_back( x ); }
+
+#define FSGR_ADDPART(x)  \
+_Pragma("omp critical") { \
+mpParticles->addFullParticle( x ); } \
+
+
+#define MAX_THREADS 2
+
+#define  GRID_REGION_START()  \
+{ /* main_region */ \
+       int kstart=getForZMinBnd(), kend=getForZMaxBnd(mMaxRefine); \
+       if(gridLoopBound>0){ kstart=getForZMin1(), kend=getForZMax1(mMaxRefine); } \
+       int kdir = 1; \
+       const int id=omp_get_thread_num(); \
+       int jstart = (id*((mLevel[mMaxRefine].lSizey-gridLoopBound) / MAX_THREADS))+gridLoopBound; \
+       int jend   = (id+1)*((mLevel[mMaxRefine].lSizey-gridLoopBound)/ MAX_THREADS); \
+       if(id+1 == MAX_THREADS) \
+       { \
+       jend = mLevel[mMaxRefine].lSizey-gridLoopBound; \
+       } \
+       if(jstart<1) jstart = 1; \
+       LbmFloat *ccel = NULL, *tcel = NULL; \
+       CellFlagType *pFlagSrc=NULL, *pFlagDst=NULL; \
+       if(mLevel[mMaxRefine].setCurr==1) { \
+       kdir = -1; \
+       int temp = kend; \
+       kend = kstart-1; \
+       kstart = temp-1; \
+       temp = id; /* dummy remove warning */ \
+} \
+
+
+
+#define unused_GRID_REGION_END() \
+} /* main_region */  \
+       // end unusedGRID_REGION_END
+
diff --git a/intern/elbeem/intern/paraloopend.h b/intern/elbeem/intern/paraloopend.h
new file mode 100644 (file)
index 0000000..6ea636e
--- /dev/null
@@ -0,0 +1,14 @@
+// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+} /* i */ 
+       int i=0; 
+       ADVANCE_POINTERS(2*gridLoopBound); 
+} /* j */ 
+       /* COMPRESSGRIDS!=1 */ 
+#pragma omp barrier 
+
+       /* int i=0;  */ 
+       /* ADVANCE_POINTERS(mLevel[lev].lSizex*2);  */ 
+} /* all cell loop k,j,i */ 
+       if(doReduce) { } /* dummy remove warning */ 
+} /* main_region */ 
+
diff --git a/intern/elbeem/intern/paraloopstart.h b/intern/elbeem/intern/paraloopstart.h
new file mode 100644 (file)
index 0000000..9f13eb3
--- /dev/null
@@ -0,0 +1,3 @@
+
+#pragma omp parallel section num_threads(MAX_THREADS) \
+reduction(+: calcCurrentMass, calcCurrentVolume, calcCellsFilled, calcCellsEmptied, calcNumUsedCells)