From d1d34cb05f2d471c3260d326493b9709b1ec062c Mon Sep 17 00:00:00 2001 From: remicres <remi.cresson@teledetection.fr> Date: Tue, 6 Sep 2016 13:15:09 +0000 Subject: [PATCH] ADD: Function dedicated to availaible memory in controller --- include/lsgrmController.h | 1 + include/lsgrmController.txx | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/lsgrmController.h b/include/lsgrmController.h index ee768a0..9550c32 100644 --- a/include/lsgrmController.h +++ b/include/lsgrmController.h @@ -89,6 +89,7 @@ private: void GetAutomaticConfiguration(); void ComputeMaximumStabilityMargin(unsigned int width, unsigned int height, unsigned int &iter, unsigned int &margin); + void CheckMemorySize(); unsigned int GetNodeMemory(); long unsigned int GetMaximumNumberOfNodesInMemory(); diff --git a/include/lsgrmController.txx b/include/lsgrmController.txx index bfc1887..c5a8708 100644 --- a/include/lsgrmController.txx +++ b/include/lsgrmController.txx @@ -39,6 +39,8 @@ void Controller<TSegmenter>::RunSegmentation() { itkDebugMacro(<< "Entering RunSegmentation()"); + CheckMemorySize(); + if (m_TilingMode == LSGRM_TILING_AUTO || m_TilingMode == LSGRM_TILING_USER) { if(m_TilingMode == LSGRM_TILING_AUTO) @@ -252,23 +254,25 @@ unsigned int Controller<TSegmenter>::GetNodeMemory() return memory; } -/* - * Compute the maximum number of nodes which can fit in the system memory - */ template<class TSegmenter> -long unsigned int Controller<TSegmenter>::GetMaximumNumberOfNodesInMemory() +void Controller<TSegmenter>::CheckMemorySize() { - itkDebugMacro(<< "Computing maximum number of nodes in memory"); - if (m_Memory == 0) { m_Memory = getMemorySize(); assert(m_Memory > 0); } m_Memory /= 2; // For safety and can prevent out of memory troubles +} +/* + * Compute the maximum number of nodes which can fit in the memory + */ +template<class TSegmenter> +long unsigned int Controller<TSegmenter>::GetMaximumNumberOfNodesInMemory() +{ + itkDebugMacro(<< "Computing maximum number of nodes in memory"); return std::ceil(((float) m_Memory) / ((float) GetNodeMemory())); - } template<class TSegmenter> -- GitLab