Commit d291b900 authored by berenger-bramas's avatar berenger-bramas

Added CMake support

Build Directory
Put a data directory (data are not on the svn yet)
Remove compilation warning with -wall

Need to forbid use of cmake inside sources directory.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@28 2616d619-271b-44dc-8df4-d4a8f33a7222
parent 8c1a3efd
cmake_minimum_required (VERSION 2.6)
# Project Infos
project(FMB_All CXX)
# Options
OPTION( BUILD_TESTS "Set to ON to build fonctionnalities Tests" ON )
OPTION( BUILD_UTESTS "Set to ON to build UTests" ON )
ADD_DEFINITIONS(-O2 -Wall -W -Wshadow -Wpointer-arith -Wcast-qual)
# Build - lib
add_subdirectory(Sources)
# Build - Tests
MESSAGE( STATUS "BUILD_TESTS = ${BUILD_TESTS}" )
if( ${BUILD_TESTS} STREQUAL "ON" )
add_subdirectory(Tests)
endif()
# Build - UTests
MESSAGE( STATUS "BUILD_UTESTS = ${BUILD_UTESTS}" )
if( ${BUILD_UTESTS} STREQUAL "ON" )
add_subdirectory(UTests)
endif()
cmake_minimum_required(VERSION 2.6)
#Configuration du projet
project(FMB++)
set(LIBRARY_OUTPUT_PATH ../lib/${CMAKE_BUILD_TYPE})
#Configuration de la bibliothèque
file(
GLOB_RECURSE
source_lib_files
./*.cpp
)
add_library(
FMB
STATIC
${source_lib_files}
)
......@@ -87,9 +87,8 @@ public:
* @param inBoxCenter box center for this simulation
*/
FOctree(const FReal inBoxWidth, const F3DPosition& inBoxCenter)
: boxWidth(inBoxWidth) , boxCenter(inBoxCenter), boxCorner(inBoxCenter - (inBoxWidth/2)),
height(OctreeHeight) , leafIndex(OctreeHeight-1),
root(0, 0, SubtreeHeight, 1){
: root(0, 0, SubtreeHeight, 1), boxCenter(inBoxCenter), boxCorner(inBoxCenter - (inBoxWidth/2)), boxWidth(inBoxWidth),
height(OctreeHeight) , leafIndex(OctreeHeight-1) {
FReal tempWidth = this->boxWidth;
// pre compute box width for each level
for(int indexLevel = 0; indexLevel < this->height; ++indexLevel ){
......@@ -178,7 +177,7 @@ public:
* of the root (level 1 of octree) at the left limit index
*/
Iterator(FOctree* const inTarget)
: currentLocalLevel(0), currentLocalIndex(0) {
: currentLocalIndex(0) , currentLocalLevel(0) {
assert(inTarget, "Target for Octree::Iterator cannot be null", __LINE__, __FILE__);
assert(inTarget->root.getRightLeafIndex() >= 0, "Octree seems to be empty, getRightLeafIndex == 0", __LINE__, __FILE__);
......@@ -188,7 +187,7 @@ public:
this->currentLocalIndex = TransposeIndex(this->current.tree->getLeftLeafIndex(), (this->current.tree->getSubOctreeHeight() - this->currentLocalLevel - 1) );
}
Iterator() : currentLocalLevel(0), currentLocalIndex(0) {
Iterator() : currentLocalIndex(0),currentLocalLevel(0) {
current.tree = 0;
}
......
......@@ -46,7 +46,7 @@ protected:
long leftLeafIndex; //< The leaf at the left position (this is the array index to start when iterate)
long rightLeafIndex; //< The leaf at the right position (this is the last array index when iterate)
const int subOctreeHeight; //< Height of this suboctree
const int subOctreeHeight; //< Height of this suboctree
const int subOctreePosition; //< Level of the current suboctree in the global tree (0 if node)
......@@ -102,6 +102,11 @@ protected:
if(arrayIndex > this->rightLeafIndex) this->rightLeafIndex = arrayIndex;
}
/** Disable copy */
private:
FAbstractSubOctree(const FAbstractSubOctree&){}
FAbstractSubOctree& operator=(const FAbstractSubOctree&){return *this;}
public:
/**
* Constructor
......@@ -112,8 +117,8 @@ public:
*/
FAbstractSubOctree(FAbstractSubOctree* const inParent, const long inIndexInParent,
const int inSubOctreeHeight, const int inSubOctreePosition) :
parent( inParent ), indexInParent(inIndexInParent), subOctreePosition( inSubOctreePosition ),
subOctreeHeight( inSubOctreeHeight ), leftLeafIndex(1 << (3 * inSubOctreeHeight)), rightLeafIndex(-1) {
cells(0), parent( inParent ), indexInParent(inIndexInParent), leftLeafIndex(1 << (3 * inSubOctreeHeight)), rightLeafIndex(-1),
subOctreeHeight( inSubOctreeHeight ), subOctreePosition( inSubOctreePosition ) {
this->cells = new CellClass**[this->subOctreeHeight];
assert(this->cells, "Allocation failled", __LINE__, __FILE__);
......@@ -250,6 +255,10 @@ private:
FList<ParticuleClass*>** leafs; //< Leafs array
/** Disable copy */
FSubOctreeWithLeafs(const FSubOctreeWithLeafs&){}
FSubOctreeWithLeafs& operator=(const FSubOctreeWithLeafs&){return *this;}
public:
/**
* Constructor
......@@ -340,6 +349,10 @@ class FSubOctree : public FAbstractSubOctree<ParticuleClass,CellClass> {
private:
FAbstractSubOctree<ParticuleClass,CellClass>** subleafs; //< Last levels is composed of suboctree
/** Disable copy */
FSubOctree(const FSubOctree&){}
FSubOctree& operator=(const FSubOctree&){return *this;}
public:
/**
* Constructor
......
......@@ -30,7 +30,7 @@ class FFMMAlgorithm : protected FAssertable{
Octree* const tree; //< The octree to work on
KernelClass<ParticuleClass, CellClass, OctreeHeight>* const kernels; //< The kernels
FDEBUG(FTic counter); //< In case of debug: to count the elapsed time
FDEBUG(FTic counterTime); //< In case of debug: to count the elapsed time
FDEBUG(FTic computationCounter); //< In case of debug: to count computation time
public:
......@@ -74,7 +74,7 @@ public:
void bottomPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Bottom Pass\n").write(FDebug::Flush) );
FDEBUG( counter.tic() );
FDEBUG( counterTime.tic() );
FDEBUG( double totalComputation = 0 );
FOctreeIterator octreeIterator(tree);
......@@ -90,8 +90,8 @@ public:
FDEBUG(totalComputation += computationCounter.elapsed());
} while(octreeIterator.moveRight());
FDEBUG( counter.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counter.elapsed() << "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) );
}
......@@ -100,7 +100,7 @@ public:
void upwardPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Upward Pass\n").write(FDebug::Flush); );
FDEBUG( counter.tic() );
FDEBUG( counterTime.tic() );
FDEBUG( double totalComputation = 0 );
// Start from leal level - 1
......@@ -126,8 +126,8 @@ public:
octreeIterator = avoidGotoLeftIterator;// equal octreeIterator.moveUp(); octreeIterator.gotoLeft();
}
FDEBUG( counter.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counter.elapsed() << "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) );
}
......@@ -136,7 +136,7 @@ public:
void downardPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Downward Pass (M2L)\n").write(FDebug::Flush); );
FDEBUG( counter.tic() );
FDEBUG( counterTime.tic() );
FDEBUG( double totalComputation = 0 );
{ // first M2L
......@@ -161,12 +161,12 @@ public:
octreeIterator = avoidGotoLeftIterator;
}
}
FDEBUG( counter.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counter.elapsed() << "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( counter.tic() );
FDEBUG( counterTime.tic() );
FDEBUG( totalComputation = 0 );
{ // second L2L
FOctreeIterator octreeIterator(tree);
......@@ -190,8 +190,8 @@ public:
}
}
FDEBUG( counter.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counter.elapsed() << "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) );
}
......@@ -200,7 +200,7 @@ public:
void directPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Direct Pass\n").write(FDebug::Flush); );
FDEBUG( counter.tic() );
FDEBUG( counterTime.tic() );
FDEBUG( double totalComputation = 0 );
const int heightMinusOne = OctreeHeight - 1;
......@@ -220,8 +220,8 @@ public:
FDEBUG(totalComputation += computationCounter.elapsed());
} while(octreeIterator.moveRight());
FDEBUG( counter.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counter.elapsed() << "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) );
}
......
......@@ -6,6 +6,7 @@
#include "../Utils/FDebug.hpp"
#include "../Utils/FTrace.hpp"
#include "../Utils/FTic.hpp"
#include "../Utils/FGlobal.hpp"
#include "../Containers/FOctree.hpp"
......@@ -35,12 +36,10 @@ class FFMMAlgorithmArray : protected FAssertable{
typedef typename FOctree<ParticuleClass, CellClass, OctreeHeight, SubtreeHeight>::Iterator OctreeIterator;
typedef KernelClass<ParticuleClass, CellClass, OctreeHeight> Kernel;
static const int NbThreads = 4; //< Number of threads (currently a static number)
Octree* const tree; //< The octree to work on
Kernel* kernels[NbThreads]; //< The kernels
Kernel* kernels[FThreadNumbers]; //< The kernels
FDEBUG(FTic counter); //< In case of debug: to count the elapsed time
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;
......@@ -57,7 +56,7 @@ public:
assert(tree, "tree cannot be null", __LINE__, __FILE__);
assert(kernels, "kernels cannot be null", __LINE__, __FILE__);
for(int idxThread = 0 ; idxThread < NbThreads ; ++idxThread){
for(int idxThread = 0 ; idxThread < FThreadNumbers ; ++idxThread){
this->kernels[idxThread] = new KernelClass<ParticuleClass, CellClass, OctreeHeight>(*inKernels);
}
......@@ -66,7 +65,7 @@ public:
/** Default destructor */
virtual ~FFMMAlgorithmArray(){
for(int idxThread = 0 ; idxThread < NbThreads ; ++idxThread){
for(int idxThread = 0 ; idxThread < FThreadNumbers ; ++idxThread){
delete this->kernels[idxThread];
}
}
......@@ -88,7 +87,7 @@ public:
iterArray = new OctreeIterator[leafs];
assert(iterArray, "iterArray bad alloc", __LINE__, __FILE__);
for(int idxThread = 0 ; idxThread < NbThreads ; ++idxThread){
for(int idxThread = 0 ; idxThread < FThreadNumbers ; ++idxThread){
this->kernels[idxThread]->init();
}
......@@ -109,7 +108,7 @@ public:
void bottomPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Bottom Pass\n").write(FDebug::Flush) );
FDEBUG( counter.tic() );
FDEBUG( counterTime.tic() );
OctreeIterator octreeIterator(tree);
int leafs = 0;
......@@ -121,7 +120,7 @@ public:
} while(octreeIterator.moveRight());
FDEBUG(computationCounter.tic());
#pragma omp parallel num_threads(NbThreads)
#pragma omp parallel num_threads(FThreadNumbers)
{
Kernel * const myThreadkernels = kernels[omp_get_thread_num()];
#pragma omp for
......@@ -133,8 +132,8 @@ public:
}
FDEBUG(computationCounter.tac());
FDEBUG( counter.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counter.elapsed() << "s)\n" );
FDEBUG( counterTime.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" );
FDEBUG( FDebug::Controller << "\t\t Computation : " << computationCounter.elapsed() << " s\n" );
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
}
......@@ -143,7 +142,7 @@ public:
void upwardPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Upward Pass\n").write(FDebug::Flush); );
FDEBUG( counter.tic() );
FDEBUG( counterTime.tic() );
FDEBUG( double totalComputation = 0 );
// Start from leal level - 1
......@@ -164,7 +163,7 @@ public:
octreeIterator = avoidGotoLeftIterator;// equal octreeIterator.moveUp(); octreeIterator.gotoLeft();
FDEBUG(computationCounter.tic());
#pragma omp parallel num_threads(NbThreads)
#pragma omp parallel num_threads(FThreadNumbers)
{
Kernel * const myThreadkernels = kernels[omp_get_thread_num()];
#pragma omp for
......@@ -178,8 +177,8 @@ public:
FDEBUG(totalComputation += computationCounter.elapsed());
}
FDEBUG( counter.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counter.elapsed() << "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) );
}
......@@ -188,7 +187,7 @@ public:
void downardPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Downward Pass (M2L)\n").write(FDebug::Flush); );
FDEBUG( counter.tic() );
FDEBUG( counterTime.tic() );
FDEBUG( double totalComputation = 0 );
{ // first M2L
......@@ -208,7 +207,7 @@ public:
octreeIterator = avoidGotoLeftIterator;
FDEBUG(computationCounter.tic());
#pragma omp parallel num_threads(NbThreads)
#pragma omp parallel num_threads(FThreadNumbers)
{
Kernel * const myThreadkernels = kernels[omp_get_thread_num()];
CellClass* neighbors[208];
......@@ -222,12 +221,12 @@ public:
FDEBUG(totalComputation += computationCounter.elapsed());
}
}
FDEBUG( counter.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counter.elapsed() << "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( counter.tic() );
FDEBUG( counterTime.tic() );
FDEBUG( totalComputation = 0 );
{ // second L2L
OctreeIterator octreeIterator(tree);
......@@ -248,7 +247,7 @@ public:
octreeIterator = avoidGotoLeftIterator;
FDEBUG(computationCounter.tic());
#pragma omp parallel num_threads(NbThreads)
#pragma omp parallel num_threads(FThreadNumbers)
{
Kernel * const myThreadkernels = kernels[omp_get_thread_num()];
#pragma omp for
......@@ -261,8 +260,8 @@ public:
}
}
FDEBUG( counter.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counter.elapsed() << "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) );
}
......@@ -271,7 +270,7 @@ public:
void directPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Direct Pass\n").write(FDebug::Flush); );
FDEBUG( counter.tic() );
FDEBUG( counterTime.tic() );
int leafs = 0;
{
......@@ -286,7 +285,7 @@ public:
const int heightMinusOne = OctreeHeight - 1;
FDEBUG(computationCounter.tic());
#pragma omp parallel num_threads(NbThreads)
#pragma omp parallel num_threads(FThreadNumbers)
{
Kernel * const myThreadkernels = kernels[omp_get_thread_num()];
// There is a maximum of 26 neighbors
......@@ -302,8 +301,8 @@ public:
}
FDEBUG(computationCounter.tac());
FDEBUG( counter.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counter.elapsed() << "s)\n" );
FDEBUG( counterTime.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" );
FDEBUG( FDebug::Controller << "\t\t Computation : " << computationCounter.elapsed() << " s\n" );
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
}
......
......@@ -6,6 +6,7 @@
#include "../Utils/FDebug.hpp"
#include "../Utils/FTrace.hpp"
#include "../Utils/FTic.hpp"
#include "../Utils/FGlobal.hpp"
#include "../Containers/FOctree.hpp"
......@@ -30,12 +31,10 @@ class FFMMAlgorithmTask : protected FAssertable{
typedef FOctree<ParticuleClass, CellClass, OctreeHeight, SubtreeHeight> Octree;
typedef typename FOctree<ParticuleClass, CellClass, OctreeHeight, SubtreeHeight>::Iterator FOctreeIterator;
static const int NbThreads = 4; //< Number of threads (currently a static number)
Octree* const tree; //< The octree to work on
KernelClass<ParticuleClass, CellClass, OctreeHeight>* kernels[NbThreads]; //< The kernels
KernelClass<ParticuleClass, CellClass, OctreeHeight>* kernels[FThreadNumbers]; //< The kernels
FDEBUG(FTic counter); //< In case of debug: to count the elapsed time
FDEBUG(FTic counterTime); //< In case of debug: to count the elapsed time
public:
/** The constructor need the octree and the kernels used for computation
......@@ -49,7 +48,7 @@ public:
assert(tree, "tree cannot be null", __LINE__, __FILE__);
assert(kernels, "kernels cannot be null", __LINE__, __FILE__);
for(int idxThread = 0 ; idxThread < NbThreads ; ++idxThread){
for(int idxThread = 0 ; idxThread < FThreadNumbers ; ++idxThread){
this->kernels[idxThread] = new KernelClass<ParticuleClass, CellClass, OctreeHeight>(*inKernels);
}
......@@ -58,7 +57,7 @@ public:
/** Default destructor */
virtual ~FFMMAlgorithmTask(){
for(int idxThread = 0 ; idxThread < NbThreads ; ++idxThread){
for(int idxThread = 0 ; idxThread < FThreadNumbers ; ++idxThread){
delete this->kernels[idxThread];
}
}
......@@ -70,7 +69,7 @@ public:
void execute(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
for(int idxThread = 0 ; idxThread < NbThreads ; ++idxThread){
for(int idxThread = 0 ; idxThread < FThreadNumbers ; ++idxThread){
this->kernels[idxThread]->init();
}
......@@ -87,9 +86,9 @@ public:
void bottomPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Bottom Pass\n").write(FDebug::Flush) );
FDEBUG( counter.tic() );
FDEBUG( counterTime.tic() );
#pragma omp parallel num_threads(NbThreads)
#pragma omp parallel num_threads(FThreadNumbers)
{
#pragma omp single
{
......@@ -107,8 +106,8 @@ public:
}
}
FDEBUG( counter.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counter.elapsed() << "s)\n" );
FDEBUG( counterTime.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" );
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
}
......@@ -116,10 +115,10 @@ public:
void upwardPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Upward Pass\n").write(FDebug::Flush); );
FDEBUG( counter.tic() );
FDEBUG( counterTime.tic() );
#pragma omp parallel num_threads(NbThreads)
#pragma omp parallel num_threads(FThreadNumbers)
{
#pragma omp single
{
......@@ -152,8 +151,8 @@ public:
}
}
FDEBUG( counter.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counter.elapsed() << "s)\n" );
FDEBUG( counterTime.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" );
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
}
......@@ -162,9 +161,9 @@ public:
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
{ // first M2L
FDEBUG( FDebug::Controller.write("\tStart Downward Pass (M2L)\n").write(FDebug::Flush); );
FDEBUG( counter.tic() );
FDEBUG( counterTime.tic() );
#pragma omp parallel num_threads(NbThreads)
#pragma omp parallel num_threads(FThreadNumbers)
{
#pragma omp single
{
......@@ -193,14 +192,14 @@ public:
}
}
}
FDEBUG( counter.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counter.elapsed() << "s)\n" );
FDEBUG( counterTime.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" );
}
{ // second L2L
FDEBUG( FDebug::Controller.write("\tStart Downward Pass (L2L)\n").write(FDebug::Flush); );
FDEBUG( counter.tic() );
#pragma omp parallel num_threads(NbThreads)
FDEBUG( counterTime.tic() );
#pragma omp parallel num_threads(FThreadNumbers)
{
#pragma omp single
{
......@@ -228,8 +227,8 @@ public:
}
}
}
FDEBUG( counter.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counter.elapsed() << "s)\n" );
FDEBUG( counterTime.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" );
}
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
......@@ -239,9 +238,9 @@ public:
void directPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Direct Pass\n").write(FDebug::Flush); );
FDEBUG( counter.tic() );
FDEBUG( counterTime.tic() );
#pragma omp parallel num_threads(NbThreads)
#pragma omp parallel num_threads(FThreadNumbers)
{
#pragma omp single
{
......@@ -263,8 +262,8 @@ public:
} while(octreeIterator.moveRight());
}
}
FDEBUG( counter.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counter.elapsed() << "s)\n" );
FDEBUG( counterTime.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" );
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
}
......
......@@ -6,6 +6,7 @@
#include "../Utils/FDebug.hpp"
#include "../Utils/FTrace.hpp"
#include "../Utils/FTic.hpp"
#include "../Utils/FGlobal.hpp"
#include "../Containers/FOctree.hpp"
......@@ -29,12 +30,10 @@ class FFMMAlgorithmThreaded : protected FAssertable{
typedef FOctree<ParticuleClass, CellClass, OctreeHeight, SubtreeHeight> Octree;
typedef typename FOctree<ParticuleClass, CellClass, OctreeHeight, SubtreeHeight>::Iterator FOctreeIterator;
static const int NbThreads = 4; //< Number of threads (currently a static number)
KernelClass<ParticuleClass, CellClass, OctreeHeight>* kernels[NbThreads]; //< The kernels (one by thread)
KernelClass<ParticuleClass, CellClass, OctreeHeight>* kernels[FThreadNumbers]; //< The kernels (one by thread)
Octree* const tree; //< The octree to work on
FDEBUG(FTic counter); //< In case of debug count the time
FDEBUG(FTic counterTime); //< In case of debug count the time
public:
/** The constructor need the octree and the kernels used for computation
......@@ -49,7 +48,7 @@ public:
assert(tree, "tree cannot be null", __LINE__, __FILE__);
assert(kernels, "kernels cannot be null", __LINE__, __FILE__);
for(int idxThread = 0 ; idxThread < NbThreads ; ++idxThread){
for(int idxThread = 0 ; idxThread < FThreadNumbers ; ++idxThread){
this->kernels[idxThread] = new KernelClass<ParticuleClass, CellClass, OctreeHeight>(*inKernels);
}
......@@ -58,7 +57,7 @@ public:
/** Default destructor */
virtual ~FFMMAlgorithmThreaded(){
for(int idxThread = 0 ; idxThread < NbThreads ; ++idxThread){
for(int idxThread = 0 ; idxThread < FThreadNumbers ; ++idxThread){
delete this->kernels[idxThread];
}
}
......@@ -69,7 +68,7 @@ public:
void execute(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
for(int idxThread = 0 ; idxThread < NbThreads ; ++idxThread){
for(int idxThread = 0 ; idxThread < FThreadNumbers ; ++idxThread){
this->kernels[idxThread]->init();
}
......@@ -86,7 +85,7 @@ public:
void bottomPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Bottom Pass\n").write(FDebug::Flush) );
FDEBUG( counter.tic() );
FDEBUG( counterTime.tic() );
FOctreeIterator octreeIterator(tree);
// Iterate on leafs
......@@ -95,7 +94,7 @@ public:
omp_lock_t mutex;
omp_init_lock(&mutex);
bool stop = false;
#pragma omp parallel shared(octreeIterator,mutex,stop) num_threads(NbThreads)
#pragma omp parallel shared(octreeIterator,mutex,stop) num_threads(FThreadNumbers)
{
const int threadId = omp_get_thread_num();
omp_set_lock(&mutex);
......@@ -115,8 +114,8 @@ public:
}
omp_destroy_lock(&mutex);
FDEBUG( counter.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counter.elapsed() << "s)\n" );
FDEBUG( counterTime.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" );
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
}
......@@ -124,7 +123,7 @@ public:
void upwardPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Upward Pass\n").write(FDebug::Flush); );
FDEBUG( counter.tic() );
FDEBUG( counterTime.tic() );
FOctreeIterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
......@@ -135,7 +134,7 @@ public:
// for each levels
for(int idxLevel = OctreeHeight - 2 ; idxLevel > 1 ; --idxLevel ){
bool stop = false;
#pragma omp parallel shared(octreeIterator,mutex,stop) num_threads(NbThreads)
#pragma omp parallel shared(octreeIterator,mutex,stop) num_threads(FThreadNumbers)
{
const int threadId = omp_get_thread_num();
omp_set_lock(&mutex);
......@@ -159,8 +158,8 @@ public:
}
omp_destroy_lock(&mutex);
FDEBUG( counter.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counter.elapsed() << "s)\n" );
FDEBUG( counterTime.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" );
FTRACE( FTrace::Controller.leaveFunction(FTrace::FMM) );
}
......@@ -168,7 +167,7 @@ public:
void downardPass(){
FTRACE( FTrace::Controller.enterFunction(FTrace::FMM, __FUNCTION__ , __FILE__ , __LINE__) );
FDEBUG( FDebug::Controller.write("\tStart Downward Pass (M2L)\n").write(FDebug::Flush); );
FDEBUG( counter.tic() );
FDEBUG( counterTime.tic() );
{ // first M2L
FOctreeIterator octreeIterator(tree);
......@@ -180,7 +179,7 @@ public:
// for each levels
for(int idxLevel = 2 ; idxLevel < OctreeHeight ; ++idxLevel ){
bool stop = false;
#pragma omp parallel shared(octreeIterator,mutex,idxLevel,stop) num_threads(NbThreads)
#pragma omp parallel shared(octreeIterator,mutex,idxLevel,stop) num_threads(FThreadNumbers)
{
const int threadId = omp_get_thread_num();
CellClass* neighbors[208];
......@@ -204,11 +203,11 @@ public:
}
omp_destroy_lock(&mutex);
}
FDEBUG( counter.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counter.elapsed() << "s)\n" );
FDEBUG( counterTime.tac() );
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.elapsed() << "s)\n" );
FDEBUG( FDebug::Controller.write("\tStart Downward Pass (L2L)\n").write(FDebug::Flush); );
FDEBUG( counter.tic() );
FDEBUG( counterTime.tic() );
{ // second L2L
FOctreeIterator octreeIterator(tree);
octreeIterator.moveDown();
......@@ -219,7 +218,7 @@ public:
// for each levels exepted leaf level
for(int idxLevel = 2 ; idxLevel < heightMinusOne ; ++idxLevel ){
bool stop = false;
#pragma omp parallel shared(octreeIterator,mutex,idxLevel,stop) num_threads(NbThreads)
#pragma omp parallel shared(octreeIterator,mutex,idxLevel,stop) num_threads(FThreadNumbers)
{