Commit 648df9d8 authored by berenger-bramas's avatar berenger-bramas

Removed the periodic P2P to have only one function prototype and an...

Removed the periodic P2P to have only one function prototype and an differential position access by array index.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@376 2616d619-271b-44dc-8df4-d4a8f33a7222
parent c9d33a49
...@@ -101,27 +101,8 @@ public: ...@@ -101,27 +101,8 @@ public:
*/ */
virtual void P2P(const MortonIndex inCurrentLeafIndex, virtual void P2P(const MortonIndex inCurrentLeafIndex,
ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources, ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources,
ContainerClass* const directNeighborsParticles[26], const MortonIndex inNeighborsIndex[26], const int size) = 0; ContainerClass* const directNeighborsParticles[26], const int size) = 0;
//////////////////////////////////////////////////////////////////////////////
// Periodic methods
//////////////////////////////////////////////////////////////////////////////
/**
* P2P
* Particles to particles
* @param inCurrentLeafIndex the leaf index
* @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 neighborsRelativePositions the relative position of neighbors
* @param size the number of direct neighbors (the size of the array directNeighborsParticles)
*/
virtual void P2P(const MortonIndex inCurrentLeafIndex,
ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources,
ContainerClass* const directNeighborsParticles[26], const FTreeCoordinate neighborsRelativeOffset[26],
const int size) = 0;
}; };
......
...@@ -67,18 +67,10 @@ public: ...@@ -67,18 +67,10 @@ public:
/** Do nothing */ /** Do nothing */
virtual void P2P(const MortonIndex , virtual void P2P(const MortonIndex ,
ContainerClass* const FRestrict , const ContainerClass* const FRestrict , ContainerClass* const FRestrict , const ContainerClass* const FRestrict ,
ContainerClass* const [26], const MortonIndex [26], const int ){ ContainerClass* const [26], const int ){
} }
// ------------------- Periodic --------------------
/** After Downward */
void P2P(const MortonIndex ,
ContainerClass* const FRestrict , const ContainerClass* const FRestrict ,
ContainerClass* const [26], const FTreeCoordinate [26], const int ) {
}
}; };
......
...@@ -114,7 +114,7 @@ public: ...@@ -114,7 +114,7 @@ public:
/** After Downward */ /** After Downward */
void P2P(const MortonIndex , void P2P(const MortonIndex ,
ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources, ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources,
ContainerClass* const directNeighborsParticles[26], const MortonIndex [26], const int size) { ContainerClass* const directNeighborsParticles[26], const int size) {
// 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();
......
// ===================================================================================
// Logiciel initial: ScalFmm Version 0.5
// Co-auteurs : Olivier Coulaud, Bérenger Bramas.
// Propriétaires : INRIA.
// Copyright © 2011-2012, diffusé sous les termes et conditions d’une licence propriétaire.
// Initial software: ScalFmm Version 0.5
// Co-authors: Olivier Coulaud, Bérenger Bramas.
// Owners: INRIA.
// Copyright © 2011-2012, spread under the terms and conditions of a proprietary license.
// ===================================================================================
#ifndef FTESTPERIODICKERNELS_HPP
#define FTESTPERIODICKERNELS_HPP
#include "FTestKernels.hpp"
/** This kernel is the periodic version of the test kernel
*/
template< class ParticleClass, class CellClass, class ContainerClass>
class FTestPeriodicKernels : public FTestKernels<ParticleClass,CellClass,ContainerClass> {
public:
/** After Downward */
void P2P(const MortonIndex ,
ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources,
ContainerClass* const directNeighborsParticles[26], const FTreeCoordinate [26], const int size) {
// Each particles targeted is impacted by the particles sources
long long int inc = sources->getSize();
if(targets == sources){
inc -= 1;
}
for(int idx = 0 ; idx < size ; ++idx){
inc += directNeighborsParticles[idx]->getSize();
}
typename ContainerClass::BasicIterator iter(*targets);
while( iter.hasNotFinished() ){
iter.data().setDataDown(iter.data().getDataDown() + inc);
iter.gotoNext();
}
}
};
#endif // FTESTPERIODICKERNELS_HPP
...@@ -687,7 +687,7 @@ public: ...@@ -687,7 +687,7 @@ public:
FTreeCoordinate center; FTreeCoordinate center;
center.setPositionFromMorton(inIndex, inLevel); center.setPositionFromMorton(inIndex, inLevel);
const int limite = FMath::pow(2,inLevel); const int limite = FMath::pow2(inLevel);
int idxNeighbors = 0; int idxNeighbors = 0;
...@@ -773,7 +773,7 @@ public: ...@@ -773,7 +773,7 @@ public:
const FTreeCoordinate parentCell(workingCell.getX()>>1,workingCell.getY()>>1,workingCell.getZ()>>1); const FTreeCoordinate parentCell(workingCell.getX()>>1,workingCell.getY()>>1,workingCell.getZ()>>1);
// Limite at parent level number of box (split by 2 by level) // Limite at parent level number of box (split by 2 by level)
const int limite = FMath::pow(2,inLevel-1); const int limite = FMath::pow2(inLevel-1);
int idxNeighbors = 0; int idxNeighbors = 0;
// We test all cells around // We test all cells around
...@@ -838,7 +838,7 @@ public: ...@@ -838,7 +838,7 @@ public:
const FTreeCoordinate parentCell(workingCell.getX()>>1,workingCell.getY()>>1,workingCell.getZ()>>1); const FTreeCoordinate parentCell(workingCell.getX()>>1,workingCell.getY()>>1,workingCell.getZ()>>1);
// Limite at parent level number of box (split by 2 by level) // Limite at parent level number of box (split by 2 by level)
const int limite = FMath::pow(2,inLevel-1); const int limite = FMath::pow2(inLevel-1);
// This is not on a border we can use normal interaction list method // This is not on a border we can use normal interaction list method
if( !(parentCell.getX() == 0 || parentCell.getY() == 0 || parentCell.getZ() == 0 || if( !(parentCell.getX() == 0 || parentCell.getY() == 0 || parentCell.getZ() == 0 ||
...@@ -933,22 +933,9 @@ public: ...@@ -933,22 +933,9 @@ 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 MortonIndex inIndex, const int inLevel){ int getLeafsNeighbors(ContainerClass* inNeighbors[26], const FTreeCoordinate& center, const int inLevel){
MortonIndex inNeighborsIndex[26]; memset( inNeighbors, 0 , 26 * sizeof(ContainerClass*));
return getLeafsNeighborsWithIndex(inNeighbors, inNeighborsIndex, inIndex, inLevel); const int limite = FMath::pow2(inLevel);
}
/** This function fill an array with the neighbors of a cell
* @param inNeighbors the array to store the elements
* @param inIndex the index of the element we want the neighbors
* @param inLevel the level of the element
* @return the number of neighbors
*/
int getLeafsNeighborsWithIndex(ContainerClass* inNeighbors[26], MortonIndex inNeighborsIndex[26], const MortonIndex inIndex, const int inLevel){
FTreeCoordinate center;
center.setPositionFromMorton(inIndex, inLevel);
const int limite = FMath::pow(2,inLevel);
int idxNeighbors = 0; int idxNeighbors = 0;
...@@ -970,8 +957,8 @@ public: ...@@ -970,8 +957,8 @@ public:
ContainerClass* const leaf = getLeafSrc(mortonOther); ContainerClass* const leaf = getLeafSrc(mortonOther);
// add to list if not null // add to list if not null
if(leaf){ if(leaf){
inNeighborsIndex[idxNeighbors] = mortonOther; inNeighbors[(((idxX + 1) * 3) + (idxY +1)) * 3 + idxZ + 1] = leaf;
inNeighbors[idxNeighbors++] = leaf; ++idxNeighbors;
} }
} }
} }
...@@ -987,11 +974,9 @@ public: ...@@ -987,11 +974,9 @@ 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 getLeafsNeighborsWithIndex(ContainerClass* inNeighbors[26], FTreeCoordinate inNeighborsPosition[26], const MortonIndex inIndex, const int inLevel){ int getPeriodicLeafsNeighbors(ContainerClass* inNeighbors[26], const FTreeCoordinate& center, const int inLevel){
FTreeCoordinate center; memset(inNeighbors , 0 , 26 * sizeof(ContainerClass*));
center.setPositionFromMorton(inIndex, inLevel); const int limite = FMath::pow2(inLevel);
const int limite = FMath::pow(2,inLevel);
int idxNeighbors = 0; int idxNeighbors = 0;
...@@ -1039,8 +1024,8 @@ public: ...@@ -1039,8 +1024,8 @@ public:
ContainerClass* const leaf = getLeafSrc(mortonOther); ContainerClass* const leaf = getLeafSrc(mortonOther);
// add to list if not null // add to list if not null
if(leaf){ if(leaf){
inNeighborsPosition[idxNeighbors] = offset; inNeighbors[(((idxX + 1) * 3) + (idxY +1)) * 3 + idxZ + 1] = leaf;
inNeighbors[idxNeighbors++] = leaf; ++idxNeighbors;
} }
} }
} }
......
...@@ -234,16 +234,15 @@ private: ...@@ -234,16 +234,15 @@ private:
octreeIterator.gotoBottomLeft(); octreeIterator.gotoBottomLeft();
// There is a maximum of 26 neighbors // There is a maximum of 26 neighbors
ContainerClass* neighbors[26]; ContainerClass* neighbors[26];
MortonIndex neighborsIndex[26];
// for each leafs // for each leafs
do{ do{
FDEBUG(computationCounterL2P.tic()); FDEBUG(computationCounterL2P.tic());
kernels->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets()); kernels->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets());
FDEBUG(computationCounterL2P.tac()); FDEBUG(computationCounterL2P.tac());
// need the current particles and neighbors particles // need the current particles and neighbors particles
const int counter = tree->getLeafsNeighborsWithIndex(neighbors, neighborsIndex, octreeIterator.getCurrentGlobalIndex(),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, neighborsIndex, counter); kernels->P2P(octreeIterator.getCurrentGlobalIndex(),octreeIterator.getCurrentListTargets(), octreeIterator.getCurrentListSrc() , neighbors, counter);
FDEBUG(computationCounterP2P.tac()); FDEBUG(computationCounterP2P.tac());
} while(octreeIterator.moveRight()); } while(octreeIterator.moveRight());
......
...@@ -232,16 +232,15 @@ private: ...@@ -232,16 +232,15 @@ private:
octreeIterator.gotoBottomLeft(); octreeIterator.gotoBottomLeft();
// There is a maximum of 26 neighbors // There is a maximum of 26 neighbors
ContainerClass* neighbors[26]; ContainerClass* neighbors[26];
FTreeCoordinate neighborsPosition[26];
// for each leafs // for each leafs
do{ do{
FDEBUG(computationCounterL2P.tic()); FDEBUG(computationCounterL2P.tic());
kernels->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets()); kernels->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets());
FDEBUG(computationCounterL2P.tac()); FDEBUG(computationCounterL2P.tac());
// need the current particles and neighbors particles // need the current particles and neighbors particles
const int counter = tree->getLeafsNeighborsWithIndex(neighbors, neighborsPosition, octreeIterator.getCurrentGlobalIndex(),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, neighborsPosition, counter); kernels->P2P(octreeIterator.getCurrentGlobalIndex(),octreeIterator.getCurrentListTargets(), octreeIterator.getCurrentListSrc() , neighbors, counter);
FDEBUG(computationCounterP2P.tac()); FDEBUG(computationCounterP2P.tac());
} while(octreeIterator.moveRight()); } while(octreeIterator.moveRight());
......
...@@ -282,7 +282,6 @@ private: ...@@ -282,7 +282,6 @@ private:
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[26];
MortonIndex neighborsIndex[26];
#pragma omp single nowait #pragma omp single nowait
{ {
...@@ -306,8 +305,8 @@ private: ...@@ -306,8 +305,8 @@ private:
#pragma omp task #pragma omp task
{ {
// need the current particles and neighbors particles // need the current particles and neighbors particles
const int counter = tree->getLeafsNeighborsWithIndex(neighbors, neighborsIndex, octreeIterator.getCurrentGlobalIndex(),heightMinusOne); const int counter = tree->getLeafsNeighbors(neighbors, octreeIterator.getCurrentGlobalCoordinate(),heightMinusOne);
myThreadkernels->P2P(octreeIterator.getCurrentGlobalIndex(),octreeIterator.getCurrentListTargets(), octreeIterator.getCurrentListSrc() , neighbors, neighborsIndex, counter); myThreadkernels->P2P(octreeIterator.getCurrentGlobalIndex(),octreeIterator.getCurrentListTargets(), octreeIterator.getCurrentListSrc() , neighbors, counter);
} }
} }
else{ else{
...@@ -324,8 +323,8 @@ private: ...@@ -324,8 +323,8 @@ private:
typename OctreeClass::Iterator toWork = shapes[idxShape][iterLeaf]; typename OctreeClass::Iterator toWork = shapes[idxShape][iterLeaf];
#pragma omp task #pragma omp task
{ {
const int counter = tree->getLeafsNeighborsWithIndex(neighbors, neighborsIndex, toWork.getCurrentGlobalIndex(),heightMinusOne); const int counter = tree->getLeafsNeighbors(neighbors, toWork.getCurrentGlobalCoordinate(),heightMinusOne);
myThreadkernels->P2P(toWork.getCurrentGlobalIndex(),toWork.getCurrentListTargets(), toWork.getCurrentListSrc() , neighbors, neighborsIndex, counter); myThreadkernels->P2P(toWork.getCurrentGlobalIndex(),toWork.getCurrentListTargets(), toWork.getCurrentListSrc() , neighbors, counter);
} }
} }
......
...@@ -331,7 +331,7 @@ private: ...@@ -331,7 +331,7 @@ private:
startPosAtShape[idxShape] = startPosAtShape[idxShape-1] + this->shapeLeaf[idxShape-1]; startPosAtShape[idxShape] = startPosAtShape[idxShape-1] + this->shapeLeaf[idxShape-1];
} }
#pragma omp parallel #pragma omp parallel
{ {
const float step = float(this->leafsNumber) / float(omp_get_num_threads()); const float step = float(this->leafsNumber) / float(omp_get_num_threads());
...@@ -365,27 +365,26 @@ private: ...@@ -365,27 +365,26 @@ private:
octreeIterator.moveRight(); octreeIterator.moveRight();
} }
#pragma omp barrier #pragma omp barrier
FDEBUG(if(!omp_get_thread_num()) computationCounter.tic()); FDEBUG(if(!omp_get_thread_num()) computationCounter.tic());
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[26];
MortonIndex neighborsIndex[26];
int previous = 0; int previous = 0;
for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){ for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
const int endAtThisShape = this->shapeLeaf[idxShape] + previous; const int endAtThisShape = this->shapeLeaf[idxShape] + previous;
#pragma omp for schedule(dynamic) #pragma omp for schedule(dynamic)
for(int idxLeafs = previous ; idxLeafs < endAtThisShape ; ++idxLeafs){ for(int idxLeafs = previous ; idxLeafs < endAtThisShape ; ++idxLeafs){
LeafData& currentIter = leafsDataArray[idxLeafs]; LeafData& currentIter = leafsDataArray[idxLeafs];
myThreadkernels.L2P(currentIter.cell, currentIter.targets); myThreadkernels.L2P(currentIter.cell, currentIter.targets);
// 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->getLeafsNeighborsWithIndex(neighbors, neighborsIndex, currentIter.index, LeafIndex); const int counter = tree->getLeafsNeighbors(neighbors, currentIter.cell->getCoordinate(), LeafIndex);
myThreadkernels.P2P(currentIter.index, currentIter.targets, currentIter.sources , neighbors, neighborsIndex, counter); myThreadkernels.P2P(currentIter.index, currentIter.targets, currentIter.sources , neighbors, counter);
FDEBUG(if(!omp_get_thread_num()) computationCounterP2P.tac()); FDEBUG(if(!omp_get_thread_num()) computationCounterP2P.tac());
} }
......
...@@ -728,12 +728,15 @@ private: ...@@ -728,12 +728,15 @@ private:
int counter = 0; int counter = 0;
// does we receive this index from someone? // does we receive this index from someone?
for(int idxNeig = 0 ;idxNeig < counterNeighbors ; ++idxNeig){ for(int idxNeig = 0 ;idxNeig < counterNeighbors ; ++idxNeig){
const void* const cellFromOtherProc = tempTree.getCell(neighborsIndex[idxNeig], idxLevel); if(neighborsIndex[idxNeig] < getWorkingInterval(idxLevel , idProcess).min
if(cellFromOtherProc){ || getWorkingInterval(idxLevel , idProcess).max < neighborsIndex[idxNeig]){
neighborsData[counter].deserializeUp(cellFromOtherProc); const void* const cellFromOtherProc = tempTree.getCell(neighborsIndex[idxNeig], idxLevel);
neighborsData[counter].setMortonIndex(neighborsIndex[idxNeig]); if(cellFromOtherProc){
neighbors[ neighborsPosition[counter] ] = &neighborsData[counter]; neighborsData[counter].deserializeUp(cellFromOtherProc);
++counter; neighborsData[counter].setMortonIndex(neighborsIndex[idxNeig]);
neighbors[ neighborsPosition[counter] ] = &neighborsData[counter];
++counter;
}
} }
} }
// need to compute // need to compute
...@@ -1111,26 +1114,25 @@ private: ...@@ -1111,26 +1114,25 @@ private:
FDEBUG(FTic computationCounter); FDEBUG(FTic computationCounter);
#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[26];
MortonIndex neighborsIndex[26];
int previous = 0; int previous = 0;
for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){ for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
const int endAtThisShape = shapeLeaf[idxShape] + previous; const int endAtThisShape = shapeLeaf[idxShape] + previous;
#pragma omp for schedule(dynamic) #pragma omp for schedule(dynamic)
for(int idxLeafs = previous ; idxLeafs < endAtThisShape ; ++idxLeafs){ for(int idxLeafs = previous ; idxLeafs < endAtThisShape ; ++idxLeafs){
if(!leafsNeedOtherShaped.get(idxLeafs)){ if(!leafsNeedOtherShaped.get(idxLeafs)){
LeafData& currentIter = leafsDataArray[idxLeafs]; LeafData& currentIter = leafsDataArray[idxLeafs];
myThreadkernels.L2P(currentIter.cell, currentIter.targets); myThreadkernels.L2P(currentIter.cell, currentIter.targets);
// need the current particles and neighbors particles // need the current particles and neighbors particles
const int counter = tree->getLeafsNeighborsWithIndex(neighbors, neighborsIndex, currentIter.index, LeafIndex); const int counter = tree->getLeafsNeighbors(neighbors, currentIter.cell->getCoordinate(), LeafIndex);
myThreadkernels.P2P( currentIter.index,currentIter.targets, currentIter.sources , neighbors, neighborsIndex, counter); myThreadkernels.P2P( currentIter.index,currentIter.targets, currentIter.sources , neighbors, counter);
} }
} }
...@@ -1184,7 +1186,6 @@ private: ...@@ -1184,7 +1186,6 @@ 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[26];
MortonIndex neighborsIndex[26];
int previous = 0; int previous = 0;
// Box limite // Box limite
const int limite = 1 << (this->OctreeHeight - 1); const int limite = 1 << (this->OctreeHeight - 1);
...@@ -1192,7 +1193,7 @@ private: ...@@ -1192,7 +1193,7 @@ private:
for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){ for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
const int endAtThisShape = shapeLeaf[idxShape] + previous; const int endAtThisShape = shapeLeaf[idxShape] + previous;
#pragma omp for schedule(dynamic) #pragma omp for schedule(dynamic)
for(int idxLeafs = previous ; idxLeafs < endAtThisShape ; ++idxLeafs){ for(int idxLeafs = previous ; idxLeafs < endAtThisShape ; ++idxLeafs){
// Maybe need also data from other? // Maybe need also data from other?
if(leafsNeedOtherShaped.get(idxLeafs)){ if(leafsNeedOtherShaped.get(idxLeafs)){
...@@ -1200,7 +1201,7 @@ private: ...@@ -1200,7 +1201,7 @@ private:
myThreadkernels.L2P(currentIter.cell, currentIter.targets); myThreadkernels.L2P(currentIter.cell, currentIter.targets);
// need the current particles and neighbors particles // need the current particles and neighbors particles
int counter = tree->getLeafsNeighborsWithIndex(neighbors, neighborsIndex, currentIter.index, LeafIndex); int counter = tree->getLeafsNeighbors(neighbors, currentIter.cell->getCoordinate(), LeafIndex);
// Take possible data // Take possible data
MortonIndex indexesNeighbors[26]; MortonIndex indexesNeighbors[26];
...@@ -1211,13 +1212,12 @@ private: ...@@ -1211,13 +1212,12 @@ private:
ContainerClass*const hypotheticNeighbor = otherP2Ptree.getLeafSrc(indexesNeighbors[idxNeigh]); ContainerClass*const hypotheticNeighbor = otherP2Ptree.getLeafSrc(indexesNeighbors[idxNeigh]);
if(hypotheticNeighbor){ if(hypotheticNeighbor){
neighbors[counter] = hypotheticNeighbor; neighbors[counter] = hypotheticNeighbor;
neighborsIndex[counter] = indexesNeighbors[idxNeigh];
++counter; ++counter;
} }
} }
} }
myThreadkernels.P2P( currentIter.index,currentIter.targets, currentIter.sources , neighbors, neighborsIndex, counter); myThreadkernels.P2P( currentIter.index,currentIter.targets, currentIter.sources , neighbors, counter);
} }
} }
...@@ -1277,7 +1277,7 @@ private: ...@@ -1277,7 +1277,7 @@ private:
const FTreeCoordinate parentCell(workingCell.getX()>>1,workingCell.getY()>>1,workingCell.getZ()>>1); const FTreeCoordinate parentCell(workingCell.getX()>>1,workingCell.getY()>>1,workingCell.getZ()>>1);
// Limite at parent level number of box (split by 2 by level) // Limite at parent level number of box (split by 2 by level)
const int limite = FMath::pow(2,inLevel-1); const int limite = FMath::pow2(inLevel-1);
int idxNeighbors = 0; int idxNeighbors = 0;
// We test all cells around // We test all cells around
......
...@@ -801,12 +801,15 @@ private: ...@@ -801,12 +801,15 @@ private:
int counter = 0; int counter = 0;
// does we receive this index from someone? // does we receive this index from someone?
for(int idxNeig = 0 ;idxNeig < counterNeighbors ; ++idxNeig){ for(int idxNeig = 0 ;idxNeig < counterNeighbors ; ++idxNeig){
const void* const cellFromOtherProc = tempTree.getCell(neighborsIndex[idxNeig], idxLevel); if(neighborsIndex[idxNeig] < getWorkingInterval(idxLevel , idProcess).min
if(cellFromOtherProc){ || getWorkingInterval(idxLevel , idProcess).max < neighborsIndex[idxNeig]){
neighborsData[counter].deserializeUp(cellFromOtherProc); const void* const cellFromOtherProc = tempTree.getCell(neighborsIndex[idxNeig], idxLevel);
neighborsData[counter].setMortonIndex(neighborsIndex[idxNeig]); if(cellFromOtherProc){
neighbors[ neighborsPosition[counter] ] = &neighborsData[counter]; neighborsData[counter].deserializeUp(cellFromOtherProc);
++counter; neighborsData[counter].setMortonIndex(neighborsIndex[idxNeig]);
neighbors[ neighborsPosition[counter] ] = &neighborsData[counter];
++counter;
}
} }
} }
...@@ -1036,9 +1039,9 @@ private: ...@@ -1036,9 +1039,9 @@ 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); getNeighborsIndexes(iterArray[idxLeaf].getCurrentGlobalCoordinate(), limite, indexesNeighbors);
for(int idxNeigh = 0 ; idxNeigh < neighCount ; ++idxNeigh){ for(int idxNeigh = 0 ; idxNeigh < 26 ; ++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;