Commit 06149ef8 authored by berenger-bramas's avatar berenger-bramas

Update the new M2L function prototypes.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@374 2616d619-271b-44dc-8df4-d4a8f33a7222
parent d3c01baa
...@@ -59,7 +59,9 @@ public: ...@@ -59,7 +59,9 @@ public:
// The pole is impacted by what represent other poles // The pole is impacted by what represent other poles
for(int idx = 0 ; idx < 343 ; ++idx){ for(int idx = 0 ; idx < 343 ; ++idx){
if(distantNeighbors[idx]) pole->setDataDown(pole->getDataDown() + distantNeighbors[idx]->getDataUp()); if(distantNeighbors[idx]){
pole->setDataDown(pole->getDataDown() + distantNeighbors[idx]->getDataUp());
}
} }
} }
......
...@@ -805,7 +805,7 @@ public: ...@@ -805,7 +805,7 @@ public:
// Test if it is a direct neighbor // Test if it is a direct neighbor
if(FMath::Abs(xdiff) > 1 || FMath::Abs(ydiff) > 1 || FMath::Abs(zdiff) > 1){ if(FMath::Abs(xdiff) > 1 || FMath::Abs(ydiff) > 1 || FMath::Abs(zdiff) > 1){
// add to neighbors // add to neighbors
inNeighbors[ ((xdiff * 7) + ydiff) * 7 + zdiff] = cells[idxCousin]; inNeighbors[ (((xdiff+3) * 7) + (ydiff+3)) * 7 + zdiff + 3] = cells[idxCousin];
++idxNeighbors; ++idxNeighbors;
} }
} }
...@@ -886,7 +886,7 @@ public: ...@@ -886,7 +886,7 @@ public:
// Test if it is a direct neighbor // Test if it is a direct neighbor
if(FMath::Abs(xdiff) > 1 || FMath::Abs(ydiff) > 1 || FMath::Abs(zdiff) > 1){ if(FMath::Abs(xdiff) > 1 || FMath::Abs(ydiff) > 1 || FMath::Abs(zdiff) > 1){
// add to neighbors // add to neighbors
inNeighbors[((xdiff * 7) + ydiff) * 7 + zdiff] = cells[idxCousin]; inNeighbors[((((xdiff+3) * 7) + (ydiff+3))) * 7 + zdiff + 3] = cells[idxCousin];
++idxNeighbors; ++idxNeighbors;
} }
} }
......
...@@ -1304,7 +1304,7 @@ private: ...@@ -1304,7 +1304,7 @@ private:
// Test if it is a direct neighbor // Test if it is a direct neighbor
if(FMath::Abs(xdiff) > 1 || FMath::Abs(ydiff) > 1 || FMath::Abs(zdiff) > 1){ if(FMath::Abs(xdiff) > 1 || FMath::Abs(ydiff) > 1 || FMath::Abs(zdiff) > 1){
// add to neighbors // add to neighbors
inNeighborsPosition[idxNeighbors] = (( (xdiff+3) * 7) + (ydiff+3)) * 7 + zdiff + 3; inNeighborsPosition[idxNeighbors] = ((( (xdiff+3) * 7) + (ydiff+3))) * 7 + zdiff + 3;
inNeighbors[idxNeighbors++] = (mortonOther << 3) | idxCousin; inNeighbors[idxNeighbors++] = (mortonOther << 3) | idxCousin;
} }
} }
......
...@@ -716,7 +716,7 @@ private: ...@@ -716,7 +716,7 @@ private:
#pragma omp parallel #pragma omp parallel
{ {
KernelClass * const myThreadkernels = kernels[omp_get_thread_num()]; KernelClass * const myThreadkernels = kernels[omp_get_thread_num()];
const CellClass* neighbors[189]; const CellClass* neighbors[343];
#pragma omp for schedule(dynamic) nowait #pragma omp for schedule(dynamic) nowait
for(int idxCell = 0 ; idxCell < numberOfCells ; ++idxCell){ for(int idxCell = 0 ; idxCell < numberOfCells ; ++idxCell){
...@@ -1412,7 +1412,7 @@ private: ...@@ -1412,7 +1412,7 @@ private:
// Test if it is a direct neighbor // Test if it is a direct neighbor
if(FMath::Abs(xdiff) > 1 || FMath::Abs(ydiff) > 1 || FMath::Abs(zdiff) > 1){ if(FMath::Abs(xdiff) > 1 || FMath::Abs(ydiff) > 1 || FMath::Abs(zdiff) > 1){
// add to neighbors // add to neighbors
inNeighborsPosition[idxNeighbors] = (( (xdiff+3) * 7) + (ydiff+3)) * 7 + zdiff + 3; inNeighborsPosition[idxNeighbors] = ((( (xdiff+3) * 7) + (ydiff+3))) * 7 + zdiff + 3;
inNeighbors[idxNeighbors++] = (mortonOtherParent << 3) | idxCousin; inNeighbors[idxNeighbors++] = (mortonOtherParent << 3) | idxCousin;
} }
} }
......
...@@ -125,7 +125,7 @@ public: ...@@ -125,7 +125,7 @@ public:
// For all neighbors compute M2L // For all neighbors compute M2L
for(int idxNeigh = 0 ; idxNeigh < 343 ; ++idxNeigh){ for(int idxNeigh = 0 ; idxNeigh < 343 ; ++idxNeigh){
if( distantNeighbors[idxNeigh] ){ if( distantNeighbors[idxNeigh] ){
const FComplexe* const transitionVector = &preM2LTransitions[inLevel + Parent::periodicLevels][idxNeigh]; const FComplexe* const transitionVector = &preM2LTransitions[inLevel + Parent::periodicLevels][idxNeigh * FF_MATRIX_SIZE];
multipoleToLocal(pole->getLocal(), distantNeighbors[idxNeigh]->getMultipole(), transitionVector); multipoleToLocal(pole->getLocal(), distantNeighbors[idxNeigh]->getMultipole(), transitionVector);
} }
} }
......
...@@ -125,7 +125,7 @@ public: ...@@ -125,7 +125,7 @@ public:
// For all neighbors compute M2L // For all neighbors compute M2L
for(int idxNeigh = 0 ; idxNeigh < 343 ; ++idxNeigh){ for(int idxNeigh = 0 ; idxNeigh < 343 ; ++idxNeigh){
if( distantNeighbors[idxNeigh] ){ if( distantNeighbors[idxNeigh] ){
const FComplexe* const transitionVector = &preM2LTransitions[inLevel + Parent::periodicLevels][idxNeigh]; const FComplexe* const transitionVector = &preM2LTransitions[inLevel + Parent::periodicLevels][idxNeigh * FF_MATRIX_SIZE];
multipoleToLocal(pole->getLocal(), distantNeighbors[idxNeigh]->getMultipole(), transitionVector); multipoleToLocal(pole->getLocal(), distantNeighbors[idxNeigh]->getMultipole(), transitionVector);
} }
} }
......
...@@ -87,23 +87,18 @@ public: ...@@ -87,23 +87,18 @@ public:
} }
/** M2L with a cell and all the existing neighbors */ /** M2L with a cell and all the existing neighbors */
void M2L(CellClass* const FRestrict pole, const CellClass* distantNeighbors[189], void M2L(CellClass* const FRestrict pole, const CellClass* distantNeighbors[343],
const int size, const int inLevel) { const int /*size*/, const int inLevel) {
const FTreeCoordinate& coordCenter = pole->getCoordinate();
// For all neighbors compute M2L // For all neighbors compute M2L
for(int idxNeigh = 0 ; idxNeigh < size ; ++idxNeigh){ for(int idxNeigh = 0 ; idxNeigh < 343 ; ++idxNeigh){
const FTreeCoordinate& coordNeighbors = distantNeighbors[idxNeigh]->getCoordinate(); if( distantNeighbors[idxNeigh] ){
const FComplexe* const transitionVector = &preM2LTransitions[inLevel + Parent::periodicLevels] const FComplexe* const transitionVector = &preM2LTransitions[inLevel + Parent::periodicLevels][idxNeigh * devM2lP];
[indexM2LTransition((coordCenter.getX() - coordNeighbors.getX()), multipoleToLocal(pole->getLocal(), distantNeighbors[idxNeigh]->getMultipole(), transitionVector);
(coordCenter.getY() - coordNeighbors.getY()), }
(coordCenter.getZ() - coordNeighbors.getZ()))];
multipoleToLocal(pole->getLocal(), distantNeighbors[idxNeigh]->getMultipole(), transitionVector);
} }
} }
/** M2L /** M2L
*We compute the conversion of multipole_exp_src in *p_center_of_exp_src to *We compute the conversion of multipole_exp_src in *p_center_of_exp_src to
*a local expansion in *p_center_of_exp_target, and add the result to local_exp_target. *a local expansion in *p_center_of_exp_target, and add the result to local_exp_target.
......
...@@ -345,7 +345,7 @@ protected: ...@@ -345,7 +345,7 @@ protected:
/** To access te pre computed M2L transfer vector */ /** To access te pre computed M2L transfer vector */
int indexM2LTransition(const int idxX,const int idxY,const int idxZ) const { int indexM2LTransition(const int idxX,const int idxY,const int idxZ) const {
return (((((idxX+3) * 7) + (idxY+3)) * 7 ) + (idxZ+3)) * devM2lP; return (((((idxX+3) * 7) + (idxY+3)) * 7 ) + (idxZ+3));
} }
/** Alloc and init pre-vectors*/ /** Alloc and init pre-vectors*/
...@@ -358,7 +358,7 @@ protected: ...@@ -358,7 +358,7 @@ protected:
FReal treeWidthAtLevel = Parent::boxWidth * FReal(1 << Parent::periodicLevels); FReal treeWidthAtLevel = Parent::boxWidth * FReal(1 << Parent::periodicLevels);
for(int idxLevel = -Parent::periodicLevels ; idxLevel < Parent::treeHeight ; ++idxLevel ){ for(int idxLevel = -Parent::periodicLevels ; idxLevel < Parent::treeHeight ; ++idxLevel ){
// Allocate data for this level // Allocate data for this level
preM2LTransitions[idxLevel + Parent::periodicLevels] = reinterpret_cast<RotationM2LTransfer*>(new char[(7 * 7 * 7) * devM2lP * sizeof(RotationM2LTransfer)]); preM2LTransitions[idxLevel + Parent::periodicLevels] = reinterpret_cast<RotationM2LTransfer*>(new char[(7 * 7 * 7) * sizeof(RotationM2LTransfer)]);
// Precompute transfer vector // Precompute transfer vector
for(int idxX = -3 ; idxX <= 3 ; ++idxX ){ for(int idxX = -3 ; idxX <= 3 ; ++idxX ){
for(int idxY = -3 ; idxY <= 3 ; ++idxY ){ for(int idxY = -3 ; idxY <= 3 ; ++idxY ){
...@@ -409,33 +409,14 @@ public: ...@@ -409,33 +409,14 @@ public:
} }
/** M2L with a cell and all the existing neighbors */ /** M2L with a cell and all the existing neighbors */
void M2L(CellClass* const FRestrict pole, const CellClass* distantNeighbors[189], void M2L(CellClass* const FRestrict pole, const CellClass* distantNeighbors[343],
const int size, const int inLevel) { const int /*size*/, const int inLevel) {
const FTreeCoordinate& coordCenter = pole->getCoordinate();
// For all neighbors compute M2L // For all neighbors compute M2L
for(int idxNeigh = 0 ; idxNeigh < size ; ++idxNeigh){ for(int idxNeigh = 0 ; idxNeigh < 343 ; ++idxNeigh){
const FTreeCoordinate& coordNeighbors = distantNeighbors[idxNeigh]->getCoordinate(); if(distantNeighbors[idxNeigh]){
const RotationM2LTransfer& transitionVector = preM2LTransitions[inLevel + Parent::periodicLevels] const RotationM2LTransfer& transitionVector = preM2LTransitions[inLevel + Parent::periodicLevels][idxNeigh];
[indexM2LTransition((coordCenter.getX() - coordNeighbors.getX()), multipoleToLocal(pole->getLocal(), distantNeighbors[idxNeigh]->getMultipole(), transitionVector);
(coordCenter.getY() - coordNeighbors.getY()), }
(coordCenter.getZ() - coordNeighbors.getZ()))];
multipoleToLocal(pole->getLocal(), distantNeighbors[idxNeigh]->getMultipole(), transitionVector);
}
}
/** Before Downward */
void M2L(CellClass* const FRestrict local, const CellClass* distantNeighbors[189],
const FTreeCoordinate neighborsRelativePositions[189],
const int size, const int inLevel) {
// For all neighbors compute M2L
for(int idxNeigh = 0 ; idxNeigh < size ; ++idxNeigh){
const RotationM2LTransfer& transitionVector = preM2LTransitions[inLevel + Parent::periodicLevels]
[indexM2LTransition(neighborsRelativePositions[idxNeigh].getX(),
neighborsRelativePositions[idxNeigh].getY(),
neighborsRelativePositions[idxNeigh].getZ())];
multipoleToLocal(local->getLocal(), distantNeighbors[idxNeigh]->getMultipole(), transitionVector);
} }
} }
......
...@@ -51,7 +51,7 @@ int main(int argc, char ** argv){ ...@@ -51,7 +51,7 @@ int main(int argc, char ** argv){
typedef FTestKernels<ParticleClass, CellClass, ContainerClass > KernelClass; typedef FTestKernels<ParticleClass, CellClass, ContainerClass > KernelClass;
// FFmmAlgorithmTask FFmmAlgorithmThread // FFmmAlgorithmTask FFmmAlgorithmThread
typedef FFmmAlgorithmTask<OctreeClass, ParticleClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; typedef FFmmAlgorithm<OctreeClass, ParticleClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass;
///////////////////////What we do///////////////////////////// ///////////////////////What we do/////////////////////////////
std::cout << ">> This executable has to be used to test the FMM algorithm.\n"; std::cout << ">> This executable has to be used to test the FMM algorithm.\n";
......
...@@ -194,7 +194,7 @@ int main(int argc, char ** argv){ ...@@ -194,7 +194,7 @@ int main(int argc, char ** argv){
if(child[idxChild]) ++nbChildAtLevel[idxArray]; if(child[idxChild]) ++nbChildAtLevel[idxArray];
} }
const FBasicCell* neighbors[189]; const FBasicCell* neighbors[343];
M2LCalculusAtLevel[idxArray] += tree.getInteractionNeighbors(neighbors, octreeIterator.getCurrentGlobalCoordinate(),idxLevel); M2LCalculusAtLevel[idxArray] += tree.getInteractionNeighbors(neighbors, octreeIterator.getCurrentGlobalCoordinate(),idxLevel);
......
...@@ -113,7 +113,7 @@ class TestFmb : public FUTester<TestFmb> { ...@@ -113,7 +113,7 @@ class TestFmb : public FUTester<TestFmb> {
algo.execute(); algo.execute();
// If needed save the result // If needed save the result
FTreeIO::Save<OctreeClass, CellClass, ParticleClass, FTreeIO::Serializer<CellClass, ParticleClass> >(DataFile, testTree); // FTreeIO::Save<OctreeClass, CellClass, ParticleClass, FTreeIO::Serializer<CellClass, ParticleClass> >(DataFile, testTree);
// Load previous result // Load previous result
OctreeClass goodTree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); OctreeClass goodTree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox());
......
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