Commit 76c383e2 authored by berenger-bramas's avatar berenger-bramas

Start working on increasing P2P performances :

- change the kernels to be mutual P2P by default

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@93 2616d619-271b-44dc-8df4-d4a8f33a7222
parent bbf607e1
...@@ -16,4 +16,5 @@ tmp/ ...@@ -16,4 +16,5 @@ tmp/
*~ *~
*TAGS *TAGS
*#*# *#*#
*.bin.*
...@@ -658,61 +658,8 @@ public: ...@@ -658,61 +658,8 @@ public:
* @return the number of neighbors * @return the number of neighbors
*/ */
int getDistantNeighbors(CellClass* inNeighbors[208], const MortonIndex inIndex, const int inLevel) const{ int getDistantNeighbors(CellClass* inNeighbors[208], const MortonIndex inIndex, const int inLevel) const{
// Take the neighbors != brothers MortonIndex inNeighborsIndex[208];
CellClass* directNeighbors[26]; return getDistantNeighborsWithIndex(inNeighbors, inNeighborsIndex, inIndex, inLevel);
const int nbDirectNeighbors = getNeighborsNoBrothers(directNeighbors,inIndex,inLevel);
// Then take each child of the parent's neighbors if not in directNeighbors
// Father coordinate
FTreeCoordinate center;
center.setPositionFromMorton(inIndex>>3, inLevel-1);
// Limite at parent level
const long limite = FMath::pow(2,inLevel-1);
int idxNeighbors = 0;
// We test all cells around
for(long idxX = -1 ; idxX <= 1 ; ++idxX){
if(!FMath::Between(center.getX() + idxX,0l,limite)) continue;
for(long idxY = -1 ; idxY <= 1 ; ++idxY){
if(!FMath::Between(center.getY() + idxY,0l,limite)) continue;
for(long idxZ = -1 ; idxZ <= 1 ; ++idxZ){
if(!FMath::Between(center.getZ() + idxZ,0l,limite)) continue;
// if we are not on the current cell
if( !(!idxX && !idxY && !idxZ) ){
const FTreeCoordinate other(center.getX() + idxX,center.getY() + idxY,center.getZ() + idxZ);
const MortonIndex mortonOther = other.getMortonIndex(inLevel-1);
// Get child
CellClass** const cells = getCellPt(mortonOther<<3, inLevel);
// If there is one or more child
if(cells){
// For each child
for(int idxCousin = 0 ; idxCousin < 8 ; ++idxCousin){
if(cells[idxCousin]){
// Test if it is a direct neighbor
bool existInDirectNeigh = false;
for(int idxDirectNeigh = 0 ; idxDirectNeigh < nbDirectNeighbors ; ++idxDirectNeigh){
if( cells[idxCousin] == directNeighbors[idxDirectNeigh] ){
existInDirectNeigh = true;
break;
}
}
// add to neighbors
if(!existInDirectNeigh){
inNeighbors[idxNeighbors++] = cells[idxCousin];
}
}
}
}
}
}
}
}
return idxNeighbors;
} }
...@@ -815,6 +762,17 @@ public: ...@@ -815,6 +762,17 @@ public:
* @return the number of neighbors * @return the number of neighbors
*/ */
int getLeafsNeighbors(FList<ParticleClass*>* inNeighbors[26], const MortonIndex inIndex, const int inLevel){ int getLeafsNeighbors(FList<ParticleClass*>* inNeighbors[26], const MortonIndex inIndex, const int inLevel){
MortonIndex inNeighborsIndex[26];
return getLeafsNeighborsWithIndex(inNeighbors, inNeighborsIndex, inIndex, 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(FList<ParticleClass*>* inNeighbors[26], MortonIndex inNeighborsIndex[26], const MortonIndex inIndex, const int inLevel){
FTreeCoordinate center; FTreeCoordinate center;
center.setPositionFromMorton(inIndex, inLevel); center.setPositionFromMorton(inIndex, inLevel);
...@@ -839,7 +797,10 @@ public: ...@@ -839,7 +797,10 @@ public:
// get cell // get cell
FList<ParticleClass*>* const leaf = getLeafSrc(mortonOther); FList<ParticleClass*>* const leaf = getLeafSrc(mortonOther);
// add to list if not null // add to list if not null
if(leaf) inNeighbors[idxNeighbors++] = leaf; if(leaf){
inNeighborsIndex[idxNeighbors] = mortonOther;
inNeighbors[idxNeighbors++] = leaf;
}
} }
} }
} }
......
...@@ -621,7 +621,7 @@ protected: ...@@ -621,7 +621,7 @@ protected:
FFmbKernels& operator=(const FFmbKernels&){ return *this; } FFmbKernels& operator=(const FFmbKernels&){ return *this; }
public: public:
FFmbKernels(const FReal inTreeWidth, const bool inUseMutual = false) : FFmbKernels(const FReal inTreeWidth, const bool inUseMutual = true) :
treeWidthAtRoot(inTreeWidth), UseMutual(inUseMutual) { treeWidthAtRoot(inTreeWidth), UseMutual(inUseMutual) {
buildPrecompute(); buildPrecompute();
} }
...@@ -1347,13 +1347,11 @@ public: ...@@ -1347,13 +1347,11 @@ public:
while( iterTarget.isValide() ){ while( iterTarget.isValide() ){
for(int idxDirectNeighbors = 0 ; idxDirectNeighbors < size ; ++idxDirectNeighbors){ for(int idxDirectNeighbors = 0 ; idxDirectNeighbors < size ; ++idxDirectNeighbors){
if(directNeighbors[idxDirectNeighbors] < targets){ typename FList<ParticleClass*>::BasicIterator iterSource(*directNeighbors[idxDirectNeighbors]);
typename FList<ParticleClass*>::BasicIterator iterSource(*directNeighbors[idxDirectNeighbors]); while( iterSource.isValide() ){
while( iterSource.isValide() ){ DIRECT_COMPUTATION_MUTUAL_SOFT(&iterTarget.value(),
DIRECT_COMPUTATION_MUTUAL_SOFT(&iterTarget.value(), &iterSource.value());
&iterSource.value()); iterSource.progress();
iterSource.progress();
}
} }
} }
......
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