From 893739abfa24467f93fef970a0fe1f3ac7b473ab Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 9 Mar 2018 14:59:05 +0100 Subject: [PATCH] BUG: #1526: use the defaultRAM with extended filenames, always cast sizevalue to uint --- .../IO/ImageIO/include/otbImageFileWriter.txx | 38 +++++++++++------- .../include/otbSimpleParallelTiffWriter.txx | 39 ++++++++++++------- 2 files changed, 48 insertions(+), 29 deletions(-) diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index b1472291f1..7649a80bf1 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -300,11 +300,17 @@ ImageFileWriter<TInputImage> sizemode = m_FilenameHelper->GetStreamingSizeMode(); } - double sizevalue = 0.; + unsigned int sizevalue = 0; + // Save the DefaultRAM value for later + unsigned int oldDefaultRAM = m_StreamingManager->GetDefaultRAM(); + if (sizemode == "auto") + { + sizevalue = oldDefaultRAM; + } if(m_FilenameHelper->StreamingSizeValueIsSet()) { - sizevalue = m_FilenameHelper->GetStreamingSizeValue(); + sizevalue = static_cast<unsigned int>(m_FilenameHelper->GetStreamingSizeValue()); } if(type == "auto") @@ -313,7 +319,7 @@ ImageFileWriter<TInputImage> { itkWarningMacro(<<"In auto streaming type, the sizemode option will be ignored."); } - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("sizemode is auto but sizevalue is 0. Value will be fetched from the OTB_MAX_RAM_HINT environment variable if set, or else use the default value"); } @@ -323,7 +329,7 @@ ImageFileWriter<TInputImage> { if(sizemode == "auto") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("sizemode is auto but sizevalue is 0. Value will be fetched from the OTB_MAX_RAM_HINT environment variable if set, or else use the default value"); } @@ -331,27 +337,27 @@ ImageFileWriter<TInputImage> } else if(sizemode == "nbsplits") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("Streaming sizemode is set to nbsplits but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } - this->SetNumberOfDivisionsTiledStreaming(static_cast<unsigned int>(sizevalue)); + this->SetNumberOfDivisionsTiledStreaming(sizevalue); } else if(sizemode == "height") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("Streaming sizemode is set to height but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } - this->SetTileDimensionTiledStreaming(static_cast<unsigned int>(sizevalue)); + this->SetTileDimensionTiledStreaming(sizevalue); } } else if(type == "stripped") { if(sizemode == "auto") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("sizemode is auto but sizevalue is 0. Value will be fetched from configuration file if any, or from cmake configuration otherwise."); } @@ -360,30 +366,34 @@ ImageFileWriter<TInputImage> } else if(sizemode == "nbsplits") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("Streaming sizemode is set to nbsplits but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } - this->SetNumberOfDivisionsStrippedStreaming(static_cast<unsigned int>(sizevalue)); + this->SetNumberOfDivisionsStrippedStreaming(sizevalue); } else if(sizemode == "height") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("Streaming sizemode is set to height but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } - this->SetNumberOfLinesStrippedStreaming(static_cast<unsigned int>(sizevalue)); + this->SetNumberOfLinesStrippedStreaming(sizevalue); } } else if (type == "none") { - if(sizemode!="" || sizevalue!=0.) + if(sizemode!="" || sizevalue!=0) { itkWarningMacro("Streaming is explicitly disabled, sizemode and sizevalue will be ignored."); } this->SetNumberOfDivisionsTiledStreaming(0); } + + // since we change the m_StreamingManager under the hood, we copy the DefaultRAM + // value to the new streamingManager. + m_StreamingManager->SetDefaultRAM(oldDefaultRAM); } else { diff --git a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx index 96cbf7120c..01fd32f266 100644 --- a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx +++ b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx @@ -315,11 +315,16 @@ SimpleParallelTiffWriter<TInputImage> sizemode = m_FilenameHelper->GetStreamingSizeMode(); } - double sizevalue = 0.; - + unsigned int sizevalue = 0; + // Save the DefaultRAM value for later + unsigned int oldDefaultRAM = m_StreamingManager->GetDefaultRAM(); + if (sizemode == "auto") + { + sizevalue = oldDefaultRAM; + } if(m_FilenameHelper->StreamingSizeValueIsSet()) { - sizevalue = m_FilenameHelper->GetStreamingSizeValue(); + sizevalue = static_cast<unsigned int>(m_FilenameHelper->GetStreamingSizeValue()); } if(type == "auto") @@ -328,7 +333,7 @@ SimpleParallelTiffWriter<TInputImage> { itkWarningMacro(<<"In auto streaming type, the sizemode option will be ignored."); } - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("sizemode is auto but sizevalue is 0. Value will be fetched from configuration file if any, or from cmake configuration otherwise."); } @@ -338,7 +343,7 @@ SimpleParallelTiffWriter<TInputImage> { if(sizemode == "auto") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("sizemode is auto but sizevalue is 0. Value will be fetched from configuration file if any, or from cmake configuration otherwise."); } @@ -346,27 +351,27 @@ SimpleParallelTiffWriter<TInputImage> } else if(sizemode == "nbsplits") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("Streaming sizemode is set to nbsplits but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } - this->SetNumberOfDivisionsTiledStreaming(static_cast<unsigned int>(sizevalue)); + this->SetNumberOfDivisionsTiledStreaming(sizevalue); } else if(sizemode == "height") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("Streaming sizemode is set to height but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } - this->SetTileDimensionTiledStreaming(static_cast<unsigned int>(sizevalue)); + this->SetTileDimensionTiledStreaming(sizevalue); } } else if(type == "stripped") { if(sizemode == "auto") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("sizemode is auto but sizevalue is 0. Value will be fetched from configuration file if any, or from cmake configuration otherwise."); } @@ -375,30 +380,34 @@ SimpleParallelTiffWriter<TInputImage> } else if(sizemode == "nbsplits") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("Streaming sizemode is set to nbsplits but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } - this->SetNumberOfDivisionsStrippedStreaming(static_cast<unsigned int>(sizevalue)); + this->SetNumberOfDivisionsStrippedStreaming(sizevalue); } else if(sizemode == "height") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("Streaming sizemode is set to height but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } - this->SetNumberOfLinesStrippedStreaming(static_cast<unsigned int>(sizevalue)); + this->SetNumberOfLinesStrippedStreaming(sizevalue); } } else if (type == "none") { - if(sizemode!="" || sizevalue!=0.) + if(sizemode!="" || sizevalue!=0) { itkWarningMacro("Streaming is explicitly disabled, sizemode and sizevalue will be ignored."); } this->SetNumberOfDivisionsTiledStreaming(0); } + + // since we change the m_StreamingManager under the hood, we copy the DefaultRAM + // value to the new streamingManager. + m_StreamingManager->SetDefaultRAM(oldDefaultRAM); } else { -- GitLab