From f8253c7775e0f8c047544f11555ea24fb29f6f36 Mon Sep 17 00:00:00 2001 From: Berenger Bramas <Berenger.Bramas@inria.fr> Date: Fri, 17 Jul 2015 14:10:29 +0200 Subject: [PATCH] Add assertion for the separation criteria --- Src/Core/FFmmAlgorithm.hpp | 1 + Src/Core/FFmmAlgorithmPeriodic.hpp | 1 + Src/Core/FFmmAlgorithmSectionTask.hpp | 1 + Src/Core/FFmmAlgorithmTask.hpp | 9 +++++---- Src/Core/FFmmAlgorithmThread.hpp | 8 +++++--- Src/Core/FFmmAlgorithmThreadBalance.hpp | 7 ++++--- Src/Core/FFmmAlgorithmThreadProc.hpp | 11 ++++++----- Src/Core/FFmmAlgorithmThreadProcPeriodic.hpp | 11 ++++++----- Src/Core/FFmmAlgorithmThreadTsm.hpp | 7 ++++--- Src/Core/FFmmAlgorithmTsm.hpp | 7 ++++--- 10 files changed, 37 insertions(+), 26 deletions(-) diff --git a/Src/Core/FFmmAlgorithm.hpp b/Src/Core/FFmmAlgorithm.hpp index 3a8fffc25..49010c41a 100644 --- a/Src/Core/FFmmAlgorithm.hpp +++ b/Src/Core/FFmmAlgorithm.hpp @@ -62,6 +62,7 @@ public: FAssertLF(tree, "tree cannot be null"); FAssertLF(kernels, "kernels cannot be null"); + FAssertLF(leafLevelSeparationCriteria < 3, "Separation criteria should be < 3"); FAbstractAlgorithm::setNbLevelsInTree(tree->getHeight()); diff --git a/Src/Core/FFmmAlgorithmPeriodic.hpp b/Src/Core/FFmmAlgorithmPeriodic.hpp index bdd5f8cca..41d1b0fbf 100644 --- a/Src/Core/FFmmAlgorithmPeriodic.hpp +++ b/Src/Core/FFmmAlgorithmPeriodic.hpp @@ -67,6 +67,7 @@ public: FAssertLF(tree, "tree cannot be null"); FAssertLF(-1 <= inUpperLevel, "inUpperLevel cannot be < -1"); + FAssertLF(leafLevelSeparationCriteria < 3, "Separation criteria should be < 3"); FAbstractAlgorithm::setNbLevelsInTree(extendedTreeHeight()); diff --git a/Src/Core/FFmmAlgorithmSectionTask.hpp b/Src/Core/FFmmAlgorithmSectionTask.hpp index ebafb2e9c..52c3e9117 100644 --- a/Src/Core/FFmmAlgorithmSectionTask.hpp +++ b/Src/Core/FFmmAlgorithmSectionTask.hpp @@ -74,6 +74,7 @@ public: FAssertLF(tree, "tree cannot be null"); FAssertLF(inKernels, "kernels cannot be null"); + FAssertLF(leafLevelSeparationCriteria < 3, "Separation criteria should be < 3"); this->kernels = new KernelClass*[MaxThreads]; #pragma omp parallel for schedule(static) diff --git a/Src/Core/FFmmAlgorithmTask.hpp b/Src/Core/FFmmAlgorithmTask.hpp index 8d87deaf4..87d190b1d 100644 --- a/Src/Core/FFmmAlgorithmTask.hpp +++ b/Src/Core/FFmmAlgorithmTask.hpp @@ -49,7 +49,7 @@ class FFmmAlgorithmTask : public FAbstractAlgorithm, public FAlgorithmTimers { const int OctreeHeight; - const int leafLevelSeperationCriteria; + const int leafLevelSeparationCriteria; public: /** The constructor need the octree and the kernels used for computation * @param inTree the octree to work on @@ -58,11 +58,12 @@ public: */ FFmmAlgorithmTask(OctreeClass* const inTree, KernelClass* const inKernels, const int inLeafLevelSeperationCriteria = 1) : tree(inTree) , kernels(nullptr), - MaxThreads(omp_get_max_threads()), OctreeHeight(tree->getHeight()), leafLevelSeperationCriteria(inLeafLevelSeperationCriteria) + MaxThreads(omp_get_max_threads()), OctreeHeight(tree->getHeight()), leafLevelSeparationCriteria(inLeafLevelSeperationCriteria) { FAssertLF(tree, "tree cannot be null"); FAssertLF(inKernels, "kernels cannot be null"); + FAssertLF(leafLevelSeparationCriteria < 3, "Separation criteria should be < 3"); this->kernels = new KernelClass*[MaxThreads]; #pragma omp parallel for schedule(static) @@ -239,7 +240,7 @@ protected: // for each levels for(int idxLevel = FAbstractAlgorithm::upperWorkingLevel ; idxLevel < FAbstractAlgorithm::lowerWorkingLevel ; ++idxLevel ){ FLOG(FTic counterTimeLevel); - const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeperationCriteria); + const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeparationCriteria); // for each cell we apply the M2L with all cells in the implicit interaction list do{ #pragma omp task firstprivate(octreeIterator) private(neighbors) shared(idxLevel) @@ -286,7 +287,7 @@ protected: // for each levels for(int idxLevel = FAbstractAlgorithm::upperWorkingLevel ; idxLevel < FAbstractAlgorithm::lowerWorkingLevel ; ++idxLevel ){ FLOG(FTic counterTimeLevel); - const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeperationCriteria); + const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeparationCriteria); // for each cells do{ //#pragma omp task default(none) firstprivate(octreeIterator,separationCriteria) private( neighbors) shared(idxLevel) diff --git a/Src/Core/FFmmAlgorithmThread.hpp b/Src/Core/FFmmAlgorithmThread.hpp index daf2303b0..d01071ebc 100644 --- a/Src/Core/FFmmAlgorithmThread.hpp +++ b/Src/Core/FFmmAlgorithmThread.hpp @@ -62,7 +62,7 @@ class FFmmAlgorithmThread : public FAbstractAlgorithm, public FAlgorithmTimers{ int userChunkSize; - const int leafLevelSeperationCriteria; + const int leafLevelSeparationCriteria; public: /** Class constructor @@ -79,8 +79,10 @@ public: const int inUserChunkSize = 10, const int inLeafLevelSeperationCriteria = 1) : tree(inTree) , kernels(nullptr), iterArray(nullptr), leafsNumber(0), MaxThreads(omp_get_max_threads()), OctreeHeight(tree->getHeight()), - userChunkSize(inUserChunkSize), leafLevelSeperationCriteria(inLeafLevelSeperationCriteria) { + userChunkSize(inUserChunkSize), leafLevelSeparationCriteria(inLeafLevelSeperationCriteria) { FAssertLF(tree, "tree cannot be null"); + FAssertLF(leafLevelSeparationCriteria < 3, "Separation criteria should be < 3"); + FAssertLF(0 < userChunkSize, "Chunk size should be > 0"); this->kernels = new KernelClass*[MaxThreads]; #pragma omp parallel for schedule(static) @@ -296,7 +298,7 @@ protected: // for each levels for(int idxLevel = FAbstractAlgorithm::upperWorkingLevel ; idxLevel < FAbstractAlgorithm::lowerWorkingLevel ; ++idxLevel ){ FLOG(FTic counterTimeLevel); - const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeperationCriteria); + const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeparationCriteria); int numberOfCells = 0; // for each cells do{ diff --git a/Src/Core/FFmmAlgorithmThreadBalance.hpp b/Src/Core/FFmmAlgorithmThreadBalance.hpp index 207ce23fa..e4988637f 100644 --- a/Src/Core/FFmmAlgorithmThreadBalance.hpp +++ b/Src/Core/FFmmAlgorithmThreadBalance.hpp @@ -40,7 +40,7 @@ class FFmmAlgorithmThreadBalance : public FAbstractAlgorithm, public FAlgorithmT const int OctreeHeight; ///< The height of the given tree. - const int leafLevelSeperationCriteria; + const int leafLevelSeparationCriteria; public: /** Class constructor @@ -57,8 +57,9 @@ public: const int inLeafLevelSeperationCriteria = 1) : tree(inTree) , kernels(nullptr), MaxThreads(omp_get_max_threads()), OctreeHeight(tree->getHeight()), - leafLevelSeperationCriteria(inLeafLevelSeperationCriteria) { + leafLevelSeparationCriteria(inLeafLevelSeperationCriteria) { FAssertLF(tree, "tree cannot be null"); + FAssertLF(leafLevelSeparationCriteria < 3, "Separation criteria should be < 3"); this->kernels = new KernelClass*[MaxThreads]; #pragma omp parallel for schedule(static) @@ -543,7 +544,7 @@ protected: // for each levels for(int idxLevel = FAbstractAlgorithm::upperWorkingLevel ; idxLevel < FAbstractAlgorithm::lowerWorkingLevel ; ++idxLevel ){ - const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeperationCriteria); + const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeparationCriteria); FLOG(FTic counterTimeLevel); FLOG(computationCounter.tic()); #pragma omp parallel diff --git a/Src/Core/FFmmAlgorithmThreadProc.hpp b/Src/Core/FFmmAlgorithmThreadProc.hpp index eabe9bdac..f7a3977cf 100644 --- a/Src/Core/FFmmAlgorithmThreadProc.hpp +++ b/Src/Core/FFmmAlgorithmThreadProc.hpp @@ -82,7 +82,7 @@ private: const int idProcess; ///< Current process id const int OctreeHeight; ///< Tree height - const int leafLevelSeperationCriteria; + const int leafLevelSeparationCriteria; /** An interval is the morton index interval * that a proc uses (i.e. it holds data in this interval) */ @@ -150,10 +150,11 @@ public: nbProcess(inComm.processCount()), idProcess(inComm.processId()), OctreeHeight(tree->getHeight()), - leafLevelSeperationCriteria(inLeafLevelSeperationCriteria), + leafLevelSeparationCriteria(inLeafLevelSeperationCriteria), intervals(new Interval[inComm.processCount()]), workingIntervalsPerLevel(new Interval[inComm.processCount() * tree->getHeight()]) { FAssertLF(tree, "tree cannot be null"); + FAssertLF(leafLevelSeparationCriteria < 3, "Separation criteria should be < 3"); this->kernels = new KernelClass*[MaxThreads]; #pragma omp parallel for schedule(static) @@ -663,7 +664,7 @@ protected: // for each levels for(int idxLevel = FAbstractAlgorithm::upperWorkingLevel ; idxLevel < FAbstractAlgorithm::lowerWorkingLevel ; ++idxLevel ){ - const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeperationCriteria); + const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeparationCriteria); if(!procHasWorkAtLevel(idxLevel, idProcess)){ avoidGotoLeftIterator.moveDown(); @@ -821,7 +822,7 @@ protected: // Now we can compute all the data // for each levels for(int idxLevel = FAbstractAlgorithm::upperWorkingLevel ; idxLevel < FAbstractAlgorithm::lowerWorkingLevel ; ++idxLevel ){ - const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeperationCriteria); + const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeparationCriteria); if(!procHasWorkAtLevel(idxLevel, idProcess)){ avoidGotoLeftIterator.moveDown(); @@ -888,7 +889,7 @@ protected: // compute the second time // for each levels for(int idxLevel = FAbstractAlgorithm::upperWorkingLevel ; idxLevel < FAbstractAlgorithm::lowerWorkingLevel ; ++idxLevel ){ - const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeperationCriteria); + const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeparationCriteria); if(!procHasWorkAtLevel(idxLevel, idProcess)){ avoidGotoLeftIterator.moveDown(); diff --git a/Src/Core/FFmmAlgorithmThreadProcPeriodic.hpp b/Src/Core/FFmmAlgorithmThreadProcPeriodic.hpp index e2a0ab116..2779d69aa 100644 --- a/Src/Core/FFmmAlgorithmThreadProcPeriodic.hpp +++ b/Src/Core/FFmmAlgorithmThreadProcPeriodic.hpp @@ -83,7 +83,7 @@ class FFmmAlgorithmThreadProcPeriodic : public FAbstractAlgorithm { const int OctreeHeight; - const int leafLevelSeperationCriteria; + const int leafLevelSeparationCriteria; public: struct Interval{ @@ -146,12 +146,13 @@ public: numberOfLeafs(0), MaxThreads(omp_get_max_threads()), nbProcess(inComm.processCount()), idProcess(inComm.processId()), OctreeHeight(tree->getHeight()), - leafLevelSeperationCriteria(inLeafLevelSeperationCriteria), + leafLevelSeparationCriteria(inLeafLevelSeperationCriteria), intervals(new Interval[inComm.processCount()]), workingIntervalsPerLevel(new Interval[inComm.processCount() * tree->getHeight()]) { FAssertLF(tree, "tree cannot be null"); FAssertLF(-1 <= inUpperLevel, "inUpperLevel cannot be < -1"); + FAssertLF(leafLevelSeparationCriteria < 3, "Separation criteria should be < 3"); FAbstractAlgorithm::setNbLevelsInTree(extendedTreeHeight()); @@ -787,7 +788,7 @@ protected: // Find the M2L neigbors of a cell const int counter = getPeriodicInteractionNeighbors(iterArray[idxCell].getCurrentGlobalCoordinate(), idxLevel, - neighborsIndexes, neighborsPosition, AllDirs, leafLevelSeperationCriteria); + neighborsIndexes, neighborsPosition, AllDirs, leafLevelSeparationCriteria); memset(alreadySent, false, sizeof(bool) * nbProcess); bool needOther = false; @@ -913,7 +914,7 @@ protected: for(int idxLevel = 1 ; idxLevel < OctreeHeight ; ++idxLevel ){ const int fackLevel = idxLevel + offsetRealTree; - const int separationCriteria = (idxLevel != OctreeHeight-1 ? 1 : leafLevelSeperationCriteria); + const int separationCriteria = (idxLevel != OctreeHeight-1 ? 1 : leafLevelSeparationCriteria); if(!procHasWorkAtLevel(idxLevel, idProcess)){ avoidGotoLeftIterator.moveDown(); @@ -981,7 +982,7 @@ protected: for(int idxLevel = 1 ; idxLevel < OctreeHeight ; ++idxLevel ){ const int fackLevel = idxLevel + offsetRealTree; - const int separationCriteria = (fackLevel != OctreeHeight-1 ? 1 : leafLevelSeperationCriteria); + const int separationCriteria = (fackLevel != OctreeHeight-1 ? 1 : leafLevelSeparationCriteria); if(!procHasWorkAtLevel(idxLevel, idProcess)){ avoidGotoLeftIterator.moveDown(); diff --git a/Src/Core/FFmmAlgorithmThreadTsm.hpp b/Src/Core/FFmmAlgorithmThreadTsm.hpp index 6bb6a268a..b731fb399 100644 --- a/Src/Core/FFmmAlgorithmThreadTsm.hpp +++ b/Src/Core/FFmmAlgorithmThreadTsm.hpp @@ -55,7 +55,7 @@ class FFmmAlgorithmThreadTsm : public FAbstractAlgorithm, public FAlgorithmTimer const int OctreeHeight; - const int leafLevelSeperationCriteria; + const int leafLevelSeparationCriteria; public: /** The constructor need the octree and the kernels used for computation @@ -65,9 +65,10 @@ public: */ FFmmAlgorithmThreadTsm(OctreeClass* const inTree, KernelClass* const inKernels, const int inLeafLevelSeperationCriteria = 1) : tree(inTree) , kernels(nullptr), iterArray(nullptr), - MaxThreads(omp_get_max_threads()) , OctreeHeight(tree->getHeight()), leafLevelSeperationCriteria(inLeafLevelSeperationCriteria) { + MaxThreads(omp_get_max_threads()) , OctreeHeight(tree->getHeight()), leafLevelSeparationCriteria(inLeafLevelSeperationCriteria) { FAssertLF(tree, "tree cannot be null"); + FAssertLF(leafLevelSeparationCriteria < 3, "Separation criteria should be < 3"); this->kernels = new KernelClass*[MaxThreads]; #pragma omp parallel for schedule(static) @@ -250,7 +251,7 @@ protected: // for each levels for(int idxLevel = FAbstractAlgorithm::upperWorkingLevel ; idxLevel < FAbstractAlgorithm::lowerWorkingLevel ; ++idxLevel ){ FLOG(FTic counterTimeLevel); - const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeperationCriteria); + const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeparationCriteria); int numberOfCells = 0; // for each cells diff --git a/Src/Core/FFmmAlgorithmTsm.hpp b/Src/Core/FFmmAlgorithmTsm.hpp index 80f238d68..62f0c8c3b 100644 --- a/Src/Core/FFmmAlgorithmTsm.hpp +++ b/Src/Core/FFmmAlgorithmTsm.hpp @@ -46,7 +46,7 @@ class FFmmAlgorithmTsm : public FAbstractAlgorithm{ const int OctreeHeight; - const int leafLevelSeperationCriteria; + const int leafLevelSeparationCriteria; FLOG(FTic counterTime); //< In case of debug: to count the elapsed time FLOG(FTic computationCounter); //< In case of debug: to count computation time @@ -58,10 +58,11 @@ public: * An assert is launched if one of the arguments is null */ FFmmAlgorithmTsm(OctreeClass* const inTree, KernelClass* const inKernels, const int inLeafLevelSeperationCriteria = 1) - : tree(inTree) , kernels(inKernels) , OctreeHeight(tree->getHeight()), leafLevelSeperationCriteria(inLeafLevelSeperationCriteria){ + : tree(inTree) , kernels(inKernels) , OctreeHeight(tree->getHeight()), leafLevelSeparationCriteria(inLeafLevelSeperationCriteria){ FAssertLF(tree, "tree cannot be null"); FAssertLF(kernels, "kernels cannot be null"); + FAssertLF(leafLevelSeparationCriteria < 3, "Separation criteria should be < 3"); FAbstractAlgorithm::setNbLevelsInTree(tree->getHeight()); @@ -200,7 +201,7 @@ protected: // for each levels for(int idxLevel = FAbstractAlgorithm::upperWorkingLevel ; idxLevel < FAbstractAlgorithm::lowerWorkingLevel ; ++idxLevel ){ FLOG(FTic counterTimeLevel); - const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeperationCriteria); + const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeparationCriteria); // for each cells do{ FLOG(computationCounter.tic()); -- GitLab