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:
*/
virtual void P2P(const MortonIndex inCurrentLeafIndex,
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:
/** Do nothing */
virtual void P2P(const MortonIndex ,
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:
/** After Downward */
void P2P(const MortonIndex ,
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
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:
FTreeCoordinate center;
center.setPositionFromMorton(inIndex, inLevel);
const int limite = FMath::pow(2,inLevel);
const int limite = FMath::pow2(inLevel);
int idxNeighbors = 0;
......@@ -773,7 +773,7 @@ public:
const FTreeCoordinate parentCell(workingCell.getX()>>1,workingCell.getY()>>1,workingCell.getZ()>>1);
// 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;
// We test all cells around
......@@ -838,7 +838,7 @@ public:
const FTreeCoordinate parentCell(workingCell.getX()>>1,workingCell.getY()>>1,workingCell.getZ()>>1);
// 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
if( !(parentCell.getX() == 0 || parentCell.getY() == 0 || parentCell.getZ() == 0 ||
......@@ -933,22 +933,9 @@ public:
* @param inLevel the level of the element
* @return the number of neighbors
*/
int getLeafsNeighbors(ContainerClass* 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(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 getLeafsNeighbors(ContainerClass* inNeighbors[26], const FTreeCoordinate& center, const int inLevel){
memset( inNeighbors, 0 , 26 * sizeof(ContainerClass*));
const int limite = FMath::pow2(inLevel);
int idxNeighbors = 0;
......@@ -970,8 +957,8 @@ public:
ContainerClass* const leaf = getLeafSrc(mortonOther);
// add to list if not null
if(leaf){
inNeighborsIndex[idxNeighbors] = mortonOther;
inNeighbors[idxNeighbors++] = leaf;
inNeighbors[(((idxX + 1) * 3) + (idxY +1)) * 3 + idxZ + 1] = leaf;
++idxNeighbors;
}
}
}
......@@ -987,11 +974,9 @@ public:
* @param inLevel the level of the element
* @return the number of neighbors
*/
int getLeafsNeighborsWithIndex(ContainerClass* inNeighbors[26], FTreeCoordinate inNeighborsPosition[26], const MortonIndex inIndex, const int inLevel){
FTreeCoordinate center;
center.setPositionFromMorton(inIndex, inLevel);
const int limite = FMath::pow(2,inLevel);
int getPeriodicLeafsNeighbors(ContainerClass* inNeighbors[26], const FTreeCoordinate& center, const int inLevel){
memset(inNeighbors , 0 , 26 * sizeof(ContainerClass*));
const int limite = FMath::pow2(inLevel);
int idxNeighbors = 0;
......@@ -1039,8 +1024,8 @@ public:
ContainerClass* const leaf = getLeafSrc(mortonOther);
// add to list if not null
if(leaf){
inNeighborsPosition[idxNeighbors] = offset;
inNeighbors[idxNeighbors++] = leaf;
inNeighbors[(((idxX + 1) * 3) + (idxY +1)) * 3 + idxZ + 1] = leaf;
++idxNeighbors;
}
}
}
......
......@@ -234,16 +234,15 @@ private:
octreeIterator.gotoBottomLeft();
// There is a maximum of 26 neighbors
ContainerClass* neighbors[26];
MortonIndex neighborsIndex[26];
// for each leafs
do{
FDEBUG(computationCounterL2P.tic());
kernels->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets());
FDEBUG(computationCounterL2P.tac());
// 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());
kernels->P2P(octreeIterator.getCurrentGlobalIndex(),octreeIterator.getCurrentListTargets(), octreeIterator.getCurrentListSrc() , neighbors, neighborsIndex, counter);
kernels->P2P(octreeIterator.getCurrentGlobalIndex(),octreeIterator.getCurrentListTargets(), octreeIterator.getCurrentListSrc() , neighbors, counter);
FDEBUG(computationCounterP2P.tac());
} while(octreeIterator.moveRight());
......
......@@ -232,16 +232,15 @@ private:
octreeIterator.gotoBottomLeft();
// There is a maximum of 26 neighbors
ContainerClass* neighbors[26];
FTreeCoordinate neighborsPosition[26];
// for each leafs
do{
FDEBUG(computationCounterL2P.tic());
kernels->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets());
FDEBUG(computationCounterL2P.tac());
// 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());
kernels->P2P(octreeIterator.getCurrentGlobalIndex(),octreeIterator.getCurrentListTargets(), octreeIterator.getCurrentListSrc() , neighbors, neighborsPosition, counter);
kernels->P2P(octreeIterator.getCurrentGlobalIndex(),octreeIterator.getCurrentListTargets(), octreeIterator.getCurrentListSrc() , neighbors, counter);
FDEBUG(computationCounterP2P.tac());
} while(octreeIterator.moveRight());
......
......@@ -282,7 +282,6 @@ private:
KernelClass*const myThreadkernels = kernels[omp_get_thread_num()];
// There is a maximum of 26 neighbors
ContainerClass* neighbors[26];
MortonIndex neighborsIndex[26];
#pragma omp single nowait
{
......@@ -306,8 +305,8 @@ private:
#pragma omp task
{
// need the current particles and neighbors particles
const int counter = tree->getLeafsNeighborsWithIndex(neighbors, neighborsIndex, octreeIterator.getCurrentGlobalIndex(),heightMinusOne);
myThreadkernels->P2P(octreeIterator.getCurrentGlobalIndex(),octreeIterator.getCurrentListTargets(), octreeIterator.getCurrentListSrc() , neighbors, neighborsIndex, counter);
const int counter = tree->getLeafsNeighbors(neighbors, octreeIterator.getCurrentGlobalCoordinate(),heightMinusOne);
myThreadkernels->P2P(octreeIterator.getCurrentGlobalIndex(),octreeIterator.getCurrentListTargets(), octreeIterator.getCurrentListSrc() , neighbors, counter);
}
}
else{
......@@ -324,8 +323,8 @@ private:
typename OctreeClass::Iterator toWork = shapes[idxShape][iterLeaf];
#pragma omp task
{
const int counter = tree->getLeafsNeighborsWithIndex(neighbors, neighborsIndex, toWork.getCurrentGlobalIndex(),heightMinusOne);
myThreadkernels->P2P(toWork.getCurrentGlobalIndex(),toWork.getCurrentListTargets(), toWork.getCurrentListSrc() , neighbors, neighborsIndex, counter);
const int counter = tree->getLeafsNeighbors(neighbors, toWork.getCurrentGlobalCoordinate(),heightMinusOne);
myThreadkernels->P2P(toWork.getCurrentGlobalIndex(),toWork.getCurrentListTargets(), toWork.getCurrentListSrc() , neighbors, counter);
}
}
......
......@@ -331,7 +331,7 @@ private:
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());
......@@ -365,27 +365,26 @@ private:
octreeIterator.moveRight();
}
#pragma omp barrier
#pragma omp barrier
FDEBUG(if(!omp_get_thread_num()) computationCounter.tic());
KernelClass& myThreadkernels = (*kernels[omp_get_thread_num()]);
// There is a maximum of 26 neighbors
ContainerClass* neighbors[26];
MortonIndex neighborsIndex[26];
int previous = 0;
for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
const int endAtThisShape = this->shapeLeaf[idxShape] + previous;
#pragma omp for schedule(dynamic)
#pragma omp for schedule(dynamic)
for(int idxLeafs = previous ; idxLeafs < endAtThisShape ; ++idxLeafs){
LeafData& currentIter = leafsDataArray[idxLeafs];
myThreadkernels.L2P(currentIter.cell, currentIter.targets);
// need the current particles and neighbors particles
FDEBUG(if(!omp_get_thread_num()) computationCounterP2P.tic());
const int counter = tree->getLeafsNeighborsWithIndex(neighbors, neighborsIndex, currentIter.index, LeafIndex);
myThreadkernels.P2P(currentIter.index, currentIter.targets, currentIter.sources , neighbors, neighborsIndex, counter);
const int counter = tree->getLeafsNeighbors(neighbors, currentIter.cell->getCoordinate(), LeafIndex);
myThreadkernels.P2P(currentIter.index, currentIter.targets, currentIter.sources , neighbors, counter);
FDEBUG(if(!omp_get_thread_num()) computationCounterP2P.tac());
}
......
......@@ -728,12 +728,15 @@ private:
int counter = 0;
// does we receive this index from someone?
for(int idxNeig = 0 ;idxNeig < counterNeighbors ; ++idxNeig){
const void* const cellFromOtherProc = tempTree.getCell(neighborsIndex[idxNeig], idxLevel);
if(cellFromOtherProc){
neighborsData[counter].deserializeUp(cellFromOtherProc);
neighborsData[counter].setMortonIndex(neighborsIndex[idxNeig]);
neighbors[ neighborsPosition[counter] ] = &neighborsData[counter];
++counter;
if(neighborsIndex[idxNeig] < getWorkingInterval(idxLevel , idProcess).min
|| getWorkingInterval(idxLevel , idProcess).max < neighborsIndex[idxNeig]){
const void* const cellFromOtherProc = tempTree.getCell(neighborsIndex[idxNeig], idxLevel);
if(cellFromOtherProc){
neighborsData[counter].deserializeUp(cellFromOtherProc);
neighborsData[counter].setMortonIndex(neighborsIndex[idxNeig]);
neighbors[ neighborsPosition[counter] ] = &neighborsData[counter];
++counter;
}
}
}
// need to compute
......@@ -1111,26 +1114,25 @@ private:
FDEBUG(FTic computationCounter);
#pragma omp parallel
#pragma omp parallel
{
KernelClass& myThreadkernels = (*kernels[omp_get_thread_num()]);
// There is a maximum of 26 neighbors
ContainerClass* neighbors[26];
MortonIndex neighborsIndex[26];
int previous = 0;
for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
const int endAtThisShape = shapeLeaf[idxShape] + previous;
#pragma omp for schedule(dynamic)
#pragma omp for schedule(dynamic)
for(int idxLeafs = previous ; idxLeafs < endAtThisShape ; ++idxLeafs){
if(!leafsNeedOtherShaped.get(idxLeafs)){
LeafData& currentIter = leafsDataArray[idxLeafs];
myThreadkernels.L2P(currentIter.cell, currentIter.targets);
// need the current particles and neighbors particles
const int counter = tree->getLeafsNeighborsWithIndex(neighbors, neighborsIndex, currentIter.index, LeafIndex);
myThreadkernels.P2P( currentIter.index,currentIter.targets, currentIter.sources , neighbors, neighborsIndex, counter);
const int counter = tree->getLeafsNeighbors(neighbors, currentIter.cell->getCoordinate(), LeafIndex);
myThreadkernels.P2P( currentIter.index,currentIter.targets, currentIter.sources , neighbors, counter);
}
}
......@@ -1184,7 +1186,6 @@ private:
KernelClass& myThreadkernels = (*kernels[omp_get_thread_num()]);
// There is a maximum of 26 neighbors
ContainerClass* neighbors[26];
MortonIndex neighborsIndex[26];
int previous = 0;
// Box limite
const int limite = 1 << (this->OctreeHeight - 1);
......@@ -1192,7 +1193,7 @@ private:
for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
const int endAtThisShape = shapeLeaf[idxShape] + previous;
#pragma omp for schedule(dynamic)
#pragma omp for schedule(dynamic)
for(int idxLeafs = previous ; idxLeafs < endAtThisShape ; ++idxLeafs){
// Maybe need also data from other?
if(leafsNeedOtherShaped.get(idxLeafs)){
......@@ -1200,7 +1201,7 @@ private:
myThreadkernels.L2P(currentIter.cell, currentIter.targets);
// 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
MortonIndex indexesNeighbors[26];
......@@ -1211,13 +1212,12 @@ private:
ContainerClass*const hypotheticNeighbor = otherP2Ptree.getLeafSrc(indexesNeighbors[idxNeigh]);
if(hypotheticNeighbor){
neighbors[counter] = hypotheticNeighbor;
neighborsIndex[counter] = indexesNeighbors[idxNeigh];
++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:
const FTreeCoordinate parentCell(workingCell.getX()>>1,workingCell.getY()>>1,workingCell.getZ()>>1);
// 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;
// We test all cells around
......
......@@ -801,12 +801,15 @@ private:
int counter = 0;
// does we receive this index from someone?
for(int idxNeig = 0 ;idxNeig < counterNeighbors ; ++idxNeig){
const void* const cellFromOtherProc = tempTree.getCell(neighborsIndex[idxNeig], idxLevel);
if(cellFromOtherProc){
neighborsData[counter].deserializeUp(cellFromOtherProc);
neighborsData[counter].setMortonIndex(neighborsIndex[idxNeig]);
neighbors[ neighborsPosition[counter] ] = &neighborsData[counter];
++counter;
if(neighborsIndex[idxNeig] < getWorkingInterval(idxLevel , idProcess).min
|| getWorkingInterval(idxLevel , idProcess).max < neighborsIndex[idxNeig]){
const void* const cellFromOtherProc = tempTree.getCell(neighborsIndex[idxNeig], idxLevel);
if(cellFromOtherProc){
neighborsData[counter].deserializeUp(cellFromOtherProc);
neighborsData[counter].setMortonIndex(neighborsIndex[idxNeig]);
neighbors[ neighborsPosition[counter] ] = &neighborsData[counter];
++counter;
}
}
}
......@@ -1036,9 +1039,9 @@ private:
memset(alreadySent, 0, sizeof(int) * nbProcess);
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]){
needOther = true;
......@@ -1188,26 +1191,25 @@ private:
FDEBUG(FTic computationCounter);
#pragma omp parallel
#pragma omp parallel
{
KernelClass& myThreadkernels = (*kernels[omp_get_thread_num()]);
// There is a maximum of 26 neighbors
ContainerClass* neighbors[26];
FTreeCoordinate neighborsPosition[26];
int previous = 0;
for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
const int endAtThisShape = shapeLeaf[idxShape] + previous;
#pragma omp for schedule(dynamic)
#pragma omp for schedule(dynamic)
for(int idxLeafs = previous ; idxLeafs < endAtThisShape ; ++idxLeafs){
if(!leafsNeedOtherShaped.get(idxLeafs)){
LeafData& currentIter = leafsDataArray[idxLeafs];
myThreadkernels.L2P(currentIter.cell, currentIter.targets);
// need the current particles and neighbors particles
const int counter = tree->getLeafsNeighborsWithIndex(neighbors, neighborsPosition, currentIter.index, LeafIndex);
myThreadkernels.P2P( currentIter.index,currentIter.targets, currentIter.sources , neighbors, neighborsPosition, counter);
const int counter = tree->getPeriodicLeafsNeighbors(neighbors, currentIter.cell->getCoordinate(), LeafIndex);
myThreadkernels.P2P( currentIter.index,currentIter.targets, currentIter.sources , neighbors, counter);
}
}
......@@ -1256,12 +1258,13 @@ private:
FTRACE( FTrace::FRegion regionOtherTrace("Compute P2P Other", __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( computation2Counter.tic() );
#pragma omp parallel
#pragma omp parallel
{
KernelClass& myThreadkernels = (*kernels[omp_get_thread_num()]);
// There is a maximum of 26 neighbors
ContainerClass* neighbors[26];
//MortonIndex neighborsIndex[26];
MortonIndex indexesNeighbors[26];
int previous = 0;
// Box limite
const int limite = 1 << (this->OctreeHeight - 1);
......@@ -1269,7 +1272,7 @@ private:
for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
const int endAtThisShape = shapeLeaf[idxShape] + previous;
#pragma omp for schedule(dynamic)
#pragma omp for schedule(dynamic)
for(int idxLeafs = previous ; idxLeafs < endAtThisShape ; ++idxLeafs){
// Maybe need also data from other?
if(leafsNeedOtherShaped.get(idxLeafs)){
......@@ -1277,33 +1280,30 @@ private:
myThreadkernels.L2P(currentIter.cell, currentIter.targets);
// need the current particles and neighbors particles
// int counter = tree->getLeafsNeighborsWithIndex(neighbors, neighborsIndex, currentIter.index, LeafIndex);
// int counter = tree->getLeafsNeighbors(neighbors, neighborsIndex, currentIter.index, LeafIndex);
int counter = 0;
memset(neighbors, 0, 26 * sizeof(ContainerClass*));
// Take possible data
MortonIndex indexesNeighbors[26];
FTreeCoordinate neighborsPosition[26];
const int neighCount = getNeighborsIndexes(currentIter.index, limite, indexesNeighbors, neighborsPosition);
getNeighborsIndexes(currentIter.cell->getCoordinate(), 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]){
ContainerClass*const hypotheticNeighbor = otherP2Ptree.getLeafSrc(indexesNeighbors[idxNeigh]);
if(hypotheticNeighbor){
neighbors[counter] = hypotheticNeighbor;
neighborsPosition[counter] = neighborsPosition[idxNeigh];
neighbors[idxNeigh] = hypotheticNeighbor;
++counter;
}
}
else{
ContainerClass*const hypotheticNeighbor = tree->getLeafSrc(indexesNeighbors[idxNeigh]);
if(hypotheticNeighbor){
neighbors[counter] = hypotheticNeighbor;
neighborsPosition[counter] = neighborsPosition[idxNeigh];
neighbors[idxNeigh] = hypotheticNeighbor;
++counter;
}
}
}
myThreadkernels.P2P( currentIter.index,currentIter.targets, currentIter.sources , neighbors, neighborsPosition, counter);
myThreadkernels.P2P( currentIter.index,currentIter.targets, currentIter.sources , neighbors, counter);
}
}
......@@ -1331,15 +1331,8 @@ private:
}
int getNeighborsIndexes(const MortonIndex centerIndex, const int limite, MortonIndex indexes[26]) const{
FTreeCoordinate relativePositions[26];
return getNeighborsIndexes(centerIndex, limite, indexes, relativePositions);
}
int getNeighborsIndexes(const MortonIndex centerIndex, const int limite, MortonIndex indexes[26], FTreeCoordinate inRelativePositions[26]) const{
FTreeCoordinate center;
center.setPositionFromMorton(centerIndex, OctreeHeight - 1);
void getNeighborsIndexes(const FTreeCoordinate& center, const int limite, MortonIndex indexes[26]) const{
int idxNeig = 0;
// We test all cells around
for(int idxX = -1 ; idxX <= 1 ; ++idxX){
......@@ -1358,16 +1351,12 @@ private:
if( other.getZ() < 0 ) other.setZ( other.getZ() + limite );
else if( limite <= other.getZ() ) other.setZ( other.getZ() - limite );
inRelativePositions[idxNeig].setPosition( idxX,
idxY,
idxZ);
indexes[idxNeig++] = other.getMortonIndex(this->OctreeHeight - 1);
indexes[idxNeig] = other.getMortonIndex(this->OctreeHeight - 1);
}
++idxNeig;
}
}
}
return idxNeig;
}
......@@ -1378,7 +1367,7 @@ private:
const FTreeCoordinate parentCell(workingCell.getX()>>1,workingCell.getY()>>1,workingCell.getZ()>>1);
// 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;
// We test all cells around
......
......@@ -349,7 +349,7 @@ public:
for(int idxLeafs = 0 ; idxLeafs < numberOfLeafs ; ++idxLeafs){
myThreadkernels->L2P(iterArray[idxLeafs].getCurrentCell(), iterArray[idxLeafs].getCurrentListTargets());
// need the current particles and neighbors particles
const int counter = tree->getLeafsNeighbors(neighbors, iterArray[idxLeafs].getCurrentGlobalIndex(),heightMinusOne);
const int counter = tree->getLeafsNeighbors(neighbors, iterArray[idxLeafs].getCurrentGlobalCoordinate(),heightMinusOne);
myThreadkernels->P2P( iterArray[idxLeafs].getCurrentListTargets(), iterArray[idxLeafs].getCurrentListSrc() , neighbors, counter);
}
}
......
......@@ -280,7 +280,7 @@ public:
FDEBUG(computationCounter.tic());
kernels->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets());
// need the current particles and neighbors particles
const int counter = tree->getLeafsNeighbors(neighbors, octreeIterator.getCurrentGlobalIndex(),heightMinusOne);
const int counter = tree->getLeafsNeighbors(neighbors, octreeIterator.getCurrentGlobalCoordinate(), heightMinusOne);
kernels->P2P( octreeIterator.getCurrentListTargets(), octreeIterator.getCurrentListSrc() , neighbors, counter);
FDEBUG(computationCounter.tac());
FDEBUG(totalComputation += computationCounter.elapsed());
......
......@@ -249,7 +249,7 @@ public:
*/
void P2P(const MortonIndex inCurrentIndex,
ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict /*sources*/,
ContainerClass* const directNeighbors[26], const MortonIndex inNeighborsIndex[26], const int size){
ContainerClass* const directNeighbors[26], const int size){
{ // Compute interaction in this leaf
typename ContainerClass::BasicIterator iterTarget(*targets);
while( iterTarget.hasNotFinished() ){
......@@ -271,7 +271,7 @@ public:
{ // Compute interactions with other leaves
// For all the neigbors leaves
for(int idxDirectNeighbors = 0 ; idxDirectNeighbors < size ; ++idxDirectNeighbors){
if(inCurrentIndex < inNeighborsIndex[idxDirectNeighbors] ){
if(inCurrentIndex < 0 /*inNeighborsIndex[idxDirectNeighbors] TODO */ ){
// For all particles in current leaf
typename ContainerClass::BasicIterator iterTarget(*targets);
while( iterTarget.hasNotFinished() ){
......@@ -297,8 +297,8 @@ public:
/** After Downward */
void P2P(const MortonIndex inCurrentIndex,
ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict /*sources*/,
/*void P2P(const MortonIndex inCurrentIndex,
ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict ,//sources
ContainerClass* const directNeighbors[26], const FTreeCoordinate neighborsRelativeOffset[26], const int size) {
{ // Compute interaction in this leaf
......@@ -358,7 +358,7 @@ public:
}
}
}
}
}*/
///////////////////////////////////////////////////////////////////////////////
// Computation
......
......@@ -80,6 +80,11 @@ struct FMath{
return result;
}
/** To get pow of 2 */
static int pow2(const int power){
return (1 << power);
}
/** To know if a value is between two others */
template <class NumType>
static bool Between(const NumType inValue, const NumType inMin, const NumType inMax){
......
......@@ -27,7 +27,7 @@
#include "../Src/Components/FTestParticle.hpp"
#include "../Src/Components/FTestCell.hpp"
#include "../Src/Components/FTestPeriodicKernels.hpp"
#include "../Src/Components/FTestKernels.hpp"
#include "../Src/Core/FFmmAlgorithmPeriodic.hpp"
......@@ -45,7 +45,7 @@ int main(int argc, char ** argv){
typedef FSimpleLeaf<ParticleClass, ContainerClass > LeafClass;
typedef FOctree<ParticleClass, CellClass, ContainerClass , LeafClass > OctreeClass;
typedef FTestPeriodicKernels<ParticleClass, CellClass, ContainerClass > KernelClass;
typedef FTestKernels<ParticleClass, CellClass, ContainerClass > KernelClass;
typedef FFmmAlgorithmPeriodic<OctreeClass, ParticleClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass;
///////////////////////What we do/////////////////////////////
......
......@@ -27,7 +27,7 @@
#include "../Src/Components/FTestParticle.hpp"
#include "../Src/Components/FTestCell.hpp"
#include "../Src/Components/FTestPeriodicKernels.hpp"