Commit d1d34cb0 authored by remicres's avatar remicres
Browse files

ADD: Function dedicated to availaible memory in controller

Showing with 12 additions and 7 deletions
+12 -7
...@@ -89,6 +89,7 @@ private: ...@@ -89,6 +89,7 @@ private:
void GetAutomaticConfiguration(); void GetAutomaticConfiguration();
void ComputeMaximumStabilityMargin(unsigned int width, unsigned int height, unsigned int &iter, unsigned int &margin); void ComputeMaximumStabilityMargin(unsigned int width, unsigned int height, unsigned int &iter, unsigned int &margin);
void CheckMemorySize();
unsigned int GetNodeMemory(); unsigned int GetNodeMemory();
long unsigned int GetMaximumNumberOfNodesInMemory(); long unsigned int GetMaximumNumberOfNodesInMemory();
......
...@@ -39,6 +39,8 @@ void Controller<TSegmenter>::RunSegmentation() ...@@ -39,6 +39,8 @@ void Controller<TSegmenter>::RunSegmentation()
{ {
itkDebugMacro(<< "Entering RunSegmentation()"); itkDebugMacro(<< "Entering RunSegmentation()");
CheckMemorySize();
if (m_TilingMode == LSGRM_TILING_AUTO || m_TilingMode == LSGRM_TILING_USER) if (m_TilingMode == LSGRM_TILING_AUTO || m_TilingMode == LSGRM_TILING_USER)
{ {
if(m_TilingMode == LSGRM_TILING_AUTO) if(m_TilingMode == LSGRM_TILING_AUTO)
...@@ -252,23 +254,25 @@ unsigned int Controller<TSegmenter>::GetNodeMemory() ...@@ -252,23 +254,25 @@ unsigned int Controller<TSegmenter>::GetNodeMemory()
return memory; return memory;
} }
/*
* Compute the maximum number of nodes which can fit in the system memory
*/
template<class TSegmenter> 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) if (m_Memory == 0)
{ {
m_Memory = getMemorySize(); m_Memory = getMemorySize();
assert(m_Memory > 0); assert(m_Memory > 0);
} }
m_Memory /= 2; // For safety and can prevent out of memory troubles 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())); return std::ceil(((float) m_Memory) / ((float) GetNodeMemory()));
} }
template<class TSegmenter> template<class TSegmenter>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment