Commit 3e7bcd0a authored by berenger-bramas's avatar berenger-bramas

Change P2P prototype.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@377 2616d619-271b-44dc-8df4-d4a8f33a7222
parent 648df9d8
...@@ -82,26 +82,25 @@ public: ...@@ -82,26 +82,25 @@ public:
* P2P * P2P
* Particles to particles * Particles to particles
* @param targets current boxe targets particles * @param targets current boxe targets particles
* @param sources current boxe sources particles
* @param directNeighborsParticles the particles from direct neighbors (this is an array of list) * @param directNeighborsParticles the particles from direct neighbors (this is an array of list)
* @param size the number of direct neighbors (the size of the array directNeighborsParticles) * @param size the number of direct neighbors (the size of the array directNeighborsParticles)
*/ */
virtual void P2P(ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources, virtual void P2P(const FTreeCoordinate& inLeafPosition,
const ContainerClass* const directNeighborsParticles[26], const int size) = 0; ContainerClass* const FRestrict targets,
ContainerClass* const directNeighborsParticles[27], const int size) = 0;
/** /**
* P2P * P2P
* Particles to particles * Particles to particles
* @param inCurrentLeafIndex * @param inLeafPosition
* @param targets current boxe targets particles * @param targets current boxe targets particles
* @param sources current boxe sources particles * @param sources current boxe sources particles
* @param directNeighborsParticles the particles from direct neighbors (this is an array of list) * @param directNeighborsParticles the particles from direct neighbors (this is an array of list)
* @param inNeighborsIndex the indexes of neighbors
* @param size the number of direct neighbors (the size of the array directNeighborsParticles) * @param size the number of direct neighbors (the size of the array directNeighborsParticles)
*/ */
virtual void P2P(const MortonIndex inCurrentLeafIndex, virtual void P2P(const FTreeCoordinate& inLeafPosition,
ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources, ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources,
ContainerClass* const directNeighborsParticles[26], const int size) = 0; ContainerClass* const directNeighborsParticles[27], const int size) = 0;
}; };
......
...@@ -59,15 +59,16 @@ public: ...@@ -59,15 +59,16 @@ public:
} }
/** Do nothing */ /** Do nothing */
virtual void P2P(ContainerClass* const FRestrict , const ContainerClass* const FRestrict , virtual void P2P(const FTreeCoordinate& ,
const ContainerClass* const [26], const int ) { ContainerClass* const FRestrict ,
ContainerClass* const [27], const int ) {
} }
/** Do nothing */ /** Do nothing */
virtual void P2P(const MortonIndex , virtual void P2P(const FTreeCoordinate& ,
ContainerClass* const FRestrict , const ContainerClass* const FRestrict , ContainerClass* const FRestrict , const ContainerClass* const FRestrict ,
ContainerClass* const [26], const int ){ ContainerClass* const [27], const int ){
} }
......
...@@ -90,16 +90,17 @@ public: ...@@ -90,16 +90,17 @@ public:
} }
/** After Downward */ /** After Downward */
void P2P(ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources, void P2P(const FTreeCoordinate& ,
const ContainerClass* const directNeighborsParticles[26], const int size) { ContainerClass* const FRestrict targets,
ContainerClass* const directNeighborsParticles[27], const int ){
// Each particles targeted is impacted by the particles sources // Each particles targeted is impacted by the particles sources
long long int inc = sources->getSize(); long long int inc = targets->getSize() - 1;
if(targets == sources){
inc -= 1; for(int idx = 0 ; idx < 27 ; ++idx){
} if( directNeighborsParticles[idx] ){
for(int idx = 0 ; idx < size ; ++idx){ inc += directNeighborsParticles[idx]->getSize();
inc += directNeighborsParticles[idx]->getSize(); }
} }
typename ContainerClass::BasicIterator iter(*targets); typename ContainerClass::BasicIterator iter(*targets);
...@@ -112,17 +113,19 @@ public: ...@@ -112,17 +113,19 @@ public:
/** After Downward */ /** After Downward */
void P2P(const MortonIndex , void P2P(const FTreeCoordinate& ,
ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources, ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources,
ContainerClass* const directNeighborsParticles[26], const int size) { ContainerClass* const directNeighborsParticles[27], const int ){
// Each particles targeted is impacted by the particles sources // Each particles targeted is impacted by the particles sources
long long int inc = sources->getSize(); long long int inc = sources->getSize();
if(targets == sources){ if(targets == sources){
inc -= 1; inc -= 1;
} }
for(int idx = 0 ; idx < size ; ++idx){ for(int idx = 0 ; idx < 27 ; ++idx){
inc += directNeighborsParticles[idx]->getSize(); if( directNeighborsParticles[idx] ){
inc += directNeighborsParticles[idx]->getSize();
}
} }
typename ContainerClass::BasicIterator iter(*targets); typename ContainerClass::BasicIterator iter(*targets);
......
...@@ -933,8 +933,8 @@ public: ...@@ -933,8 +933,8 @@ public:
* @param inLevel the level of the element * @param inLevel the level of the element
* @return the number of neighbors * @return the number of neighbors
*/ */
int getLeafsNeighbors(ContainerClass* inNeighbors[26], const FTreeCoordinate& center, const int inLevel){ int getLeafsNeighbors(ContainerClass* inNeighbors[27], const FTreeCoordinate& center, const int inLevel){
memset( inNeighbors, 0 , 26 * sizeof(ContainerClass*)); memset( inNeighbors, 0 , 27 * sizeof(ContainerClass*));
const int limite = FMath::pow2(inLevel); const int limite = FMath::pow2(inLevel);
int idxNeighbors = 0; int idxNeighbors = 0;
...@@ -974,8 +974,8 @@ public: ...@@ -974,8 +974,8 @@ public:
* @param inLevel the level of the element * @param inLevel the level of the element
* @return the number of neighbors * @return the number of neighbors
*/ */
int getPeriodicLeafsNeighbors(ContainerClass* inNeighbors[26], const FTreeCoordinate& center, const int inLevel){ int getPeriodicLeafsNeighbors(ContainerClass* inNeighbors[27], const FTreeCoordinate& center, const int inLevel){
memset(inNeighbors , 0 , 26 * sizeof(ContainerClass*)); memset(inNeighbors , 0 , 27 * sizeof(ContainerClass*));
const int limite = FMath::pow2(inLevel); const int limite = FMath::pow2(inLevel);
int idxNeighbors = 0; int idxNeighbors = 0;
......
...@@ -233,7 +233,7 @@ private: ...@@ -233,7 +233,7 @@ private:
typename OctreeClass::Iterator octreeIterator(tree); typename OctreeClass::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft(); octreeIterator.gotoBottomLeft();
// There is a maximum of 26 neighbors // There is a maximum of 26 neighbors
ContainerClass* neighbors[26]; ContainerClass* neighbors[27];
// for each leafs // for each leafs
do{ do{
FDEBUG(computationCounterL2P.tic()); FDEBUG(computationCounterL2P.tic());
...@@ -242,7 +242,7 @@ private: ...@@ -242,7 +242,7 @@ private:
// need the current particles and neighbors particles // need the current particles and neighbors particles
const int counter = tree->getLeafsNeighbors(neighbors, octreeIterator.getCurrentGlobalCoordinate(),heightMinusOne); const int counter = tree->getLeafsNeighbors(neighbors, octreeIterator.getCurrentGlobalCoordinate(),heightMinusOne);
FDEBUG(computationCounterP2P.tic()); FDEBUG(computationCounterP2P.tic());
kernels->P2P(octreeIterator.getCurrentGlobalIndex(),octreeIterator.getCurrentListTargets(), octreeIterator.getCurrentListSrc() , neighbors, counter); kernels->P2P(octreeIterator.getCurrentGlobalCoordinate(),octreeIterator.getCurrentListTargets(), neighbors, counter);
FDEBUG(computationCounterP2P.tac()); FDEBUG(computationCounterP2P.tac());
} while(octreeIterator.moveRight()); } while(octreeIterator.moveRight());
......
...@@ -231,7 +231,7 @@ private: ...@@ -231,7 +231,7 @@ private:
typename OctreeClass::Iterator octreeIterator(tree); typename OctreeClass::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft(); octreeIterator.gotoBottomLeft();
// There is a maximum of 26 neighbors // There is a maximum of 26 neighbors
ContainerClass* neighbors[26]; ContainerClass* neighbors[27];
// for each leafs // for each leafs
do{ do{
FDEBUG(computationCounterL2P.tic()); FDEBUG(computationCounterL2P.tic());
...@@ -240,7 +240,7 @@ private: ...@@ -240,7 +240,7 @@ private:
// need the current particles and neighbors particles // need the current particles and neighbors particles
const int counter = tree->getPeriodicLeafsNeighbors(neighbors, octreeIterator.getCurrentGlobalCoordinate(),heightMinusOne); const int counter = tree->getPeriodicLeafsNeighbors(neighbors, octreeIterator.getCurrentGlobalCoordinate(),heightMinusOne);
FDEBUG(computationCounterP2P.tic()); FDEBUG(computationCounterP2P.tic());
kernels->P2P(octreeIterator.getCurrentGlobalIndex(),octreeIterator.getCurrentListTargets(), octreeIterator.getCurrentListSrc() , neighbors, counter); kernels->P2P(octreeIterator.getCurrentGlobalCoordinate(),octreeIterator.getCurrentListTargets(), neighbors, counter);
FDEBUG(computationCounterP2P.tac()); FDEBUG(computationCounterP2P.tac());
} while(octreeIterator.moveRight()); } while(octreeIterator.moveRight());
......
...@@ -277,13 +277,13 @@ private: ...@@ -277,13 +277,13 @@ private:
const int heightMinusOne = OctreeHeight - 1; const int heightMinusOne = OctreeHeight - 1;
#pragma omp parallel #pragma omp parallel
{ {
KernelClass*const myThreadkernels = kernels[omp_get_thread_num()]; KernelClass*const myThreadkernels = kernels[omp_get_thread_num()];
// There is a maximum of 26 neighbors // There is a maximum of 26 neighbors
ContainerClass* neighbors[26]; ContainerClass* neighbors[27];
#pragma omp single nowait #pragma omp single nowait
{ {
const int SizeShape = 3*3*3; const int SizeShape = 3*3*3;
FVector<typename OctreeClass::Iterator> shapes[SizeShape]; FVector<typename OctreeClass::Iterator> shapes[SizeShape];
...@@ -293,7 +293,7 @@ private: ...@@ -293,7 +293,7 @@ private:
// for each leafs // for each leafs
do{ do{
#pragma omp task #pragma omp task
{ {
myThreadkernels->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets()); myThreadkernels->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets());
} }
...@@ -302,7 +302,7 @@ private: ...@@ -302,7 +302,7 @@ private:
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);
if( shapePosition == 0){ if( shapePosition == 0){
#pragma omp task #pragma omp task
{ {
// need the current particles and neighbors particles // need the current particles and neighbors particles
const int counter = tree->getLeafsNeighbors(neighbors, octreeIterator.getCurrentGlobalCoordinate(),heightMinusOne); const int counter = tree->getLeafsNeighbors(neighbors, octreeIterator.getCurrentGlobalCoordinate(),heightMinusOne);
...@@ -315,20 +315,20 @@ private: ...@@ -315,20 +315,20 @@ private:
} while(octreeIterator.moveRight()); } while(octreeIterator.moveRight());
#pragma omp taskwait #pragma omp taskwait
for( int idxShape = 1 ; idxShape < SizeShape ; ++idxShape){ for( int idxShape = 1 ; idxShape < SizeShape ; ++idxShape){
int iterLeaf = shapes[idxShape].getSize(); int iterLeaf = shapes[idxShape].getSize();
while( iterLeaf-- ){ while( iterLeaf-- ){
typename OctreeClass::Iterator toWork = shapes[idxShape][iterLeaf]; typename OctreeClass::Iterator toWork = shapes[idxShape][iterLeaf];
#pragma omp task #pragma omp task
{ {
const int counter = tree->getLeafsNeighbors(neighbors, toWork.getCurrentGlobalCoordinate(),heightMinusOne); const int counter = tree->getLeafsNeighbors(neighbors, toWork.getCurrentGlobalCoordinate(),heightMinusOne);
myThreadkernels->P2P(toWork.getCurrentGlobalIndex(),toWork.getCurrentListTargets(), toWork.getCurrentListSrc() , neighbors, counter); myThreadkernels->P2P(toWork.getCurrentGlobalCoordinate(), toWork.getCurrentListTargets(), neighbors, counter);
} }
} }
#pragma omp taskwait #pragma omp taskwait
} }
} }
} }
......
...@@ -371,7 +371,7 @@ private: ...@@ -371,7 +371,7 @@ private:
KernelClass& myThreadkernels = (*kernels[omp_get_thread_num()]); KernelClass& myThreadkernels = (*kernels[omp_get_thread_num()]);
// There is a maximum of 26 neighbors // There is a maximum of 26 neighbors
ContainerClass* neighbors[26]; ContainerClass* neighbors[27];
int previous = 0; int previous = 0;
for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){ for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
...@@ -384,7 +384,7 @@ private: ...@@ -384,7 +384,7 @@ private:
// need the current particles and neighbors particles // need the current particles and neighbors particles
FDEBUG(if(!omp_get_thread_num()) computationCounterP2P.tic()); FDEBUG(if(!omp_get_thread_num()) computationCounterP2P.tic());
const int counter = tree->getLeafsNeighbors(neighbors, currentIter.cell->getCoordinate(), LeafIndex); const int counter = tree->getLeafsNeighbors(neighbors, currentIter.cell->getCoordinate(), LeafIndex);
myThreadkernels.P2P(currentIter.index, currentIter.targets, currentIter.sources , neighbors, counter); myThreadkernels.P2P(currentIter.cell->getCoordinate(), currentIter.targets, neighbors, counter);
FDEBUG(if(!omp_get_thread_num()) computationCounterP2P.tac()); FDEBUG(if(!omp_get_thread_num()) computationCounterP2P.tac());
} }
......
...@@ -953,6 +953,7 @@ private: ...@@ -953,6 +953,7 @@ private:
int alreadySent[nbProcess]; int alreadySent[nbProcess];
MortonIndex indexesNeighbors[26]; MortonIndex indexesNeighbors[26];
int uselessIndexArray[26];
for(int idxLeaf = 0 ; idxLeaf < this->numberOfLeafs ; ++idxLeaf){ for(int idxLeaf = 0 ; idxLeaf < this->numberOfLeafs ; ++idxLeaf){
FTreeCoordinate center; FTreeCoordinate center;
...@@ -961,7 +962,7 @@ private: ...@@ -961,7 +962,7 @@ private:
memset(alreadySent, 0, sizeof(int) * nbProcess); memset(alreadySent, 0, sizeof(int) * nbProcess);
bool needOther = false; bool needOther = false;
const int neighCount = getNeighborsIndexes(iterArray[idxLeaf].getCurrentGlobalIndex(), limite, indexesNeighbors); const int neighCount = getNeighborsIndexes(iterArray[idxLeaf].getCurrentGlobalIndex(), limite, indexesNeighbors, uselessIndexArray);
for(int idxNeigh = 0 ; idxNeigh < neighCount ; ++idxNeigh){ for(int idxNeigh = 0 ; idxNeigh < neighCount ; ++idxNeigh){
if(indexesNeighbors[idxNeigh] < intervals[idProcess].min || intervals[idProcess].max < indexesNeighbors[idxNeigh]){ if(indexesNeighbors[idxNeigh] < intervals[idProcess].min || intervals[idProcess].max < indexesNeighbors[idxNeigh]){
...@@ -1118,7 +1119,7 @@ private: ...@@ -1118,7 +1119,7 @@ private:
{ {
KernelClass& myThreadkernels = (*kernels[omp_get_thread_num()]); KernelClass& myThreadkernels = (*kernels[omp_get_thread_num()]);
// There is a maximum of 26 neighbors // There is a maximum of 26 neighbors
ContainerClass* neighbors[26]; ContainerClass* neighbors[27];
int previous = 0; int previous = 0;
for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){ for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
...@@ -1132,7 +1133,7 @@ private: ...@@ -1132,7 +1133,7 @@ private:
// need the current particles and neighbors particles // need the current particles and neighbors particles
const int counter = tree->getLeafsNeighbors(neighbors, currentIter.cell->getCoordinate(), LeafIndex); const int counter = tree->getLeafsNeighbors(neighbors, currentIter.cell->getCoordinate(), LeafIndex);
myThreadkernels.P2P( currentIter.index,currentIter.targets, currentIter.sources , neighbors, counter); myThreadkernels.P2P( currentIter.cell->getCoordinate(),currentIter.targets, neighbors, counter);
} }
} }
...@@ -1181,11 +1182,11 @@ private: ...@@ -1181,11 +1182,11 @@ private:
FTRACE( FTrace::FRegion regionOtherTrace("Compute P2P Other", __FUNCTION__ , __FILE__ , __LINE__) ); FTRACE( FTrace::FRegion regionOtherTrace("Compute P2P Other", __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( computation2Counter.tic() ); FDEBUG( computation2Counter.tic() );
#pragma omp parallel #pragma omp parallel
{ {
KernelClass& myThreadkernels = (*kernels[omp_get_thread_num()]); KernelClass& myThreadkernels = (*kernels[omp_get_thread_num()]);
// There is a maximum of 26 neighbors // There is a maximum of 26 neighbors
ContainerClass* neighbors[26]; ContainerClass* neighbors[27];
int previous = 0; int previous = 0;
// Box limite // Box limite
const int limite = 1 << (this->OctreeHeight - 1); const int limite = 1 << (this->OctreeHeight - 1);
...@@ -1204,20 +1205,23 @@ private: ...@@ -1204,20 +1205,23 @@ private:
int counter = tree->getLeafsNeighbors(neighbors, currentIter.cell->getCoordinate(), LeafIndex); int counter = tree->getLeafsNeighbors(neighbors, currentIter.cell->getCoordinate(), LeafIndex);
// Take possible data // Take possible data
MortonIndex indexesNeighbors[26]; MortonIndex indexesNeighbors[27];
const int neighCount = getNeighborsIndexes(currentIter.index, limite, indexesNeighbors); int indexArray[26];
const int nbNeigh = getNeighborsIndexes(currentIter.index, limite, indexesNeighbors, indexArray);
memset( neighbors, 0, sizeof(ContainerClass*) * 27);
for(int idxNeigh = 0 ; idxNeigh < neighCount ; ++idxNeigh){ for(int idxNeigh = 0 ; idxNeigh < nbNeigh ; ++idxNeigh){
if(indexesNeighbors[idxNeigh] < intervals[idProcess].min || intervals[idProcess].max < indexesNeighbors[idxNeigh]){ if(indexesNeighbors[idxNeigh] < intervals[idProcess].min || intervals[idProcess].max < indexesNeighbors[idxNeigh]){
ContainerClass*const hypotheticNeighbor = otherP2Ptree.getLeafSrc(indexesNeighbors[idxNeigh]); ContainerClass*const hypotheticNeighbor = otherP2Ptree.getLeafSrc(indexesNeighbors[idxNeigh]);
if(hypotheticNeighbor){ if(hypotheticNeighbor){
neighbors[counter] = hypotheticNeighbor; neighbors[ indexArray[idxNeigh] ] = hypotheticNeighbor;
++counter; ++counter;
} }
} }
} }
myThreadkernels.P2P( currentIter.index,currentIter.targets, currentIter.sources , neighbors, counter); myThreadkernels.P2P( currentIter.cell->getCoordinate(), currentIter.targets, neighbors, counter);
} }
} }
...@@ -1245,7 +1249,7 @@ private: ...@@ -1245,7 +1249,7 @@ private:
} }
int getNeighborsIndexes(const MortonIndex centerIndex, const int limite, MortonIndex indexes[26]) const{ int getNeighborsIndexes(const MortonIndex centerIndex, const int limite, MortonIndex indexes[26], int indexInArray[26]) const{
FTreeCoordinate center; FTreeCoordinate center;
center.setPositionFromMorton(centerIndex, OctreeHeight - 1); center.setPositionFromMorton(centerIndex, OctreeHeight - 1);
int idxNeig = 0; int idxNeig = 0;
...@@ -1262,7 +1266,9 @@ private: ...@@ -1262,7 +1266,9 @@ private:
// if we are not on the current cell // if we are not on the current cell
if( idxX || idxY || idxZ ){ if( idxX || idxY || idxZ ){
const FTreeCoordinate other(center.getX() + idxX,center.getY() + idxY,center.getZ() + idxZ); const FTreeCoordinate other(center.getX() + idxX,center.getY() + idxY,center.getZ() + idxZ);
indexes[idxNeig++] = other.getMortonIndex(this->OctreeHeight - 1); indexes[ idxNeig ] = other.getMortonIndex(this->OctreeHeight - 1);
indexInArray[ idxNeig ] = ((idxX+1)*3 + (idxY+1)) * 3 + (idxZ+1);
++idxNeig;
} }
} }
} }
......
...@@ -1031,6 +1031,7 @@ private: ...@@ -1031,6 +1031,7 @@ private:
int alreadySent[nbProcess]; int alreadySent[nbProcess];
MortonIndex indexesNeighbors[26]; MortonIndex indexesNeighbors[26];
int uselessIndexInArray[26];
for(int idxLeaf = 0 ; idxLeaf < this->numberOfLeafs ; ++idxLeaf){ for(int idxLeaf = 0 ; idxLeaf < this->numberOfLeafs ; ++idxLeaf){
FTreeCoordinate center; FTreeCoordinate center;
...@@ -1039,9 +1040,9 @@ private: ...@@ -1039,9 +1040,9 @@ private:
memset(alreadySent, 0, sizeof(int) * nbProcess); memset(alreadySent, 0, sizeof(int) * nbProcess);
bool needOther = false; bool needOther = false;
getNeighborsIndexes(iterArray[idxLeaf].getCurrentGlobalCoordinate(), limite, indexesNeighbors); const int nbNeigh = getNeighborsIndexes(iterArray[idxLeaf].getCurrentGlobalCoordinate(), limite, indexesNeighbors, uselessIndexInArray);
for(int idxNeigh = 0 ; idxNeigh < 26 ; ++idxNeigh){ for(int idxNeigh = 0 ; idxNeigh < nbNeigh ; ++idxNeigh){
if(indexesNeighbors[idxNeigh] < intervals[idProcess].min || intervals[idProcess].max < indexesNeighbors[idxNeigh]){ if(indexesNeighbors[idxNeigh] < intervals[idProcess].min || intervals[idProcess].max < indexesNeighbors[idxNeigh]){
needOther = true; needOther = true;
...@@ -1195,7 +1196,7 @@ private: ...@@ -1195,7 +1196,7 @@ private:
{ {
KernelClass& myThreadkernels = (*kernels[omp_get_thread_num()]); KernelClass& myThreadkernels = (*kernels[omp_get_thread_num()]);
// There is a maximum of 26 neighbors // There is a maximum of 26 neighbors
ContainerClass* neighbors[26]; ContainerClass* neighbors[27];
int previous = 0; int previous = 0;
for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){ for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
...@@ -1209,7 +1210,7 @@ private: ...@@ -1209,7 +1210,7 @@ private:
// need the current particles and neighbors particles // need the current particles and neighbors particles
const int counter = tree->getPeriodicLeafsNeighbors(neighbors, currentIter.cell->getCoordinate(), LeafIndex); const int counter = tree->getPeriodicLeafsNeighbors(neighbors, currentIter.cell->getCoordinate(), LeafIndex);
myThreadkernels.P2P( currentIter.index,currentIter.targets, currentIter.sources , neighbors, counter); myThreadkernels.P2P( currentIter.cell->getCoordinate(), currentIter.targets, neighbors, counter);
} }
} }
...@@ -1262,8 +1263,9 @@ private: ...@@ -1262,8 +1263,9 @@ private:
{ {
KernelClass& myThreadkernels = (*kernels[omp_get_thread_num()]); KernelClass& myThreadkernels = (*kernels[omp_get_thread_num()]);
// There is a maximum of 26 neighbors // There is a maximum of 26 neighbors
ContainerClass* neighbors[26]; ContainerClass* neighbors[27];
MortonIndex indexesNeighbors[26]; MortonIndex indexesNeighbors[26];
int indexInArray[26];
int previous = 0; int previous = 0;
// Box limite // Box limite
...@@ -1282,28 +1284,28 @@ private: ...@@ -1282,28 +1284,28 @@ private:
// need the current particles and neighbors particles // need the current particles and neighbors particles
// int counter = tree->getLeafsNeighbors(neighbors, neighborsIndex, currentIter.index, LeafIndex); // int counter = tree->getLeafsNeighbors(neighbors, neighborsIndex, currentIter.index, LeafIndex);
int counter = 0; int counter = 0;
memset(neighbors, 0, 26 * sizeof(ContainerClass*)); memset(neighbors, 0, 27 * sizeof(ContainerClass*));
// Take possible data // Take possible data
getNeighborsIndexes(currentIter.cell->getCoordinate(), limite, indexesNeighbors); const int nbNeigh = getNeighborsIndexes(currentIter.cell->getCoordinate(), limite, indexesNeighbors, indexInArray);
for(int idxNeigh = 0 ; idxNeigh < 26 ; ++idxNeigh){ for(int idxNeigh = 0 ; idxNeigh < nbNeigh ; ++idxNeigh){
if(indexesNeighbors[idxNeigh] < intervals[idProcess].min || intervals[idProcess].max < indexesNeighbors[idxNeigh]){ if(indexesNeighbors[idxNeigh] < intervals[idProcess].min || intervals[idProcess].max < indexesNeighbors[idxNeigh]){
ContainerClass*const hypotheticNeighbor = otherP2Ptree.getLeafSrc(indexesNeighbors[idxNeigh]); ContainerClass*const hypotheticNeighbor = otherP2Ptree.getLeafSrc(indexesNeighbors[idxNeigh]);
if(hypotheticNeighbor){ if(hypotheticNeighbor){
neighbors[idxNeigh] = hypotheticNeighbor; neighbors[ indexInArray[idxNeigh] ] = hypotheticNeighbor;
++counter; ++counter;
} }
} }
else{ else{
ContainerClass*const hypotheticNeighbor = tree->getLeafSrc(indexesNeighbors[idxNeigh]); ContainerClass*const hypotheticNeighbor = tree->getLeafSrc(indexesNeighbors[idxNeigh]);
if(hypotheticNeighbor){ if(hypotheticNeighbor){
neighbors[idxNeigh] = hypotheticNeighbor; neighbors[ indexInArray[idxNeigh] ] = hypotheticNeighbor;
++counter; ++counter;
} }
} }
} }
myThreadkernels.P2P( currentIter.index,currentIter.targets, currentIter.sources , neighbors, counter); myThreadkernels.P2P( currentIter.cell->getCoordinate(), currentIter.targets, neighbors, counter);
}