Commit e9168d2a authored by berenger-bramas's avatar berenger-bramas
Browse files

Enable target/source (ToS) for P2P

(need modification for other kernels)

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@36 2616d619-271b-44dc-8df4-d4a8f33a7222
parent 75fc7f4b
......@@ -76,11 +76,13 @@ public:
/**
* P2P
* Particules to particules
* @param particules current boxe particules
* @param targets current boxe targets particules
* @param sources current boxe sources particules
* @param directNeighborsParticules the particules from direct neighbors (this is an array of list)
* @param size the number of direct neighbors (the size of the array directNeighborsParticules)
*/
virtual void P2P(FList<ParticuleClass*>* const FRestrict particules, const FList<ParticuleClass*>*const FRestrict *const FRestrict directNeighborsParticules, const int size) = 0;
virtual void P2P(FList<ParticuleClass*>* const FRestrict targets, const FList<ParticuleClass*>* const FRestrict sources,
const FList<ParticuleClass*>*const FRestrict *const FRestrict directNeighborsParticules, const int size) = 0;
};
......
......@@ -56,7 +56,8 @@ public:
}
/** Print the number of particules */
virtual void P2P(FList<ParticuleClass*>* const FRestrict , const FList<ParticuleClass*>* FRestrict const* FRestrict , const int ) {
virtual void P2P(FList<ParticuleClass*>* const FRestrict , const FList<ParticuleClass*>* const FRestrict ,
const FList<ParticuleClass*>* FRestrict const* FRestrict , const int ) {
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
......
......@@ -218,7 +218,7 @@ public:
kernels->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets());
// need the current particules and neighbors particules
const int counter = tree->getLeafsNeighbors(neighbors, octreeIterator.getCurrentGlobalIndex(),heightMinusOne);
kernels->P2P( octreeIterator.getCurrentListTargets() , neighbors, counter);
kernels->P2P( octreeIterator.getCurrentListTargets(), octreeIterator.getCurrentListSources() , neighbors, counter);
FDEBUG(computationCounter.tac());
FDEBUG(totalComputation += computationCounter.elapsed());
} while(octreeIterator.moveRight());
......
......@@ -299,7 +299,7 @@ public:
myThreadkernels->L2P(iterArray[idxLeafs].getCurrentCell(), iterArray[idxLeafs].getCurrentListTargets());
// need the current particules and neighbors particules
const int counter = tree->getLeafsNeighbors(neighbors, iterArray[idxLeafs].getCurrentGlobalIndex(),heightMinusOne);
myThreadkernels->P2P( iterArray[idxLeafs].getCurrentListTargets() , neighbors, counter);
myThreadkernels->P2P( iterArray[idxLeafs].getCurrentListTargets(), iterArray[idxLeafs].getCurrentListSources() , neighbors, counter);
}
}
FDEBUG(computationCounter.tac());
......
......@@ -260,7 +260,7 @@ public:
kernels[omp_get_thread_num()]->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets());
// need the current particules and neighbors particules
const int counter = tree->getLeafsNeighbors(neighbors, octreeIterator.getCurrentGlobalIndex(),heightMinusOne);
kernels[omp_get_thread_num()]->P2P( octreeIterator.getCurrentListTargets() , neighbors, counter);
kernels[omp_get_thread_num()]->P2P( octreeIterator.getCurrentListTargets() , octreeIterator.getCurrentListSources(), neighbors, counter);
}
} while(octreeIterator.moveRight());
}
......
......@@ -273,15 +273,16 @@ public:
// for each leafs
while(!stop){
const CellClass * const cell = octreeIterator.getCurrentCell();
FList<ParticuleClass*>* const particules = octreeIterator.getCurrentListTargets();
FList<ParticuleClass*>* const targets = octreeIterator.getCurrentListTargets();
const FList<ParticuleClass*>* const sources = octreeIterator.getCurrentListSources();
const MortonIndex cellIndex = octreeIterator.getCurrentGlobalIndex();
if(!octreeIterator.moveRight()) stop = true;
omp_unset_lock(&mutex);
kernels[threadId]->L2P(cell, particules);
// need the current particules and neighbors particules
kernels[threadId]->L2P(cell, targets);
// need the current targets and neighbors particules
const int counter = tree->getLeafsNeighbors(neighbors, cellIndex,heightMinusOne);
kernels[threadId]->P2P( particules , neighbors, counter);
kernels[threadId]->P2P( targets , sources, neighbors, counter);
omp_set_lock(&mutex);
}
......
......@@ -77,15 +77,19 @@ public:
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
// After Downward
void P2P(FList<ParticuleClass*>*const FRestrict currentBox, const FList<ParticuleClass*>* FRestrict const* FRestrict directNeighbors, const int size) {
void P2P(FList<ParticuleClass*>* const FRestrict targets, const FList<ParticuleClass*>* const FRestrict sources,
const FList<ParticuleClass*>* FRestrict const* FRestrict directNeighbors, const int size) {
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
// Each particules targeted is impacted by the particules sources
long inc = currentBox->getSize() - 1;
long inc = sources->getSize();
if(targets == sources){
inc -= 1;
}
for(int idx = 0 ; idx < size ; ++idx){
inc += directNeighbors[idx]->getSize();
}
typename FList<ParticuleClass*>::BasicIterator iter(*currentBox);
typename FList<ParticuleClass*>::BasicIterator iter(*targets);
while( iter.isValide() ){
iter.value()->setDataDown(iter.value()->getDataDown() + inc);
iter.progress();
......
......@@ -1054,7 +1054,8 @@ public:
virtual void L2P(const CellClass* const local, FList<ParticuleClass*>* const particules) = 0;
virtual void P2P(FList<ParticuleClass*>* const FRestrict currentBox, const FList<ParticuleClass*>* FRestrict const* FRestrict directNeighbors, const int size) = 0;
virtual void P2P(FList<ParticuleClass*>* const FRestrict targets, const FList<ParticuleClass*>* const FRestrict sources,
const FList<ParticuleClass*>* FRestrict const* FRestrict directNeighbors, const int size) = 0;
};
......
......@@ -16,7 +16,7 @@
*/
template< class ParticuleClass, class CellClass, int TreeHeight>
class FFmbKernelsForces : public FAbstractFmbKernels<ParticuleClass,CellClass, TreeHeight> {
public:
public:
FFmbKernelsForces(const FReal inTreeWidth)
: FAbstractFmbKernels<ParticuleClass,CellClass,TreeHeight>(inTreeWidth) {
}
......@@ -116,9 +116,9 @@ class FFmbKernelsForces : public FAbstractFmbKernels<ParticuleClass,CellClass, T
if (th > FMath::FPi){
th = 2*FMath::FPi - th;
//spherical_position_Set_ph(p, spherical_position_Get_ph(p) + M_PI);
ph = FMath::Fmod(ph + FMath::FPi, 2*FMath::FPi);
if (ph > M_PI) ph -= 2*FMath::FPi;
if (ph < -M_PI + FMath::Epsilon) ph += 2 * FMath::Epsilon;
ph = FMath::Fmod(ph + FMath::FPi, 2*FMath::FPi);
if (ph > M_PI) ph -= 2*FMath::FPi;
if (ph < -M_PI + FMath::Epsilon) ph += 2 * FMath::Epsilon;
th = FMath::Fmod(th, 2*FMath::FPi);
if (th > M_PI) th -= 2*FMath::FPi;
if (th < -M_PI + FMath::Epsilon) th += 2 * FMath::Epsilon;
......@@ -137,9 +137,9 @@ class FFmbKernelsForces : public FAbstractFmbKernels<ParticuleClass,CellClass, T
if (th > FMath::FPi){
th = 2*FMath::FPi - th;
//spherical_position_Set_ph(p, spherical_position_Get_ph(p) + M_PI);
ph = FMath::Fmod(ph + FMath::FPi, 2*FMath::FPi);
if (ph > M_PI) ph -= 2*FMath::FPi;
if (ph < -M_PI + FMath::Epsilon) ph += 2 * FMath::Epsilon;
ph = FMath::Fmod(ph + FMath::FPi, 2*FMath::FPi);
if (ph > M_PI) ph -= 2*FMath::FPi;
if (ph < -M_PI + FMath::Epsilon) ph += 2 * FMath::Epsilon;
th = FMath::Fmod(th, 2*FMath::FPi);
if (th > M_PI) th -= 2*FMath::FPi;
if (th < -M_PI + FMath::Epsilon) th += 2 * FMath::Epsilon;
......@@ -228,24 +228,23 @@ class FFmbKernelsForces : public FAbstractFmbKernels<ParticuleClass,CellClass, T
* )
*
*/
void P2P(FList<ParticuleClass*>* const FRestrict currentBox, const FList<ParticuleClass*>* FRestrict const* FRestrict directNeighbors, const int size) {
void P2P(FList<ParticuleClass*>* const FRestrict targets, const FList<ParticuleClass*>* const FRestrict sources,
const FList<ParticuleClass*>* FRestrict const* FRestrict directNeighbors, const int size) {
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
typename FList<ParticuleClass*>::BasicIterator iterTarget(*currentBox);
typename FList<ParticuleClass*>::BasicIterator iterTarget(*targets);
while( iterTarget.isValide() ){
for(int idxDirectNeighbors = 0 ; idxDirectNeighbors < size ; ++idxDirectNeighbors){
typename FList<ParticuleClass*>::ConstBasicIterator iterSource(*directNeighbors[idxDirectNeighbors]);
while( iterSource.isValide() ){
DIRECT_COMPUTATION_NO_MUTUAL_SOFT(&iterTarget.value(),
iterSource.value());
iterSource.progress();
DIRECT_COMPUTATION_NO_MUTUAL_SOFT(&iterTarget.value(), iterSource.value());
iterSource.progress();
}
}
}
typename FList<ParticuleClass*>::BasicIterator iterSameBox(*currentBox);
typename FList<ParticuleClass*>::ConstBasicIterator iterSameBox(*sources);
while( iterSameBox.isValide() ){
if(iterSameBox.value() != iterTarget.value()){
DIRECT_COMPUTATION_NO_MUTUAL_SOFT(&iterTarget.value(),
iterSameBox.value());
DIRECT_COMPUTATION_NO_MUTUAL_SOFT(&iterTarget.value(), iterSameBox.value());
}
iterSameBox.progress();
}
......@@ -261,21 +260,21 @@ class FFmbKernelsForces : public FAbstractFmbKernels<ParticuleClass,CellClass, T
}
void DIRECT_COMPUTATION_NO_MUTUAL_SOFT(ParticuleClass** const target, const ParticuleClass* const source){
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
const FReal dx = (*target)->getPosition().getX() - source->getPosition().getX();
const FReal dy = (*target)->getPosition().getY() - source->getPosition().getY();
const FReal dz = (*target)->getPosition().getZ() - source->getPosition().getZ();
FReal inv_square_distance = 1.0/ (dx*dx + dy*dy + dz*dz + FAbstractFmbKernels<ParticuleClass,CellClass,TreeHeight>::FMB_Info_eps_soft_square);
FReal inv_distance = FMath::Sqrt(inv_square_distance);
inv_distance *= (*target)->getPhysicalValue() * source->getPhysicalValue();
inv_square_distance *= inv_distance;
(*target)->setForces(
(*target)->getForces().getX() + dx * inv_square_distance,
(*target)->getForces().getY() + dy * inv_square_distance,
(*target)->getForces().getZ() + dz * inv_square_distance
);
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
const FReal dx = (*target)->getPosition().getX() - source->getPosition().getX();
const FReal dy = (*target)->getPosition().getY() - source->getPosition().getY();
const FReal dz = (*target)->getPosition().getZ() - source->getPosition().getZ();
FReal inv_square_distance = 1.0 / (dx*dx + dy*dy + dz*dz + FAbstractFmbKernels<ParticuleClass,CellClass,TreeHeight>::FMB_Info_eps_soft_square);
FReal inv_distance = FMath::Sqrt(inv_square_distance);
inv_distance *= (*target)->getPhysicalValue() * source->getPhysicalValue();
inv_square_distance *= inv_distance;
(*target)->setForces(
(*target)->getForces().getX() + dx * inv_square_distance,
(*target)->getForces().getY() + dy * inv_square_distance,
(*target)->getForces().getZ() + dz * inv_square_distance
);
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
};
......
......@@ -92,9 +92,10 @@ public:
* )
*
*/
void P2P(FList<ParticuleClass*>* const FRestrict currentBox, const FList<ParticuleClass*>* FRestrict const* FRestrict directNeighbors, const int size) {
void P2P(FList<ParticuleClass*>* const FRestrict targets, const FList<ParticuleClass*>* const FRestrict sources,
const FList<ParticuleClass*>* FRestrict const* FRestrict directNeighbors, const int size) {
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
typename FList<ParticuleClass*>::BasicIterator iterTarget(*currentBox);
typename FList<ParticuleClass*>::BasicIterator iterTarget(*targets);
while( iterTarget.isValide() ){
for(int idxDirectNeighbors = 0 ; idxDirectNeighbors < size ; ++idxDirectNeighbors){
typename FList<ParticuleClass*>::ConstBasicIterator iterSource(*directNeighbors[idxDirectNeighbors]);
......@@ -104,7 +105,7 @@ public:
}
}
typename FList<ParticuleClass*>::BasicIterator iterSameBox(*currentBox);
typename FList<ParticuleClass*>::ConstBasicIterator iterSameBox(*sources);
while( iterSameBox.isValide() ){
if(iterSameBox.value() != iterTarget.value()){
DIRECT_COMPUTATION_NO_MUTUAL_SOFT(&iterTarget.value(), iterSameBox.value());
......
......@@ -290,9 +290,10 @@ public:
* )
*
*/
void P2P(FList<ParticuleClass*>* const FRestrict currentBox, const FList<ParticuleClass*>* FRestrict const* FRestrict directNeighbors, const int size) {
void P2P(FList<ParticuleClass*>* const FRestrict targets, const FList<ParticuleClass*>* const FRestrict sources,
const FList<ParticuleClass*>* FRestrict const* FRestrict directNeighbors, const int size) {
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
typename FList<ParticuleClass*>::BasicIterator iterTarget(*currentBox);
typename FList<ParticuleClass*>::BasicIterator iterTarget(*targets);
while( iterTarget.isValide() ){
for(int idxDirectNeighbors = 0 ; idxDirectNeighbors < size ; ++idxDirectNeighbors){
......@@ -304,7 +305,7 @@ public:
}
}
typename FList<ParticuleClass*>::BasicIterator iterSameBox(*currentBox);
typename FList<ParticuleClass*>::ConstBasicIterator iterSameBox(*sources);
while( iterSameBox.isValide() ){
if(iterSameBox.value() != iterTarget.value()){
DIRECT_COMPUTATION_NO_MUTUAL_SOFT(&iterTarget.value(),
......
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