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) );
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -40,13 +40,12 @@ class FFmmAlgorithmThreadTsm : protected FAssertable{ ...@@ -40,13 +40,12 @@ class FFmmAlgorithmThreadTsm : 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;
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
* @param inTree the octree to work on * @param inTree the octree to work on
...@@ -54,12 +53,12 @@ public: ...@@ -54,12 +53,12 @@ public:
* An assert is launched if one of the arguments is null * An assert is launched if one of the arguments is null
*/ */
FFmmAlgorithmThreadTsm(Octree* const inTree, Kernel* const inKernels) FFmmAlgorithmThreadTsm(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);
} }
...@@ -68,9 +67,10 @@ public: ...@@ -68,9 +67,10 @@ public:
/** Default destructor */ /** Default destructor */
virtual ~FFmmAlgorithmThreadTsm(){ virtual ~FFmmAlgorithmThreadTsm(){
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;
} }
/** /**
...@@ -90,7 +90,7 @@ public: ...@@ -90,7 +90,7 @@ 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){ for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
this->kernels[idxThread]->init(); this->kernels[idxThread]->init();
} }
...@@ -111,7 +111,7 @@ public: ...@@ -111,7 +111,7 @@ public:
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;
...@@ -122,8 +122,8 @@ public: ...@@ -122,8 +122,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
...@@ -152,8 +152,8 @@ public: ...@@ -152,8 +152,8 @@ public:
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);
...@@ -173,7 +173,7 @@ public: ...@@ -173,7 +173,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
...@@ -199,23 +199,23 @@ public: ...@@ -199,23 +199,23 @@ public:
} }
} }
FDEBUG(computationCounter.tac()); FDEBUG(computationCounter.tac());
FDEBUG(totalComputation += computationCounter.elapsed());
} }
FDEBUG( counterTime.tac() ); FDEBUG( counterTime.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" ); FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "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) );
} }
/** 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);
...@@ -232,7 +232,7 @@ public: ...@@ -232,7 +232,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];
...@@ -259,17 +259,16 @@ public: ...@@ -259,17 +259,16 @@ 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();
...@@ -288,7 +287,7 @@ public: ...@@ -288,7 +287,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
...@@ -308,13 +307,11 @@ public: ...@@ -308,13 +307,11 @@ 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) );
} }
...@@ -322,7 +319,7 @@ public: ...@@ -322,7 +319,7 @@ public:
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);
int leafs = 0; int leafs = 0;
{ {
...@@ -336,8 +333,8 @@ public: ...@@ -336,8 +333,8 @@ public:
} }
const int heightMinusOne = OctreeHeight - 1; const int heightMinusOne = OctreeHeight - 1;
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()];
// There is a maximum of 26 neighbors // There is a maximum of 26 neighbors
...@@ -354,7 +351,7 @@ public: ...@@ -354,7 +351,7 @@ public:
FDEBUG(computationCounter.tac()); FDEBUG(computationCounter.tac());
FDEBUG( counterTime.tac() ); 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 : " << 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) );
} }
......
...@@ -40,13 +40,12 @@ class FFmmAlgorithmThreadUs : protected FAssertable{ ...@@ -40,13 +40,12 @@ class FFmmAlgorithmThreadUs : 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;
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
* @param inTree the octree to work on * @param inTree the octree to work on
...@@ -54,12 +53,12 @@ public: ...@@ -54,12 +53,12 @@ public:
* An assert is launched if one of the arguments is null * An assert is launched if one of the arguments is null
*/ */
FFmmAlgorithmThreadUs(Octree* const inTree, Kernel* const inKernels) FFmmAlgorithmThreadUs(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);
} }
...@@ -68,9 +67,10 @@ public: ...@@ -68,9 +67,10 @@ public:
/** Default destructor */ /** Default destructor */
virtual ~FFmmAlgorithmThreadUs(){ virtual ~FFmmAlgorithmThreadUs(){
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;
} }
/** /**
...@@ -90,7 +90,7 @@ public: ...@@ -90,7 +90,7 @@ public:
iterArray = new OctreeIterator[leafs]; iterArray = new OctreeIterator[leafs];
assert(iterArray, "iterArray bad alloc", __LINE__, __FILE__); assert(iterArray, "iterArray bad alloc", __LINE__, __FILE__);