Commit 0b6ed9f6 authored by BRAMAS Berenger's avatar BRAMAS Berenger
Browse files

Add a test to do only P2P or L2P in Algorithm

parent 8b2baebb
...@@ -79,7 +79,7 @@ public: ...@@ -79,7 +79,7 @@ public:
if(operationsToProceed & FFmmL2L) downardPass(); if(operationsToProceed & FFmmL2L) downardPass();
if( (operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P) ) directPass(); if( (operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P) ) directPass((operationsToProceed & FFmmP2P),(operationsToProceed & FFmmL2P));
} }
private: private:
...@@ -236,7 +236,7 @@ private: ...@@ -236,7 +236,7 @@ private:
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
/** P2P */ /** P2P */
void directPass(){ void directPass(const bool p2pEnabled, const bool l2pEnabled){
FLOG( FLog::Controller.write("\tStart Direct Pass\n").write(FLog::Flush); ); FLOG( FLog::Controller.write("\tStart Direct Pass\n").write(FLog::Flush); );
FLOG(FTic counterTime); FLOG(FTic counterTime);
FLOG(FTic computationCounterL2P); FLOG(FTic computationCounterL2P);
...@@ -250,15 +250,19 @@ private: ...@@ -250,15 +250,19 @@ private:
ContainerClass* neighbors[27]; ContainerClass* neighbors[27];
// for each leafs // for each leafs
do{ do{
FLOG(computationCounterL2P.tic()); if(l2pEnabled){
kernels->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets()); FLOG(computationCounterL2P.tic());
FLOG(computationCounterL2P.tac()); kernels->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets());
// need the current particles and neighbors particles FLOG(computationCounterL2P.tac());
const int counter = tree->getLeafsNeighbors(neighbors, octreeIterator.getCurrentGlobalCoordinate(),heightMinusOne); }
FLOG(computationCounterP2P.tic()); if(p2pEnabled){
kernels->P2P(octreeIterator.getCurrentGlobalCoordinate(),octreeIterator.getCurrentListTargets(), // need the current particles and neighbors particles
octreeIterator.getCurrentListSrc(), neighbors, counter); const int counter = tree->getLeafsNeighbors(neighbors, octreeIterator.getCurrentGlobalCoordinate(),heightMinusOne);
FLOG(computationCounterP2P.tac()); FLOG(computationCounterP2P.tic());
kernels->P2P(octreeIterator.getCurrentGlobalCoordinate(),octreeIterator.getCurrentListTargets(),
octreeIterator.getCurrentListSrc(), neighbors, counter);
FLOG(computationCounterP2P.tac());
}
} while(octreeIterator.moveRight()); } while(octreeIterator.moveRight());
......
...@@ -97,7 +97,7 @@ public: ...@@ -97,7 +97,7 @@ public:
if(operationsToProceed & FFmmL2L) downardPass(); if(operationsToProceed & FFmmL2L) downardPass();
if((operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P)) directPass(); if((operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P)) directPass((operationsToProceed & FFmmP2P),(operationsToProceed & FFmmL2P));
} }
...@@ -247,7 +247,7 @@ public: ...@@ -247,7 +247,7 @@ public:
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
/** P2P */ /** P2P */
void directPass(){ void directPass(const bool p2pEnabled, const bool l2pEnabled){
FLOG( FLog::Controller.write("\tStart Direct Pass\n").write(FLog::Flush); ); FLOG( FLog::Controller.write("\tStart Direct Pass\n").write(FLog::Flush); );
FLOG(FTic counterTime); FLOG(FTic counterTime);
FLOG(FTic computationCounterL2P); FLOG(FTic computationCounterL2P);
...@@ -264,64 +264,65 @@ public: ...@@ -264,64 +264,65 @@ public:
bool hasPeriodicLeaves; bool hasPeriodicLeaves;
// for each leafs // for each leafs
do{ do{
FLOG(computationCounterL2P.tic()); if(l2pEnabled){
kernels->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets()); FLOG(computationCounterL2P.tic());
FLOG(computationCounterL2P.tac()); kernels->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets());
FLOG(computationCounterL2P.tac());
// need the current particles and neighbors particles }
const FTreeCoordinate centerOfLeaf = octreeIterator.getCurrentGlobalCoordinate(); if(p2pEnabled){
const int counter = tree->getPeriodicLeafsNeighbors( neighbors, offsets, &hasPeriodicLeaves, centerOfLeaf, heightMinusOne, AllDirs); // need the current particles and neighbors particles
int periodicNeighborsCounter = 0; const FTreeCoordinate centerOfLeaf = octreeIterator.getCurrentGlobalCoordinate();
const int counter = tree->getPeriodicLeafsNeighbors( neighbors, offsets, &hasPeriodicLeaves, centerOfLeaf, heightMinusOne, AllDirs);
if(hasPeriodicLeaves){ int periodicNeighborsCounter = 0;
ContainerClass* periodicNeighbors[27];
memset(periodicNeighbors, 0, 27 * sizeof(ContainerClass*)); if(hasPeriodicLeaves){
ContainerClass* periodicNeighbors[27];
for(int idxNeig = 0 ; idxNeig < 27 ; ++idxNeig){ memset(periodicNeighbors, 0, 27 * sizeof(ContainerClass*));
if( neighbors[idxNeig] && !offsets[idxNeig].equals(0,0,0) ){
// Put periodic neighbors into other array for(int idxNeig = 0 ; idxNeig < 27 ; ++idxNeig){
periodicNeighbors[idxNeig] = neighbors[idxNeig]; if( neighbors[idxNeig] && !offsets[idxNeig].equals(0,0,0) ){
neighbors[idxNeig] = nullptr; // Put periodic neighbors into other array
++periodicNeighborsCounter; periodicNeighbors[idxNeig] = neighbors[idxNeig];
neighbors[idxNeig] = nullptr;
FReal*const positionsX = periodicNeighbors[idxNeig]->getWPositions()[0]; ++periodicNeighborsCounter;
FReal*const positionsY = periodicNeighbors[idxNeig]->getWPositions()[1];
FReal*const positionsZ = periodicNeighbors[idxNeig]->getWPositions()[2]; FReal*const positionsX = periodicNeighbors[idxNeig]->getWPositions()[0];
FReal*const positionsY = periodicNeighbors[idxNeig]->getWPositions()[1];
for(int idxPart = 0; idxPart < periodicNeighbors[idxNeig]->getNbParticles() ; ++idxPart){ FReal*const positionsZ = periodicNeighbors[idxNeig]->getWPositions()[2];
positionsX[idxPart] += boxWidth * FReal(offsets[idxNeig].getX());
positionsY[idxPart] += boxWidth * FReal(offsets[idxNeig].getY()); for(int idxPart = 0; idxPart < periodicNeighbors[idxNeig]->getNbParticles() ; ++idxPart){
positionsZ[idxPart] += boxWidth * FReal(offsets[idxNeig].getZ()); positionsX[idxPart] += boxWidth * FReal(offsets[idxNeig].getX());
positionsY[idxPart] += boxWidth * FReal(offsets[idxNeig].getY());
positionsZ[idxPart] += boxWidth * FReal(offsets[idxNeig].getZ());
}
} }
} }
}
FLOG(computationCounterP2P.tic());
kernels->P2PRemote(octreeIterator.getCurrentGlobalCoordinate(),octreeIterator.getCurrentListTargets(),
octreeIterator.getCurrentListSrc(), periodicNeighbors, periodicNeighborsCounter);
FLOG(computationCounterP2P.tac());
for(int idxNeig = 0 ; idxNeig < 27 ; ++idxNeig){
if( periodicNeighbors[idxNeig] ){
FReal*const positionsX = periodicNeighbors[idxNeig]->getWPositions()[0];
FReal*const positionsY = periodicNeighbors[idxNeig]->getWPositions()[1];
FReal*const positionsZ = periodicNeighbors[idxNeig]->getWPositions()[2];
for(int idxPart = 0; idxPart < periodicNeighbors[idxNeig]->getNbParticles() ; ++idxPart){ FLOG(computationCounterP2P.tic());
positionsX[idxPart] -= boxWidth * FReal(offsets[idxNeig].getX()); kernels->P2PRemote(octreeIterator.getCurrentGlobalCoordinate(),octreeIterator.getCurrentListTargets(),
positionsY[idxPart] -= boxWidth * FReal(offsets[idxNeig].getY()); octreeIterator.getCurrentListSrc(), periodicNeighbors, periodicNeighborsCounter);
positionsZ[idxPart] -= boxWidth * FReal(offsets[idxNeig].getZ()); FLOG(computationCounterP2P.tac());
for(int idxNeig = 0 ; idxNeig < 27 ; ++idxNeig){
if( periodicNeighbors[idxNeig] ){
FReal*const positionsX = periodicNeighbors[idxNeig]->getWPositions()[0];
FReal*const positionsY = periodicNeighbors[idxNeig]->getWPositions()[1];
FReal*const positionsZ = periodicNeighbors[idxNeig]->getWPositions()[2];
for(int idxPart = 0; idxPart < periodicNeighbors[idxNeig]->getNbParticles() ; ++idxPart){
positionsX[idxPart] -= boxWidth * FReal(offsets[idxNeig].getX());
positionsY[idxPart] -= boxWidth * FReal(offsets[idxNeig].getY());
positionsZ[idxPart] -= boxWidth * FReal(offsets[idxNeig].getZ());
}
} }
} }
} }
}
FLOG(computationCounterP2P.tic());
kernels->P2P(octreeIterator.getCurrentGlobalCoordinate(),octreeIterator.getCurrentListTargets(),
octreeIterator.getCurrentListSrc(), neighbors, counter - periodicNeighborsCounter);
FLOG(computationCounterP2P.tac());
FLOG(computationCounterP2P.tic());
kernels->P2P(octreeIterator.getCurrentGlobalCoordinate(),octreeIterator.getCurrentListTargets(),
octreeIterator.getCurrentListSrc(), neighbors, counter - periodicNeighborsCounter);
FLOG(computationCounterP2P.tac());
}
} while(octreeIterator.moveRight()); } while(octreeIterator.moveRight());
......
...@@ -94,7 +94,7 @@ public: ...@@ -94,7 +94,7 @@ public:
if(operationsToProceed & FFmmL2L) downardPass(); if(operationsToProceed & FFmmL2L) downardPass();
if((operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P)) directPass(); if((operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P)) directPass((operationsToProceed & FFmmP2P),(operationsToProceed & FFmmL2P));
} }
private: private:
...@@ -281,7 +281,7 @@ private: ...@@ -281,7 +281,7 @@ private:
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
/** P2P */ /** P2P */
void directPass(){ void directPass(const bool p2pEnabled, const bool l2pEnabled){
FLOG( FLog::Controller.write("\tStart Direct Pass\n").write(FLog::Flush); ); FLOG( FLog::Controller.write("\tStart Direct Pass\n").write(FLog::Flush); );
FLOG(FTic counterTime); FLOG(FTic counterTime);
FLOG(FTic computationCounter); FLOG(FTic computationCounter);
...@@ -317,12 +317,16 @@ private: ...@@ -317,12 +317,16 @@ private:
const int nbLeaf = shapes[idxShape].getSize(); const int nbLeaf = shapes[idxShape].getSize();
for(int iterLeaf = 0 ; iterLeaf < nbLeaf ; ++iterLeaf ){ for(int iterLeaf = 0 ; iterLeaf < nbLeaf ; ++iterLeaf ){
typename OctreeClass::Iterator toWork = shapes[idxShape][iterLeaf]; typename OctreeClass::Iterator toWork = shapes[idxShape][iterLeaf];
#pragma omp task firstprivate(neighbors, toWork) #pragma omp task firstprivate(neighbors, toWork, l2pEnabled, p2pEnabled)
{ {
kernels[omp_get_thread_num()]->L2P(toWork.getCurrentCell(), toWork.getCurrentListTargets()); if(l2pEnabled){
const int counter = tree->getLeafsNeighbors(neighbors, toWork.getCurrentGlobalCoordinate(),heightMinusOne); kernels[omp_get_thread_num()]->L2P(toWork.getCurrentCell(), toWork.getCurrentListTargets());
kernels[omp_get_thread_num()]->P2P(toWork.getCurrentGlobalCoordinate(), toWork.getCurrentListTargets(), }
if(p2pEnabled){
const int counter = tree->getLeafsNeighbors(neighbors, toWork.getCurrentGlobalCoordinate(),heightMinusOne);
kernels[omp_get_thread_num()]->P2P(toWork.getCurrentGlobalCoordinate(), toWork.getCurrentListTargets(),
toWork.getCurrentListSrc(), neighbors, counter); toWork.getCurrentListSrc(), neighbors, counter);
}
} }
} }
......
...@@ -119,7 +119,7 @@ public: ...@@ -119,7 +119,7 @@ public:
if(operationsToProceed & FFmmL2L) downardPass(); if(operationsToProceed & FFmmL2L) downardPass();
if((operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P)) directPass(); if((operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P)) directPass((operationsToProceed & FFmmP2P),(operationsToProceed & FFmmL2P));
delete [] iterArray; delete [] iterArray;
iterArray = nullptr; iterArray = nullptr;
...@@ -320,7 +320,7 @@ private: ...@@ -320,7 +320,7 @@ private:
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
/** P2P */ /** P2P */
void directPass(){ void directPass(const bool p2pEnabled, const bool l2pEnabled){
FLOG( FLog::Controller.write("\tStart Direct Pass\n").write(FLog::Flush); ); FLOG( FLog::Controller.write("\tStart Direct Pass\n").write(FLog::Flush); );
FLOG(FTic counterTime); FLOG(FTic counterTime);
FLOG(FTic computationCounter); FLOG(FTic computationCounter);
...@@ -396,13 +396,17 @@ private: ...@@ -396,13 +396,17 @@ private:
#pragma omp for schedule(dynamic, chunkSize) #pragma omp for schedule(dynamic, chunkSize)
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); if(l2pEnabled){
// need the current particles and neighbors particles myThreadkernels.L2P(currentIter.cell, currentIter.targets);
FLOG(if(!omp_get_thread_num()) computationCounterP2P.tic()); }
const int counter = tree->getLeafsNeighbors(neighbors, currentIter.cell->getCoordinate(), LeafIndex); if(p2pEnabled){
myThreadkernels.P2P(currentIter.cell->getCoordinate(), currentIter.targets, // need the current particles and neighbors particles
currentIter.sources, neighbors, counter); FLOG(if(!omp_get_thread_num()) computationCounterP2P.tic());
FLOG(if(!omp_get_thread_num()) computationCounterP2P.tac()); const int counter = tree->getLeafsNeighbors(neighbors, currentIter.cell->getCoordinate(), LeafIndex);
myThreadkernels.P2P(currentIter.cell->getCoordinate(), currentIter.targets,
currentIter.sources, neighbors, counter);
FLOG(if(!omp_get_thread_num()) computationCounterP2P.tac());
}
} }
previous = endAtThisShape; previous = endAtThisShape;
......
...@@ -247,7 +247,7 @@ public: ...@@ -247,7 +247,7 @@ public:
if(operationsToProceed & FFmmL2L) downardPass(); if(operationsToProceed & FFmmL2L) downardPass();
if((operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P)) directPass(); if((operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P)) directPass((operationsToProceed & FFmmP2P),(operationsToProceed & FFmmL2P));
// delete array // delete array
...@@ -1082,7 +1082,7 @@ private: ...@@ -1082,7 +1082,7 @@ private:
/** P2P */ /** P2P */
void directPass(){ void directPass(const bool p2pEnabled, const bool l2pEnabled){
FLOG( FLog::Controller.write("\tStart Direct Pass\n").write(FLog::Flush); ); FLOG( FLog::Controller.write("\tStart Direct Pass\n").write(FLog::Flush); );
FLOG( FTic counterTime); FLOG( FTic counterTime);
FLOG( FTic prepareCounter); FLOG( FTic prepareCounter);
...@@ -1139,7 +1139,7 @@ private: ...@@ -1139,7 +1139,7 @@ private:
#pragma omp parallel #pragma omp parallel
{ {
#pragma omp master // MUST WAIT to fill leafsNeedOther #pragma omp master // MUST WAIT to fill leafsNeedOther
{ if(p2pEnabled){
// Copy leafs // Copy leafs
{ {
typename OctreeClass::Iterator octreeIterator(tree); typename OctreeClass::Iterator octreeIterator(tree);
...@@ -1203,7 +1203,7 @@ private: ...@@ -1203,7 +1203,7 @@ private:
#pragma omp barrier #pragma omp barrier
#pragma omp master // nowait #pragma omp master // nowait
{ if(p2pEnabled){
//Share to all processus globalReceiveMap //Share to all processus globalReceiveMap
FLOG(gatherCounter.tic()); FLOG(gatherCounter.tic());
FMpi::MpiAssert( MPI_Allgather( partsToSend, nbProcess, MPI_INT, globalReceiveMap, nbProcess, MPI_INT, comm.getComm()), __LINE__ ); FMpi::MpiAssert( MPI_Allgather( partsToSend, nbProcess, MPI_INT, globalReceiveMap, nbProcess, MPI_INT, comm.getComm()), __LINE__ );
...@@ -1338,12 +1338,15 @@ private: ...@@ -1338,12 +1338,15 @@ private:
for(int idxTaskLeaf = idxLeafs ; idxTaskLeaf < (idxLeafs + nbLeavesInTask) ; ++idxTaskLeaf){ for(int idxTaskLeaf = idxLeafs ; idxTaskLeaf < (idxLeafs + nbLeavesInTask) ; ++idxTaskLeaf){
LeafData& currentIter = leafsDataArray[idxTaskLeaf]; LeafData& currentIter = leafsDataArray[idxTaskLeaf];
myThreadkernels->L2P(currentIter.cell, currentIter.targets); if(l2pEnabled){
myThreadkernels->L2P(currentIter.cell, currentIter.targets);
// need the current particles and neighbors particles }
const int counter = tree->getLeafsNeighbors(neighbors, currentIter.coord, LeafIndex); if(p2pEnabled){
myThreadkernels->P2P( currentIter.coord,currentIter.targets, // need the current particles and neighbors particles
const int counter = tree->getLeafsNeighbors(neighbors, currentIter.coord, LeafIndex);
myThreadkernels->P2P( currentIter.coord,currentIter.targets,
currentIter.sources, neighbors, counter); currentIter.sources, neighbors, counter);
}
} }
} }
} }
...@@ -1365,7 +1368,7 @@ private: ...@@ -1365,7 +1368,7 @@ private:
#pragma omp master #pragma omp master
{ FLOG( computation2Counter.tic() ); } { FLOG( computation2Counter.tic() ); }
{ if(p2pEnabled){
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[27]; ContainerClass* neighbors[27];
......
...@@ -246,7 +246,7 @@ public: ...@@ -246,7 +246,7 @@ public:
if(operationsToProceed & FFmmL2L) downardPass(); if(operationsToProceed & FFmmL2L) downardPass();
if((operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P)) directPass(); if((operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P)) directPass((operationsToProceed & FFmmP2P),(operationsToProceed & FFmmL2P));
// delete array // delete array
...@@ -1204,7 +1204,7 @@ private: ...@@ -1204,7 +1204,7 @@ private:
/** P2P */ /** P2P */
void directPass(){ void directPass(const bool p2pEnabled, const bool l2pEnabled){
FLOG( FLog::Controller.write("\tStart Direct Pass\n").write(FLog::Flush); ); FLOG( FLog::Controller.write("\tStart Direct Pass\n").write(FLog::Flush); );
FLOG( FTic counterTime); FLOG( FTic counterTime);
FLOG( FTic prepareCounter); FLOG( FTic prepareCounter);
...@@ -1261,7 +1261,7 @@ private: ...@@ -1261,7 +1261,7 @@ private:
#pragma omp parallel #pragma omp parallel
{ {
#pragma omp master // MUST WAIT to fill leafsNeedOther #pragma omp master // MUST WAIT to fill leafsNeedOther
{ if(p2pEnabled){
// Copy leafs // Copy leafs
{ {
typename OctreeClass::Iterator octreeIterator(tree); typename OctreeClass::Iterator octreeIterator(tree);
...@@ -1327,7 +1327,7 @@ private: ...@@ -1327,7 +1327,7 @@ private:
#pragma omp barrier #pragma omp barrier
#pragma omp master // nowait #pragma omp master // nowait
{ if(p2pEnabled){
//Share to all processus globalReceiveMap //Share to all processus globalReceiveMap
FLOG(gatherCounter.tic()); FLOG(gatherCounter.tic());
FMpi::MpiAssert( MPI_Allgather( partsToSend, nbProcess, MPI_INT, globalReceiveMap, nbProcess, MPI_INT, comm.getComm()), __LINE__ ); FMpi::MpiAssert( MPI_Allgather( partsToSend, nbProcess, MPI_INT, globalReceiveMap, nbProcess, MPI_INT, comm.getComm()), __LINE__ );
...@@ -1465,55 +1465,59 @@ private: ...@@ -1465,55 +1465,59 @@ private:
bool hasPeriodicLeaves; bool hasPeriodicLeaves;
for(int idxTaskLeaf = idxLeafs ; idxTaskLeaf < (idxLeafs + nbLeavesInTask) ; ++idxTaskLeaf){ for(int idxTaskLeaf = idxLeafs ; idxTaskLeaf < (idxLeafs + nbLeavesInTask) ; ++idxTaskLeaf){
LeafData& currentIter = leafsDataArray[idxTaskLeaf]; LeafData& currentIter = leafsDataArray[idxTaskLeaf];
myThreadkernels->L2P(currentIter.cell, currentIter.targets); if(l2pEnabled){
// need the current particles and neighbors particles myThreadkernels->L2P(currentIter.cell, currentIter.targets);
const int counter = tree->getPeriodicLeafsNeighbors(neighbors, offsets, &hasPeriodicLeaves, }
currentIter.coord, LeafIndex, AllDirs); if(p2pEnabled){
int periodicNeighborsCounter = 0; // need the current particles and neighbors particles
const int counter = tree->getPeriodicLeafsNeighbors(neighbors, offsets, &hasPeriodicLeaves,
if(hasPeriodicLeaves){ currentIter.coord, LeafIndex, AllDirs);
ContainerClass* periodicNeighbors[27]; int periodicNeighborsCounter = 0;
memset(periodicNeighbors, 0, 27 * sizeof(ContainerClass*));
if(hasPeriodicLeaves){
for(int idxNeig = 0 ; idxNeig < 27 ; ++idxNeig){ ContainerClass* periodicNeighbors[27];
if( neighbors[idxNeig] && !offsets[idxNeig].equals(0,0,0) ){ memset(periodicNeighbors, 0, 27 * sizeof(ContainerClass*));
// Put periodic neighbors into other array
periodicNeighbors[idxNeig] = neighbors[idxNeig]; for(int idxNeig = 0 ; idxNeig < 27 ; ++idxNeig){
neighbors[idxNeig] = nullptr; if( neighbors[idxNeig] && !offsets[idxNeig].equals(0,0,0) ){
++periodicNeighborsCounter; // Put periodic neighbors into other array
periodicNeighbors[idxNeig] = neighbors[idxNeig];
FReal*const positionsX = periodicNeighbors[idxNeig]->getWPositions()[0]; neighbors[idxNeig] = nullptr;
FReal*const positionsY = periodicNeighbors[idxNeig]->getWPositions()[1]; ++periodicNeighborsCounter;
FReal*const positionsZ = periodicNeighbors[idxNeig]->getWPositions()[2];
FReal*const positionsX = periodicNeighbors[idxNeig]->getWPositions()[0];
for(int idxPart = 0; idxPart < periodicNeighbors[idxNeig]->getNbParticles() ; ++idxPart){ FReal*const positionsY = periodicNeighbors[idxNeig]->getWPositions()[1];
positionsX[idxPart] += boxWidth * FReal(offsets[idxNeig].getX()); FReal*const positionsZ = periodicNeighbors[idxNeig]->getWPositions()[2];
positionsY[idxPart] += boxWidth * FReal(offsets[idxNeig].getY());
positionsZ[idxPart] += boxWidth * FReal(offsets[idxNeig].getZ()); for(int idxPart = 0; idxPart < periodicNeighbors[idxNeig]->getNbParticles() ; ++idxPart){
positionsX[idxPart] += boxWidth * FReal(offsets[idxNeig].getX());
positionsY[idxPart] += boxWidth * FReal(offsets[idxNeig].getY());
positionsZ[idxPart] += boxWidth * FReal(offsets[idxNeig].getZ());
}
} }
} }
}
myThreadkernels->P2PRemote(currentIter.coord,currentIter.targets, myThreadkernels->P2PRemote(currentIter.coord,currentIter.targets,
currentIter.sources, periodicNeighbors, periodicNeighborsCounter); currentIter.sources, periodicNeighbors, periodicNeighborsCounter);
for(int idxNeig = 0 ; idxNeig < 27 ; ++idxNeig){ for(int idxNeig = 0 ; idxNeig < 27 ; ++idxNeig){
if( periodicNeighbors[idxNeig] ){ if( periodicNeighbors[idxNeig] ){
FReal*const positionsX = periodicNeighbors[idxNeig]->getWPositions()[0]; FReal*const positionsX = periodicNeighbors[idxNeig]->getWPositions()[0];
FReal*const positionsY = periodicNeighbors[idxNeig]->getWPositions()[1]; FReal*const positionsY = periodicNeighbors[idxNeig]->getWPositions()[1];
FReal*const positionsZ = periodicNeighbors[idxNeig]->getWPositions()[2]; FReal*const positionsZ = periodicNeighbors[idxNeig]->getWPositions()[2];
for(int idxPart = 0; idxPart < periodicNeighbors[idxNeig]->getNbParticles() ; ++idxPart){ for(int idxPart = 0; idxPart < periodicNeighbors[idxNeig]->getNbParticles() ; ++idxPart){
positionsX[idxPart] -= boxWidth * FReal(offsets[idxNeig].getX()); positionsX[idxPart] -= boxWidth * FReal(offsets[idxNeig].getX());
positionsY[idxPart] -= boxWidth * FReal(offsets[idxNeig].getY()); positionsY[idxPart] -= boxWidth * FReal(offsets[idxNeig].getY());
positionsZ[idxPart] -= boxWidth * FReal(offsets[idxNeig].getZ()); positionsZ[idxPart] -= boxWidth * FReal(offsets[idxNeig].getZ());
}
} }
} }
} }
}
myThreadkernels->P2P( currentIter.coord, currentIter.targets, myThreadkernels->P2P( currentIter.coord, currentIter.targets,
currentIter.sources, neighbors, counter - periodicNeighborsCounter); currentIter.sources, neighbors, counter - periodicNeighborsCounter);
}
} }
} }
...@@ -1537,7 +1541,7 @@ private: ...@@ -1537,7 +1541,7 @@ private:
#pragma omp master #pragma omp master
{ FLOG( computation2Counter.tic() ); } { FLOG( computation2Counter.tic() ); }
{ if(p2pEnabled){
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[27]; ContainerClass* neighbors[27];