Commit 184e6682 authored by berenger-bramas's avatar berenger-bramas

Clean cmake & Fmm algo

(adding comments etc.)

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@65 2616d619-271b-44dc-8df4-d4a8f33a7222
parent ce429500
...@@ -9,10 +9,10 @@ endif(insource) ...@@ -9,10 +9,10 @@ endif(insource)
# Options # Options
OPTION( SCALFMM_USE_CBLAS "Set to ON to build ScaFMM with BLAS" ON ) OPTION( SCALFMM_USE_CBLAS "Set to ON to build ScaFMM with BLAS" ON )
OPTION( SCALFMM_USE_MPI "Set to ON to build ScaFMM with MPI" ON ) OPTION( SCALFMM_USE_MPI "Set to ON to build ScaFMM with MPI" ON )
OPTION( BUILD_TESTS "Set to ON to build fonctionnalities Tests" ON ) OPTION( SCALFMM_BUILD_TESTS "Set to ON to build fonctionnalities Tests" ON )
OPTION( BUILD_UTESTS "Set to ON to build UTests" ON ) OPTION( SCALFMM_BUILD_UTESTS "Set to ON to build UTests" ON )
# MPI option # MPI option has to be set before project
if( SCALFMM_USE_MPI ) if( SCALFMM_USE_MPI )
SET(CMAKE_CXX_COMPILER mpicxx) SET(CMAKE_CXX_COMPILER mpicxx)
endif() endif()
...@@ -42,14 +42,14 @@ CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/Src/ScalFmmConfig.h.cmake ...@@ -42,14 +42,14 @@ CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/Src/ScalFmmConfig.h.cmake
add_subdirectory(Src) add_subdirectory(Src)
# Build - Tests # Build - Tests
MESSAGE( STATUS "BUILD_TESTS = ${BUILD_TESTS}" ) MESSAGE( STATUS "SCALFMM_BUILD_TESTS = ${SCALFMM_BUILD_TESTS}" )
if( BUILD_TESTS ) if( SCALFMM_BUILD_TESTS )
add_subdirectory(Tests) add_subdirectory(Tests)
endif() endif()
# Build - UTests # Build - UTests
MESSAGE( STATUS "BUILD_UTESTS = ${BUILD_UTESTS}" ) MESSAGE( STATUS "SCALFMM_BUILD_UTESTS = ${SCALFMM_BUILD_UTESTS}" )
if( BUILD_UTESTS ) if( SCALFMM_BUILD_UTESTS )
add_subdirectory(UTests) add_subdirectory(UTests)
endif() endif()
......
...@@ -20,6 +20,6 @@ add_library( ...@@ -20,6 +20,6 @@ add_library(
# Adding the entire project dir as an include dir # Adding the entire project dir as an include dir
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
${CMAKE_BINARY_DIR}/Sources ${CMAKE_BINARY_DIR}/Src
) )
...@@ -33,9 +33,6 @@ class FFmmAlgorithm : protected FAssertable{ ...@@ -33,9 +33,6 @@ class FFmmAlgorithm : protected FAssertable{
Octree* const tree; //< The octree to work on Octree* const tree; //< The octree to work on
KernelClass<ParticleClass, CellClass, OctreeHeight>* const kernels; //< The kernels KernelClass<ParticleClass, CellClass, OctreeHeight>* const kernels; //< The kernels
FDEBUG(FTic counterTime); //< In case of debug: to count the elapsed time
FDEBUG(FTic computationCounter); //< In case of debug: to count computation time
public: public:
/** The constructor need the octree and the kernels used for computation /** The constructor need the octree and the kernels used for computation
* @param inTree the octree to work on * @param inTree the octree to work on
...@@ -62,23 +59,26 @@ public: ...@@ -62,23 +59,26 @@ public:
void execute(){ void execute(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) ); FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
kernels->init();
bottomPass(); bottomPass();
upwardPass(); upwardPass();
downardPass(); downardPass();
directPass(); directPass();
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) ); FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
} }
/////////////////////////////////////////////////////////////////////////////
// P2M
/////////////////////////////////////////////////////////////////////////////
/** P2M */ /** P2M */
void bottomPass(){ void bottomPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) ); FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Bottom Pass\n").write(FDebug::Flush) ); FDEBUG( FDebug::Controller.write("\tStart Bottom Pass\n").write(FDebug::Flush) );
FDEBUG( counterTime.tic() ); FDEBUG(FTic counterTime);
FDEBUG( double totalComputation = 0 ); FDEBUG(FTic computationCounter);
FOctreeIterator octreeIterator(tree); FOctreeIterator octreeIterator(tree);
...@@ -90,21 +90,23 @@ public: ...@@ -90,21 +90,23 @@ public:
FDEBUG(computationCounter.tic()); FDEBUG(computationCounter.tic());
kernels->P2M( octreeIterator.getCurrentCell() , octreeIterator.getCurrentListSrc()); kernels->P2M( octreeIterator.getCurrentCell() , octreeIterator.getCurrentListSrc());
FDEBUG(computationCounter.tac()); FDEBUG(computationCounter.tac());
FDEBUG(totalComputation += computationCounter.elapsed());
} while(octreeIterator.moveRight()); } while(octreeIterator.moveRight());
FDEBUG( counterTime.tac() ); FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.tacAndElapsed() << "s)\n" );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" ); FDEBUG( FDebug::Controller << "\t\t Computation : " << computationCounter.cumulated() << " s\n" );
FDEBUG( FDebug::Controller << "\t\t Computation : " << totalComputation << " s\n" );
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) ); FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
} }
/////////////////////////////////////////////////////////////////////////////
// Upward
/////////////////////////////////////////////////////////////////////////////
/** M2M */ /** M2M */
void upwardPass(){ void upwardPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) ); FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Upward Pass\n").write(FDebug::Flush); ); FDEBUG( FDebug::Controller.write("\tStart Upward Pass\n").write(FDebug::Flush); );
FDEBUG( counterTime.tic() ); FDEBUG(FTic counterTime);
FDEBUG( double totalComputation = 0 ); FDEBUG(FTic computationCounter);
// Start from leal level - 1 // Start from leal level - 1
FOctreeIterator octreeIterator(tree); FOctreeIterator octreeIterator(tree);
...@@ -122,27 +124,31 @@ public: ...@@ -122,27 +124,31 @@ public:
FDEBUG(computationCounter.tic()); FDEBUG(computationCounter.tic());
kernels->M2M( octreeIterator.getCurrentCell() , octreeIterator.getCurrentChild(), idxLevel); kernels->M2M( octreeIterator.getCurrentCell() , octreeIterator.getCurrentChild(), idxLevel);
FDEBUG(computationCounter.tac()); FDEBUG(computationCounter.tac());
FDEBUG(totalComputation += computationCounter.elapsed());
} while(octreeIterator.moveRight()); } while(octreeIterator.moveRight());
avoidGotoLeftIterator.moveUp(); avoidGotoLeftIterator.moveUp();
octreeIterator = avoidGotoLeftIterator;// equal octreeIterator.moveUp(); octreeIterator.gotoLeft(); octreeIterator = avoidGotoLeftIterator;// equal octreeIterator.moveUp(); octreeIterator.gotoLeft();
} }
FDEBUG( counterTime.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" ); FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.tacAndElapsed() << "s)\n" );
FDEBUG( FDebug::Controller << "\t\t Computation : " << totalComputation << " s\n" ); FDEBUG( FDebug::Controller << "\t\t Computation : " << computationCounter.cumulated() << " s\n" );
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) ); FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
} }
/////////////////////////////////////////////////////////////////////////////
// Downward
/////////////////////////////////////////////////////////////////////////////
/** M2L L2L */ /** M2L L2L */
void downardPass(){ void downardPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) ); FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Downward Pass (M2L)\n").write(FDebug::Flush); );
FDEBUG( counterTime.tic() );
FDEBUG( double totalComputation = 0 );
{ // first M2L { // first M2L
FDEBUG( FDebug::Controller.write("\tStart Downward Pass (M2L)\n").write(FDebug::Flush); );
FDEBUG(FTic counterTime);
FDEBUG(FTic computationCounter);
FOctreeIterator octreeIterator(tree); FOctreeIterator octreeIterator(tree);
octreeIterator.moveDown(); octreeIterator.moveDown();
...@@ -153,25 +159,24 @@ public: ...@@ -153,25 +159,24 @@ public:
for(int idxLevel = 2 ; idxLevel < OctreeHeight ; ++idxLevel ){ for(int idxLevel = 2 ; idxLevel < OctreeHeight ; ++idxLevel ){
// for each cells // for each cells
do{ do{
FDEBUG(computationCounter.tic());
const int counter = tree->getDistantNeighbors(neighbors, octreeIterator.getCurrentGlobalIndex(),idxLevel); const int counter = tree->getDistantNeighbors(neighbors, octreeIterator.getCurrentGlobalIndex(),idxLevel);
FDEBUG(computationCounter.tic());
if(counter) kernels->M2L( octreeIterator.getCurrentCell() , neighbors, counter, idxLevel); if(counter) kernels->M2L( octreeIterator.getCurrentCell() , neighbors, counter, idxLevel);
FDEBUG(computationCounter.tac()); FDEBUG(computationCounter.tac());
FDEBUG(totalComputation += computationCounter.elapsed());
} while(octreeIterator.moveRight()); } while(octreeIterator.moveRight());
avoidGotoLeftIterator.moveDown(); avoidGotoLeftIterator.moveDown();
octreeIterator = avoidGotoLeftIterator; octreeIterator = avoidGotoLeftIterator;
} }
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.tacAndElapsed() << "s)\n" );
FDEBUG( FDebug::Controller << "\t\t Computation : " << computationCounter.cumulated() << " s\n" );
} }
FDEBUG( counterTime.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" ); { // second L2L
FDEBUG( FDebug::Controller << "\t\t Computation : " << totalComputation << " s\n" ); FDEBUG( FDebug::Controller.write("\tStart Downward Pass (L2L)\n").write(FDebug::Flush); );
FDEBUG(FTic counterTime);
FDEBUG( FDebug::Controller.write("\tStart Downward Pass (L2L)\n").write(FDebug::Flush); ); FDEBUG(FTic computationCounter );
FDEBUG( counterTime.tic() );
FDEBUG( totalComputation = 0 );
{ // second L2L
FOctreeIterator octreeIterator(tree); FOctreeIterator octreeIterator(tree);
octreeIterator.moveDown(); octreeIterator.moveDown();
...@@ -185,26 +190,29 @@ public: ...@@ -185,26 +190,29 @@ public:
FDEBUG(computationCounter.tic()); FDEBUG(computationCounter.tic());
kernels->L2L( octreeIterator.getCurrentCell() , octreeIterator.getCurrentChild(), idxLevel); kernels->L2L( octreeIterator.getCurrentCell() , octreeIterator.getCurrentChild(), idxLevel);
FDEBUG(computationCounter.tac()); FDEBUG(computationCounter.tac());
FDEBUG(totalComputation += computationCounter.elapsed());
} while(octreeIterator.moveRight()); } while(octreeIterator.moveRight());
avoidGotoLeftIterator.moveDown(); avoidGotoLeftIterator.moveDown();
octreeIterator = avoidGotoLeftIterator; octreeIterator = avoidGotoLeftIterator;
} }
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.tacAndElapsed() << "s)\n" );
FDEBUG( FDebug::Controller << "\t\t Computation : " << computationCounter.cumulated() << " s\n" );
} }
FDEBUG( counterTime.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" );
FDEBUG( FDebug::Controller << "\t\t Computation : " << totalComputation << " s\n" );
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) ); FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
} }
/////////////////////////////////////////////////////////////////////////////
// Direct
/////////////////////////////////////////////////////////////////////////////
/** P2P */ /** P2P */
void directPass(){ void directPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) ); FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Direct Pass\n").write(FDebug::Flush); ); FDEBUG( FDebug::Controller.write("\tStart Direct Pass\n").write(FDebug::Flush); );
FDEBUG( counterTime.tic() ); FDEBUG(FTic counterTime);
FDEBUG( double totalComputation = 0 ); FDEBUG(FTic computationCounter);
const int heightMinusOne = OctreeHeight - 1; const int heightMinusOne = OctreeHeight - 1;
...@@ -216,16 +224,17 @@ public: ...@@ -216,16 +224,17 @@ public:
do{ do{
FDEBUG(computationCounter.tic()); FDEBUG(computationCounter.tic());
kernels->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets()); kernels->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets());
FDEBUG(computationCounter.tac());
// need the current particles and neighbors particles // need the current particles and neighbors particles
const int counter = tree->getLeafsNeighbors(neighbors, octreeIterator.getCurrentGlobalIndex(),heightMinusOne); const int counter = tree->getLeafsNeighbors(neighbors, octreeIterator.getCurrentGlobalIndex(),heightMinusOne);
FDEBUG(computationCounter.tic());
kernels->P2P( octreeIterator.getCurrentListTargets(), octreeIterator.getCurrentListSrc() , neighbors, counter); kernels->P2P( octreeIterator.getCurrentListTargets(), octreeIterator.getCurrentListSrc() , neighbors, counter);
FDEBUG(computationCounter.tac()); FDEBUG(computationCounter.tac());
FDEBUG(totalComputation += computationCounter.elapsed());
} while(octreeIterator.moveRight()); } while(octreeIterator.moveRight());
FDEBUG( counterTime.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" ); FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.tacAndElapsed() << "s)\n" );
FDEBUG( FDebug::Controller << "\t\t Computation : " << totalComputation << " s\n" ); FDEBUG( FDebug::Controller << "\t\t Computation : " << computationCounter.cumulated() << " s\n" );
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) ); FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
} }
......
...@@ -40,15 +40,14 @@ class FFmmAlgorithmThread : protected FAssertable{ ...@@ -40,15 +40,14 @@ class FFmmAlgorithmThread : protected FAssertable{
typedef KernelClass<ParticleClass, CellClass, OctreeHeight> Kernel; typedef KernelClass<ParticleClass, CellClass, OctreeHeight> Kernel;
Octree* const tree; //< The octree to work on Octree* const tree; //< The octree to work on
Kernel* kernels[FThreadNumbers]; //< The kernels Kernel** kernels; //< The kernels
FDEBUG(FTic counterTime); //< In case of debug: to count the elapsed time
FDEBUG(FTic computationCounter); //< In case of debug: to count computation time
OctreeIterator* iterArray; OctreeIterator* iterArray;
static const int SizeShape = 3*3*3; static const int SizeShape = 3*3*3;
int shapeLeaf[SizeShape]; int shapeLeaf[SizeShape];
const int MaxThreads;
public: public:
/** The constructor need the octree and the kernels used for computation /** The constructor need the octree and the kernels used for computation
...@@ -57,12 +56,12 @@ public: ...@@ -57,12 +56,12 @@ public:
* An assert is launched if one of the arguments is null * An assert is launched if one of the arguments is null
*/ */
FFmmAlgorithmThread(Octree* const inTree, Kernel* const inKernels) FFmmAlgorithmThread(Octree* const inTree, Kernel* const inKernels)
: tree(inTree) , iterArray(0) { : tree(inTree) , kernels(0), iterArray(0), MaxThreads(omp_get_max_threads()) {
assert(tree, "tree cannot be null", __LINE__, __FILE__); assert(tree, "tree cannot be null", __LINE__, __FILE__);
assert(kernels, "kernels cannot be null", __LINE__, __FILE__);
for(int idxThread = 0 ; idxThread < FThreadNumbers ; ++idxThread){ this->kernels = new Kernel*[MaxThreads];
for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
this->kernels[idxThread] = new KernelClass<ParticleClass, CellClass, OctreeHeight>(*inKernels); this->kernels[idxThread] = new KernelClass<ParticleClass, CellClass, OctreeHeight>(*inKernels);
} }
...@@ -71,9 +70,10 @@ public: ...@@ -71,9 +70,10 @@ public:
/** Default destructor */ /** Default destructor */
virtual ~FFmmAlgorithmThread(){ virtual ~FFmmAlgorithmThread(){
for(int idxThread = 0 ; idxThread < FThreadNumbers ; ++idxThread){ for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
delete this->kernels[idxThread]; delete this->kernels[idxThread];
} }
delete [] this->kernels;
} }
/** /**
...@@ -103,10 +103,6 @@ public: ...@@ -103,10 +103,6 @@ public:
iterArray = new OctreeIterator[leafs]; iterArray = new OctreeIterator[leafs];
assert(iterArray, "iterArray bad alloc", __LINE__, __FILE__); assert(iterArray, "iterArray bad alloc", __LINE__, __FILE__);
for(int idxThread = 0 ; idxThread < FThreadNumbers ; ++idxThread){
this->kernels[idxThread]->init();
}
bottomPass(); bottomPass();
upwardPass(); upwardPass();
...@@ -120,11 +116,15 @@ public: ...@@ -120,11 +116,15 @@ public:
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) ); FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
} }
/////////////////////////////////////////////////////////////////////////////
// P2M
/////////////////////////////////////////////////////////////////////////////
/** P2M */ /** P2M */
void bottomPass(){ void bottomPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) ); FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Bottom Pass\n").write(FDebug::Flush) ); FDEBUG( FDebug::Controller.write("\tStart Bottom Pass\n").write(FDebug::Flush) );
FDEBUG( counterTime.tic() ); FDEBUG(FTic counterTime);
OctreeIterator octreeIterator(tree); OctreeIterator octreeIterator(tree);
int leafs = 0; int leafs = 0;
...@@ -135,8 +135,8 @@ public: ...@@ -135,8 +135,8 @@ public:
++leafs; ++leafs;
} while(octreeIterator.moveRight()); } while(octreeIterator.moveRight());
FDEBUG(computationCounter.tic()); FDEBUG(FTic computationCounter);
#pragma omp parallel num_threads(FThreadNumbers) #pragma omp parallel
{ {
Kernel * const myThreadkernels = kernels[omp_get_thread_num()]; Kernel * const myThreadkernels = kernels[omp_get_thread_num()];
#pragma omp for #pragma omp for
...@@ -146,20 +146,23 @@ public: ...@@ -146,20 +146,23 @@ public:
myThreadkernels->P2M( iterArray[idxLeafs].getCurrentCell() , iterArray[idxLeafs].getCurrentListSrc()); myThreadkernels->P2M( iterArray[idxLeafs].getCurrentCell() , iterArray[idxLeafs].getCurrentListSrc());
} }
} }
FDEBUG(computationCounter.tac()); FDEBUG(computationCounter.tac() );
FDEBUG( counterTime.tac() ); FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.tacAndElapsed() << "s)\n" );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" );
FDEBUG( FDebug::Controller << "\t\t Computation : " << computationCounter.elapsed() << " s\n" ); FDEBUG( FDebug::Controller << "\t\t Computation : " << computationCounter.elapsed() << " s\n" );
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) ); FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
} }
/////////////////////////////////////////////////////////////////////////////
// Upward
/////////////////////////////////////////////////////////////////////////////
/** M2M */ /** M2M */
void upwardPass(){ void upwardPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) ); FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Upward Pass\n").write(FDebug::Flush); ); FDEBUG( FDebug::Controller.write("\tStart Upward Pass\n").write(FDebug::Flush); );
FDEBUG( counterTime.tic() ); FDEBUG(FTic counterTime);
FDEBUG( double totalComputation = 0 ); FDEBUG(FTic computationCounter);
// Start from leal level - 1 // Start from leal level - 1
OctreeIterator octreeIterator(tree); OctreeIterator octreeIterator(tree);
...@@ -179,7 +182,7 @@ public: ...@@ -179,7 +182,7 @@ public:
octreeIterator = avoidGotoLeftIterator;// equal octreeIterator.moveUp(); octreeIterator.gotoLeft(); octreeIterator = avoidGotoLeftIterator;// equal octreeIterator.moveUp(); octreeIterator.gotoLeft();
FDEBUG(computationCounter.tic()); FDEBUG(computationCounter.tic());
#pragma omp parallel num_threads(FThreadNumbers) #pragma omp parallel
{ {
Kernel * const myThreadkernels = kernels[omp_get_thread_num()]; Kernel * const myThreadkernels = kernels[omp_get_thread_num()];
#pragma omp for #pragma omp for
...@@ -190,23 +193,27 @@ public: ...@@ -190,23 +193,27 @@ public:
} }
} }
FDEBUG(computationCounter.tac()); FDEBUG(computationCounter.tac());
FDEBUG(totalComputation += computationCounter.elapsed());
} }
FDEBUG( counterTime.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" ); FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.tacAndElapsed() << "s)\n" );
FDEBUG( FDebug::Controller << "\t\t Computation : " << totalComputation << " s\n" ); FDEBUG( FDebug::Controller << "\t\t Computation : " << computationCounter.cumulated() << " s\n" );
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) ); FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
} }
/////////////////////////////////////////////////////////////////////////////
// Downard
/////////////////////////////////////////////////////////////////////////////
/** M2L L2L */ /** M2L L2L */
void downardPass(){ void downardPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) ); FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Downward Pass (M2L)\n").write(FDebug::Flush); );
FDEBUG( counterTime.tic() );
FDEBUG( double totalComputation = 0 );
{ // first M2L { // first M2L
FDEBUG( FDebug::Controller.write("\tStart Downward Pass (M2L)\n").write(FDebug::Flush); );
FDEBUG(FTic counterTime);
FDEBUG(FTic computationCounter);
OctreeIterator octreeIterator(tree); OctreeIterator octreeIterator(tree);
octreeIterator.moveDown(); octreeIterator.moveDown();
OctreeIterator avoidGotoLeftIterator(octreeIterator); OctreeIterator avoidGotoLeftIterator(octreeIterator);
...@@ -223,7 +230,7 @@ public: ...@@ -223,7 +230,7 @@ public:
octreeIterator = avoidGotoLeftIterator; octreeIterator = avoidGotoLeftIterator;
FDEBUG(computationCounter.tic()); FDEBUG(computationCounter.tic());
#pragma omp parallel num_threads(FThreadNumbers) #pragma omp parallel
{ {
Kernel * const myThreadkernels = kernels[omp_get_thread_num()]; Kernel * const myThreadkernels = kernels[omp_get_thread_num()];
CellClass* neighbors[208]; CellClass* neighbors[208];
...@@ -234,17 +241,17 @@ public: ...@@ -234,17 +241,17 @@ public:
} }
} }
FDEBUG(computationCounter.tac()); FDEBUG(computationCounter.tac());
FDEBUG(totalComputation += computationCounter.elapsed());
} }
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.tacAndElapsed() << "s)\n" );
FDEBUG( FDebug::Controller << "\t\t Computation : " << computationCounter.cumulated() << " s\n" );
} }
FDEBUG( counterTime.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" );
FDEBUG( FDebug::Controller << "\t\t Computation : " << totalComputation << " s\n" );
FDEBUG( FDebug::Controller.write("\tStart Downward Pass (L2L)\n").write(FDebug::Flush); );
FDEBUG( counterTime.tic() );
FDEBUG( totalComputation = 0 );
{ // second L2L { // second L2L
FDEBUG( FDebug::Controller.write("\tStart Downward Pass (L2L)\n").write(FDebug::Flush); );
FDEBUG(FTic counterTime);
FDEBUG(FTic computationCounter);
OctreeIterator octreeIterator(tree); OctreeIterator octreeIterator(tree);
octreeIterator.moveDown(); octreeIterator.moveDown();
...@@ -263,7 +270,7 @@ public: ...@@ -263,7 +270,7 @@ public:
octreeIterator = avoidGotoLeftIterator; octreeIterator = avoidGotoLeftIterator;
FDEBUG(computationCounter.tic()); FDEBUG(computationCounter.tic());
#pragma omp parallel num_threads(FThreadNumbers) #pragma omp parallel
{ {
Kernel * const myThreadkernels = kernels[omp_get_thread_num()]; Kernel * const myThreadkernels = kernels[omp_get_thread_num()];
#pragma omp for #pragma omp for
...@@ -272,21 +279,25 @@ public: ...@@ -272,21 +279,25 @@ public:
} }
} }
FDEBUG(computationCounter.tac()); FDEBUG(computationCounter.tac());
FDEBUG(totalComputation += computationCounter.elapsed());
} }
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.tacAndElapsed() << "s)\n" );
FDEBUG( FDebug::Controller << "\t\t Computation : " << computationCounter.cumulated() << " s\n" );
} }
FDEBUG( counterTime.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" );
FDEBUG( FDebug::Controller << "\t\t Computation : " << totalComputation << " s\n" );
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) ); FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
} }
/////////////////////////////////////////////////////////////////////////////
// Direct
/////////////////////////////////////////////////////////////////////////////
/** P2P */ /** P2P */
void directPass(){ void directPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) ); FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Direct Pass\n").write(FDebug::Flush); ); FDEBUG( FDebug::Controller.write("\tStart Direct Pass\n").write(FDebug::Flush); );
FDEBUG( counterTime.tic() ); FDEBUG(FTic counterTime);
FDEBUG(FTic computationCounter);
OctreeIterator* shapeArray[SizeShape]; OctreeIterator* shapeArray[SizeShape];
int countShape[SizeShape]; int countShape[SizeShape];
...@@ -317,7 +328,7 @@ public: ...@@ -317,7 +328,7 @@ public:
FDEBUG(computationCounter.tic()); FDEBUG(computationCounter.tic());
for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){ for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
const int leafAtThisShape = this->shapeLeaf[idxShape]; const int leafAtThisShape = this->shapeLeaf[idxShape];
#pragma omp parallel num_threads(FThreadNumbers) #pragma omp parallel
{ {
Kernel * const myThreadkernels = kernels[omp_get_thread_num()]; Kernel * const myThreadkernels = kernels[omp_get_thread_num()];
// There is a maximum of 26 neighbors // There is a maximum of 26 neighbors
...@@ -338,9 +349,8 @@ public: ...@@ -338,9 +349,8 @@ public:
delete [] shapeArray[idxShape]; delete [] shapeArray[idxShape];
} }
FDEBUG( counterTime.tac() ); FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.tacAndElapsed() << "s)\n" );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" ); FDEBUG( FDebug::Controller << "\t\t Computation : " << computationCounter.cumulated() << " s\n" );
FDEBUG( FDebug::Controller << "\t\t Computation : " << computationCounter.elapsed() << " s\n" );
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) ); FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
} }
......
...@@ -44,20 +44,17 @@ typedef FSingleApplication ApplicationImplementation; ...@@ -44,20 +44,17 @@ typedef FSingleApplication ApplicationImplementation;
* schedule(runtime) * schedule(runtime)
*/ */
template<template< class ParticleClass, class CellClass, int OctreeHeight> class KernelClass, template<template< class ParticleClass, class CellClass, int OctreeHeight> class KernelClass,
class ParticleClass, class CellClass, class ParticleClass, class CellClass,
template<class ParticleClass> class LeafClass, template<class ParticleClass> class LeafClass,
int OctreeHeight, int SubtreeHeight> int OctreeHeight, int SubtreeHeight>
class FFmmAlgorithmThreadProc : protected FAssertable, protected ApplicationImplementation{ class FFmmAlgorithmThreadProc : protected FAssertable, protected ApplicationImplementation{
// To reduce the size of variable type based on foctree in this file // To reduce the size of variable type based on foctree in this file
typedef FOctree<ParticleClass, CellClass, LeafClass, OctreeHeight, SubtreeHeight> Octree; typedef FOctree<ParticleClass, CellClass, LeafClass, OctreeHeight, SubtreeHeight> Octree;
typedef typename FOctree<ParticleClass, CellClass,LeafClass