Commit fac94bdc authored by Antoine Regimbeau's avatar Antoine Regimbeau

MRG: Merge branch 'develop' into bug_ExtractROI

parents a21aa081 1eb35e74
......@@ -59,8 +59,15 @@ public:
// Overwrite this to provide custom formatting of log entries
std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) override;
/** Output logs about the RAM, caching and multi-threading settings */
void LogSetupInformation();
/** Return true if the LogSetupInformation has already been called*/
bool IsLogSetupInformationDone();
/** Set the flag m_LogSetupInfoDone to true */
void LogSetupInformationDone();
protected:
Logger();
virtual ~Logger() ITK_OVERRIDE;
......@@ -71,6 +78,8 @@ private:
static Pointer CreateInstance();
bool m_LogSetupInfoDone;
}; // class Logger
} // namespace otb
......
......@@ -38,9 +38,6 @@ Logger::Pointer Logger::CreateInstance()
defaultOutput->SetStream(std::cout);
instance->AddLogOutput(defaultOutput);
// Log setup information
instance->LogSetupInformation();
return instance;
}
......@@ -61,6 +58,8 @@ Logger::Logger()
this->SetTimeStampFormat(itk::LoggerBase::HUMANREADABLE);
this->SetHumanReadableFormat("%Y-%m-%d %H:%M:%S");
m_LogSetupInfoDone = false;
}
Logger::~Logger()
......@@ -69,22 +68,29 @@ Logger::~Logger()
void Logger::LogSetupInformation()
{
std::ostringstream oss;
oss<<"Default RAM limit for OTB is "<<otb::ConfigurationManager::GetMaxRAMHint()<<" MB"<<std::endl;
this->Info(oss.str());
oss.str("");
oss.clear();
oss<<"GDAL maximum cache size is "<<GDALGetCacheMax64()/(1024*1024)<<" MB"<<std::endl;
this->Info(oss.str());
oss.str("");
oss.clear();
oss<<"OTB will use at most "<<itk::MultiThreader::GetGlobalDefaultNumberOfThreads()<<" threads"<<std::endl;
this->Info(oss.str());
oss.str("");
oss.clear();
if (! IsLogSetupInformationDone())
{
std::ostringstream oss;
oss<<"Default RAM limit for OTB is "<<otb::ConfigurationManager::GetMaxRAMHint()<<" MB"<<std::endl;
this->Info(oss.str());
oss.str("");
oss.clear();
oss<<"GDAL maximum cache size is "<<GDALGetCacheMax64()/(1024*1024)<<" MB"<<std::endl;
this->Info(oss.str());
oss.str("");
oss.clear();
oss<<"OTB will use at most "<<itk::MultiThreader::GetGlobalDefaultNumberOfThreads()<<" threads"<<std::endl;
this->Info(oss.str());
oss.str("");
oss.clear();
// only switch the flag for the singleton, so that other instances can call
// LogSetupInformation() several times
Instance()->LogSetupInformationDone();
}
}
std::string Logger::BuildFormattedEntry(itk::Logger::PriorityLevelType level, std::string const & content)
......@@ -116,4 +122,14 @@ std::string Logger::BuildFormattedEntry(itk::Logger::PriorityLevelType level, st
return s.str();
}
bool Logger::IsLogSetupInformationDone()
{
return m_LogSetupInfoDone;
}
void Logger::LogSetupInformationDone()
{
m_LogSetupInfoDone = true;
}
} // namespace otb
......@@ -183,6 +183,8 @@ void
StreamingImageVirtualWriter<TInputImage>
::GenerateData(void)
{
otb::Logger::Instance()->LogSetupInformation();
/**
* Prepare all the outputs. This may deallocate previous bulk data.
*/
......
......@@ -156,7 +156,7 @@ StreamingManager<TImage>::EstimateOptimalNumberOfDivisions(itk::DataObject * inp
unsigned int optimalNumberOfDivisions =
otb::PipelineMemoryPrintCalculator::EstimateOptimalNumberOfStreamDivisions(pipelineMemoryPrint, availableRAMInBytes);
otbLogMacro(Info,<<"Estimated memory for full processing: "<<pipelineMemoryPrint * otb::PipelineMemoryPrintCalculator::ByteToMegabyte<<"MB (avail.: "<<availableRAMInBytes * otb::PipelineMemoryPrintCalculator::ByteToMegabyte<<" NB), optimal image partitioning: "<<optimalNumberOfDivisions<<" blocks");
otbLogMacro(Info,<<"Estimated memory for full processing: "<<pipelineMemoryPrint * otb::PipelineMemoryPrintCalculator::ByteToMegabyte<<"MB (avail.: "<<availableRAMInBytes * otb::PipelineMemoryPrintCalculator::ByteToMegabyte<<" MB), optimal image partitioning: "<<optimalNumberOfDivisions<<" blocks");
return optimalNumberOfDivisions;
}
......
......@@ -380,6 +380,17 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
spacing[i] = 1.0;
}
origin[i] = 0.5*spacing[i];
for (unsigned j = 0; j < TOutputImage::ImageDimension; ++j)
{
if (i == j)
{
direction[j][i] = 1.0;
}
else
{
direction[j][i] = 0.0;
}
}
}
}
......
......@@ -279,6 +279,8 @@ ImageFileWriter<TInputImage>
itkExceptionMacro(<< "No input to writer");
}
otb::Logger::Instance()->LogSetupInformation();
/** Parse streaming modes */
if(m_FilenameHelper->StreamingTypeIsSet())
{
......
......@@ -28,7 +28,7 @@
#include <iostream>
#include "itkMultiThreader.h"
#include "itkMacro.h"
#include "otbMacro.h"
#include "otbOGRDriversInit.h"
#include "otbTestHelper.h"
......@@ -298,6 +298,7 @@ int main(int ac, char* av[])
}
else
{
otb::Logger::Instance()->LogSetupInformation();
MainFuncPointer f = j->second;
int result;
try
......
......@@ -233,7 +233,7 @@ SamplingRateCalculator
std::string::size_type pos5 = line.find_first_not_of(" \t", parts[2].begin() - line.begin());
std::string::size_type pos6 = line.find_last_not_of(" \t", parts[2].end() - line.begin() -1);
std::string::size_type pos7 = line.find_first_not_of(" \t", parts[3].begin() - line.begin());
std::string::size_type pos8 = line.find_last_not_of(" \t", parts[3].end() - line.begin() -1);
std::string::size_type pos8 = line.find_last_not_of(" \t\r", parts[3].end() - line.begin() -1);
if (pos2 != std::string::npos && pos1 <= pos2 &&
pos4 != std::string::npos && pos3 <= pos4 &&
pos6 != std::string::npos && pos5 <= pos6 &&
......@@ -336,7 +336,7 @@ SamplingRateCalculator
std::string::size_type pos1 = line.find_first_not_of(" \t", parts[0].begin() - line.begin());
std::string::size_type pos2 = line.find_last_not_of(" \t", parts[0].end() - line.begin() -1);
std::string::size_type pos3 = line.find_first_not_of(" \t", parts[1].begin() - line.begin());
std::string::size_type pos4 = line.find_last_not_of(" \t", parts[1].end() - line.begin() -1);
std::string::size_type pos4 = line.find_last_not_of(" \t\r", parts[1].end() - line.begin() -1);
if (pos2 != std::string::npos && pos1 <= pos2 &&
pos4 != std::string::npos && pos3 <= pos4)
{
......
......@@ -645,6 +645,8 @@ int Application::ExecuteAndWriteOutput()
{
m_Chrono.Restart();
m_Logger->LogSetupInformation();
int status = this->Execute();
if (status == 0)
......
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