Commit d7071c37 authored by remicres's avatar remicres

ADD: memory parameter can be specified for each tiling mode (auto/none/user)

parent b47a8806
......@@ -103,8 +103,10 @@ private:
AddParameter(ParameterType_Int, "tiling.user.sizex", "Tiles width");
AddParameter(ParameterType_Int, "tiling.user.sizey", "Tiles height");
AddParameter(ParameterType_Int, "tiling.user.nfirstiter", "Number of first iterations");
AddParameter(ParameterType_Int, "tiling.user.memory", "Available memory");
AddChoice("tiling.none", "No tiling layout");
AddParameter(ParameterType_Int, "memory", "Restrict memory use (mb)");
MandatoryOff("memory");
}
void DoUpdateParameters()
......@@ -184,7 +186,6 @@ private:
controller->SetTileWidth(GetParameterInt("tiling.user.sizex"));
controller->SetTileHeight(GetParameterInt("tiling.user.sizey"));
controller->SetNumberOfFirstIterations(GetParameterInt("tiling.user.nfirstiter"));
controller->SetInternalMemoryAvailable(GetParameterInt("tiling.user.memory"));
}
else if (inputTilingMode == TILING_NONE)
{
......@@ -193,7 +194,14 @@ private:
}
else
{
otbAppLogFATAL("Unknow tiling mode!");
otbAppLogFATAL("Unknown tiling mode!");
}
// Input RAM value?
if (HasValue("memory"))
{
otbAppLogINFO("Setting maximum memory to " << GetParameterInt("memory") << " MBytes");
controller->SetInternalMemoryAvailable(GetParameterInt("memory"));
}
// Run the segmentation
......
......@@ -260,9 +260,11 @@ long unsigned int Controller<TSegmenter>::GetMaximumNumberOfNodesInMemory()
{
itkDebugMacro(<< "Computing maximum number of nodes in memory");
m_Memory = getMemorySize();
assert(m_Memory > 0);
if (m_Memory == 0)
{
m_Memory = getMemorySize();
assert(m_Memory > 0);
}
m_Memory /= 2; // For safety and can prevent out of memory troubles
return std::ceil(((float) m_Memory) / ((float) GetNodeMemory()));
......@@ -412,7 +414,10 @@ void Controller<TSegmenter>::GetAutomaticConfiguration()
template <class TSegmenter>
void Controller<TSegmenter>::SetInternalMemoryAvailable(long long unsigned int v) // expecting a value in Mbytes.
{
assert(v > 0);
if (v<=0)
{
itkExceptionMacro(<<"Memory value is not valid (value=" << v << ")");
}
m_Memory = v * 1024ul * 1024ul;
}
......
Markdown is supported
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