Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 028c6055 authored by berenger-bramas's avatar berenger-bramas
Browse files

Make the MPI fmm vers. thread safe for P2P.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@89 2616d619-271b-44dc-8df4-d4a8f33a7222
parent 979e9ced
Branches
Tags
No related merge requests found
...@@ -804,25 +804,60 @@ public: ...@@ -804,25 +804,60 @@ public:
FDEBUG( FDebug::Controller.write("\tStart Direct Pass\n").write(FDebug::Flush); ); FDEBUG( FDebug::Controller.write("\tStart Direct Pass\n").write(FDebug::Flush); );
FDEBUG(FTic counterTime); FDEBUG(FTic counterTime);
// init
const int LeafIndex = OctreeHeight - 1;
const int SizeShape = 3*3*3;
int shapeLeaf[SizeShape];
OctreeIterator* shapeArray[SizeShape];
for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
shapeLeaf[idxShape] = 0;
}
// split data
{ {
OctreeIterator octreeIterator(tree); OctreeIterator octreeIterator(tree);
octreeIterator.gotoBottomLeft(); octreeIterator.gotoBottomLeft();
// remove useless leafs
for(int idxLeaf = 0 ; idxLeaf < this->leafLeft ; ++idxLeaf){ for(int idxLeaf = 0 ; idxLeaf < this->leafLeft ; ++idxLeaf){
octreeIterator.moveRight(); octreeIterator.moveRight();
} }
// to store which shape for each leaf
int* const shapeType = new int [this->leafRight - this->leafLeft + 1];
for(int idxLeaf = this->leafLeft ; idxLeaf <= this->leafRight ; ++idxLeaf){ for(int idxLeaf = this->leafLeft ; idxLeaf <= this->leafRight ; ++idxLeaf){
iterArray[idxLeaf] = octreeIterator; iterArray[idxLeaf] = octreeIterator;
const MortonIndex index = octreeIterator.getCurrentGlobalIndex();
FTreeCoordinate coord;
coord.setPositionFromMorton(index, LeafIndex);
const int shape = (coord.getX()%3)*9 + (coord.getY()%3)*3 + (coord.getZ()%3);
shapeType[idxLeaf-this->leafLeft] = shape;
++shapeLeaf[shape];
octreeIterator.moveRight(); octreeIterator.moveRight();
} }
// init iter array
int countShape[SizeShape];
for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
shapeArray[idxShape] = new OctreeIterator[shapeLeaf[idxShape]];
countShape[idxShape] = 0;
}
// store leafs
for(int idxLeaf = this->leafLeft ; idxLeaf <= this->leafRight ; ++idxLeaf){
const int idxShape = shapeType[idxLeaf - this->leafLeft];
shapeArray[idxShape][countShape[idxShape]++] = iterArray[idxLeaf];
}
delete[] shapeType;
} }
FDEBUG(FTic computationCounter); FDEBUG(FTic computationCounter);
const int LeafIndex = OctreeHeight - 1;
const int startIdx = this->leafLeft; const int startIdx = this->leafLeft;
const int endIdx = this->leafRight + 1;
#pragma omp parallel #pragma omp parallel
{ {
...@@ -830,17 +865,20 @@ public: ...@@ -830,17 +865,20 @@ public:
// There is a maximum of 26 neighbors // There is a maximum of 26 neighbors
FList<ParticleClass*>* neighbors[26]; FList<ParticleClass*>* neighbors[26];
#pragma omp for for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
for(int idxLeafs = startIdx ; idxLeafs < endIdx ; ++idxLeafs){ const int leafAtThisShape = shapeLeaf[idxShape];
myThreadkernels->L2P(iterArray[idxLeafs].getCurrentCell(), iterArray[idxLeafs].getCurrentListTargets());
// need the current particles and neighbors particles #pragma omp for
const int counter = tree->getLeafsNeighbors(neighbors, iterArray[idxLeafs].getCurrentGlobalIndex(),LeafIndex); for(int idxLeafs = startIdx ; idxLeafs < leafAtThisShape ; ++idxLeafs){
myThreadkernels->P2P( iterArray[idxLeafs].getCurrentListTargets(), iterArray[idxLeafs].getCurrentListSrc() , neighbors, counter); myThreadkernels->L2P(shapeArray[idxShape][idxLeafs].getCurrentCell(), shapeArray[idxShape][idxLeafs].getCurrentListTargets());
// need the current particles and neighbors particles
const int counter = tree->getLeafsNeighbors(neighbors, shapeArray[idxShape][idxLeafs].getCurrentGlobalIndex(),LeafIndex);
myThreadkernels->P2P( shapeArray[idxShape][idxLeafs].getCurrentListTargets(), shapeArray[idxShape][idxLeafs].getCurrentListSrc() , neighbors, counter);
}
} }
} }
FDEBUG(computationCounter.tac()); FDEBUG(computationCounter.tac());
FDEBUG( FDebug::Controller << "\tFinished (@Direct Pass (P2P) = " << counterTime.tacAndElapsed() << "s)\n" ); FDEBUG( FDebug::Controller << "\tFinished (@Direct Pass (P2P) = " << counterTime.tacAndElapsed() << "s)\n" );
FDEBUG( FDebug::Controller << "\t\t Computation : " << computationCounter.elapsed() << " s\n" ); FDEBUG( FDebug::Controller << "\t\t Computation : " << computationCounter.elapsed() << " s\n" );
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) ); FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment