Commit 40067d42 authored by berenger-bramas's avatar berenger-bramas
Browse files

Parallel version is working for procs [2:4] and 200K particles.

Also test for validation has been update to check every things we can.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@165 2616d619-271b-44dc-8df4-d4a8f33a7222
parent 9b487735
......@@ -857,7 +857,7 @@ public:
memset(partsToSend, 0, sizeof(int) * nbProcess);
// To know if a leaf has been already sent to a proc
bool alreadySent[nbProcess];
int alreadySent[nbProcess];
MortonIndex indexesNeighbors[26];
......@@ -865,7 +865,7 @@ public:
FTreeCoordinate center;
center.setPositionFromMorton(iterArray[idxLeaf].getCurrentGlobalIndex(), OctreeHeight - 1);
memset(alreadySent, false, sizeof(bool) * nbProcess);
memset(alreadySent, 0, sizeof(int) * nbProcess);
bool needOther = false;
const int neighCount = getNeighborsIndexes(iterArray[idxLeaf].getCurrentGlobalIndex(), limite, indexesNeighbors);
......@@ -885,7 +885,8 @@ public:
}
if( !alreadySent[procToReceive] && intervals[procToReceive].min <= indexesNeighbors[idxNeigh] && indexesNeighbors[idxNeigh] <= intervals[procToReceive].max){
alreadySent[procToReceive] = true;
alreadySent[procToReceive] = 1;
if(indexToSend[procToReceive] == sizeToSend[procToReceive]){
const int previousSize = sizeToSend[procToReceive];
sizeToSend[procToReceive] = FMath::Max(10*int(sizeof(typename OctreeClass::Iterator)), int(sizeToSend[procToReceive] * 1.5));
......@@ -990,6 +991,8 @@ public:
};
LeafData* const leafsDataArray = new LeafData[this->numberOfLeafs];
FBoolArray leafsNeedOtherShaped(this->numberOfLeafs);
// split data
{
typename OctreeClass::Iterator octreeIterator(tree);
......@@ -1025,6 +1028,7 @@ public:
leafsDataArray[startPosAtShape[shapePosition]].cell = myLeafs[idxInArray].getCurrentCell();
leafsDataArray[startPosAtShape[shapePosition]].targets = myLeafs[idxInArray].getCurrentListTargets();
leafsDataArray[startPosAtShape[shapePosition]].sources = myLeafs[idxInArray].getCurrentListSrc();
if( leafsNeedOther.get(idxLeaf) ) leafsNeedOtherShaped.set(startPosAtShape[shapePosition], true);
++startPosAtShape[shapePosition];
}
......@@ -1054,9 +1058,10 @@ public:
myThreadkernels.L2P(currentIter.cell, currentIter.targets);
// need the current particles and neighbors particles
const int counter = tree->getLeafsNeighborsWithIndex(neighbors, neighborsIndex, currentIter.index,LeafIndex);
const int counter = tree->getLeafsNeighborsWithIndex(neighbors, neighborsIndex, currentIter.index, LeafIndex);
if(leafsNeedOtherShaped.get(idxLeafs)){
if(leafsNeedOther.get(idxLeafs)){
MortonIndex indexesNeighbors[26];
const int neighCount = getNeighborsIndexes(currentIter.index, limite, indexesNeighbors);
int counterAll = counter;
......
......@@ -100,8 +100,8 @@ template<class OctreeClass, class ContainerClass>
void ValidateFMMAlgoProc(OctreeClass* const badTree,
OctreeClass* const valideTree){
std::cout << "Check Result\n";
/*{
const int OctreeHeight = badTree->getHeight();
const int OctreeHeight = badTree->getHeight();
{
typename OctreeClass::Iterator octreeIterator(badTree);
octreeIterator.gotoBottomLeft();
......@@ -109,39 +109,33 @@ void ValidateFMMAlgoProc(OctreeClass* const badTree,
octreeIteratorValide.gotoBottomLeft();
for(int level = OctreeHeight - 1 ; level > 0 ; --level){
int NbLeafs = 0;
do{
++NbLeafs;
} while(octreeIterator.moveRight());
octreeIterator.gotoLeft();
const int startIdx = fmm->getLeft(NbLeafs);
const int endIdx = fmm->getRight(NbLeafs);
// Check that each particle has been summed with all other
std::cout << "Check level " << level << std::endl;
for(int idx = 0 ; idx < startIdx ; ++idx){
octreeIterator.moveRight();
while(octreeIteratorValide.getCurrentGlobalIndex() != octreeIterator.getCurrentGlobalIndex()) {
octreeIteratorValide.moveRight();
}
for(int idx = startIdx ; idx < endIdx ; ++idx){
int countCheck = 0;
do{
if(octreeIterator.getCurrentGlobalIndex() != octreeIteratorValide.getCurrentGlobalIndex()){
std::cout << "Error index are not equal!" << std::endl;
}
else{
if(octreeIterator.getCurrentCell()->getDataUp() != octreeIteratorValide.getCurrentCell()->getDataUp()){
std::cout << "M2M error at level " << level << " up bad " << octreeIterator.getCurrentCell()->getDataUp()
<< " good " << octreeIteratorValide.getCurrentCell()->getDataUp() << " idx " << idx << std::endl;
<< " good " << octreeIteratorValide.getCurrentCell()->getDataUp() << " index " << octreeIterator.getCurrentGlobalIndex() << std::endl;
}
if(octreeIterator.getCurrentCell()->getDataDown() != octreeIteratorValide.getCurrentCell()->getDataDown()){
std::cout << "L2L error at level " << level << " down bad " << octreeIterator.getCurrentCell()->getDataDown()
<< " good " << octreeIteratorValide.getCurrentCell()->getDataDown() << " idx " << idx << std::endl;
<< " good " << octreeIteratorValide.getCurrentCell()->getDataDown() << " index " << octreeIterator.getCurrentGlobalIndex() << std::endl;
}
}
++countCheck;
} while(octreeIteratorValide.moveRight() && octreeIterator.moveRight());
octreeIterator.moveRight();
octreeIteratorValide.moveRight();
}
std::cout << "Has checked " << countCheck << " cells" << std::endl;
// Check that each particle has been summed with all other
octreeIterator.moveUp();
octreeIterator.gotoLeft();
......@@ -149,7 +143,7 @@ void ValidateFMMAlgoProc(OctreeClass* const badTree,
octreeIteratorValide.moveUp();
octreeIteratorValide.gotoLeft();
}
}*/
}
{
int NbPart = 0;
int NbLeafs = 0;
......@@ -209,6 +203,11 @@ void ValidateFMMAlgoProc(OctreeClass* const badTree,
valideOctreeIterator.moveRight();
}
ContainerClass* badNeighbors[26];
MortonIndex badNeighborsIndex[26];
ContainerClass* validNeighbors[26];
MortonIndex validNeighborsIndex[26];
do {
if(valideOctreeIterator.getCurrentGlobalIndex() != octreeIterator.getCurrentGlobalIndex()){
printf("Do not have the same index valide %lld invalide %lld \n",
......@@ -216,10 +215,45 @@ void ValidateFMMAlgoProc(OctreeClass* const badTree,
break;
}
/*const int badCounter = badTree->getLeafsNeighborsWithIndex(badNeighbors, badNeighborsIndex, octreeIterator.getCurrentGlobalIndex(), OctreeHeight - 1);
const int validCounter = valideTree->getLeafsNeighborsWithIndex(validNeighbors, validNeighborsIndex, valideOctreeIterator.getCurrentGlobalIndex(), OctreeHeight - 1);
if(badCounter != validCounter){
printf("Do not have the same number of neighbors at index %lld, valide is %d invalide is %d\n", octreeIterator.getCurrentGlobalIndex(),
validCounter, badCounter);
printf("valide neighbors {");
for(int idxNeigh = 0 ; idxNeigh < validCounter ; ++idxNeigh){
printf("%lld,", validNeighborsIndex[idxNeigh]);
}
printf("}\n");
}*/
if(octreeIterator.getCurrentListTargets()->getSize() != valideOctreeIterator.getCurrentListTargets()->getSize()){
printf("Do not have the same number of particle at leaf id %lld, valide %d invalide %d \n",
octreeIterator.getCurrentGlobalIndex(), valideOctreeIterator.getCurrentListTargets()->getSize(), octreeIterator.getCurrentListTargets()->getSize());
}
else {
typename ContainerClass::BasicIterator iter(*octreeIterator.getCurrentListTargets());
typename ContainerClass::BasicIterator iterValide(*valideOctreeIterator.getCurrentListTargets());
for(int idxPart = 0 ; idxPart < octreeIterator.getCurrentListTargets()->getSize() ; ++idxPart){
// If a particles has been impacted by less than NbPart - 1 (the current particle)
// there is a problem
if( iter.data().getDataDown() != iterValide.data().getDataDown()){
std::cout << "Problem on leaf " << octreeIterator.getCurrentGlobalIndex() <<
" part " << idxPart << " valide data down " << iterValide.data().getDataDown() <<
" invalide " << iter.data().getDataDown() << "\n";
std::cout << "Data down for leaf is: valide " << valideOctreeIterator.getCurrentCell()->getDataDown()
<< " invalide " << octreeIterator.getCurrentCell()->getDataDown()
<< " size is: valide " << valideOctreeIterator.getCurrentListTargets()->getSize()
<< " invalide " << octreeIterator.getCurrentListTargets()->getSize() << std::endl;
}
iter.gotoNext();
iterValide.gotoNext();
}
}
}while( octreeIterator.moveRight() && valideOctreeIterator.moveRight());
}
......
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