Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit cba7159c authored by berenger-bramas's avatar berenger-bramas

Make the pre-computation in P2P Threaded parallel.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@129 2616d619-271b-44dc-8df4-d4a8f33a7222
parent 4038ff37
...@@ -318,37 +318,56 @@ public: ...@@ -318,37 +318,56 @@ public:
LeafData* const leafsDataArray = new LeafData[this->leafsNumber]; LeafData* const leafsDataArray = new LeafData[this->leafsNumber];
const int LeafIndex = OctreeHeight - 1; const int LeafIndex = OctreeHeight - 1;
int leafs = 0;
int startPosAtShape[SizeShape];
startPosAtShape[0] = 0;
for(int idxShape = 1 ; idxShape < SizeShape ; ++idxShape){
startPosAtShape[idxShape] = startPosAtShape[idxShape-1] + this->shapeLeaf[idxShape-1];
}
#pragma omp parallel
{ {
int startPosAtShape[SizeShape];
startPosAtShape[0] = 0; const float step = (float(this->leafsNumber) / omp_get_num_threads());
for(int idxShape = 1 ; idxShape < SizeShape ; ++idxShape){ const int start = int(FMath::Ceil(step * omp_get_thread_num()));
startPosAtShape[idxShape] = startPosAtShape[idxShape-1] + this->shapeLeaf[idxShape-1]; const int tempEnd = int(FMath::Ceil(step * (omp_get_thread_num()+1)));
} const int end = (tempEnd > this->leafsNumber ? this->leafsNumber : tempEnd);
OctreeIterator octreeIterator(tree); OctreeIterator octreeIterator(tree);
octreeIterator.gotoBottomLeft(); octreeIterator.gotoBottomLeft();
for(int idxPreLeaf = 0 ; idxPreLeaf < start ; ++idxPreLeaf){
octreeIterator.moveRight();
}
// for each leafs // for each leafs
do{ for(int idxMyLeafs = start ; idxMyLeafs < end ; ++idxMyLeafs){
//iterArray[leafs] = octreeIterator; //iterArray[leafs] = octreeIterator;
++leafs; //++leafs;
const FTreeCoordinate& coord = octreeIterator.getCurrentGlobalCoordinate(); const FTreeCoordinate& coord = octreeIterator.getCurrentGlobalCoordinate();
const int shapePosition = (coord.getX()%3)*9 + (coord.getY()%3)*3 + (coord.getZ()%3); const int shapePosition = (coord.getX()%3)*9 + (coord.getY()%3)*3 + (coord.getZ()%3);
leafsDataArray[startPosAtShape[shapePosition]].index = octreeIterator.getCurrentGlobalIndex(); int positionToWork = 0;
leafsDataArray[startPosAtShape[shapePosition]].cell = octreeIterator.getCurrentCell(); #pragma omp critical
leafsDataArray[startPosAtShape[shapePosition]].targets = octreeIterator.getCurrentListTargets(); {
leafsDataArray[startPosAtShape[shapePosition]].sources = octreeIterator.getCurrentListSrc(); positionToWork = startPosAtShape[shapePosition]++;
}
++startPosAtShape[shapePosition]; leafsDataArray[positionToWork].index = octreeIterator.getCurrentGlobalIndex();
leafsDataArray[positionToWork].cell = octreeIterator.getCurrentCell();
leafsDataArray[positionToWork].targets = octreeIterator.getCurrentListTargets();
leafsDataArray[positionToWork].sources = octreeIterator.getCurrentListSrc();
} while(octreeIterator.moveRight()); octreeIterator.moveRight();
} }
FDEBUG(computationCounter.tic()); #pragma omp barrier
#pragma omp master
{
FDEBUG(computationCounter.tic());
}
#pragma omp parallel
{
Kernel& myThreadkernels = (*kernels[omp_get_thread_num()]); Kernel& myThreadkernels = (*kernels[omp_get_thread_num()]);
// There is a maximum of 26 neighbors // There is a maximum of 26 neighbors
ContainerClass<ParticleClass>* neighbors[26]; ContainerClass<ParticleClass>* neighbors[26];
...@@ -372,6 +391,7 @@ public: ...@@ -372,6 +391,7 @@ public:
previous = endAtThisShape; previous = endAtThisShape;
} }
} }
FDEBUG(computationCounter.tac()); FDEBUG(computationCounter.tac());
delete [] leafsDataArray; delete [] leafsDataArray;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment