Commit 3b8b97a3 authored by Ludovic Hussonnois's avatar Ludovic Hussonnois

Revert Log and Test for fft random segfault.

This reverts commits:
3d4ab1ff
2dc562e6
parent 3d4ab1ff
......@@ -27,7 +27,6 @@
#include <itkInverseFFTImageFilter.h>
#include <itkUnaryFunctorImageFilter.h>
#include <itkFFTShiftImageFilter.h>
#include <itkFFTWGlobalConfiguration.h>
#include "otbComplexToVectorImageCastFilter.h"
......@@ -80,25 +79,17 @@ private:
~DomainTransform() ITK_OVERRIDE
{
}
void CleanupFFTWThreads()
{
std::cout << "Start cleanup threads" << std::endl;
// This is a trick to make sure fftw will cleanup its threads when application
// shared lib is released.
#if defined(ITK_USE_FFTWF)
std::cout << "ITK_USE_FFTWF" << std::endl;
fftwf_cleanup_threads();
fftwf_cleanup();
#endif
#if defined(ITK_USE_FFTWD)
std::cout << "ITK_USE_FFTWD" << std::endl;
fftw_cleanup_threads();
fftw_cleanup();
#endif
std::cout << "End cleanup threads" << std::endl;
}
}
void DoInit() ITK_OVERRIDE
{
......@@ -261,10 +252,9 @@ private:
// fft ttransform
bool shift = IsParameterEnabled( "mode.fft.shift");
typedef otb::Image< std::complex<OutputPixelType> > ComplexOutputImageType;
if (dir == 0 )
{
otbAppLogINFO( << "Forward FFT" );
//forward fft
typedef otb::Image<InputPixelType> TInputImage;
typedef TInputImage::Pointer TInputImagePointer;
......@@ -278,7 +268,7 @@ private:
FFTFilter::Pointer fwdFilter = FFTFilter::New();
fwdFilter->SetInput( inImage );
//typedef VectorImage for output of UnaryFunctorImageFilter
typedef otb::VectorImage<OutputPixelType> TOutputImage;
......@@ -286,7 +276,7 @@ private:
ComplexOutputImageType,
TOutputImage > ComplexToVectorImageCastFilter;
ComplexToVectorImageCastFilter::Pointer unaryFunctorImageFilter = ComplexToVectorImageCastFilter::New();
if( shift)
{
otbAppLogINFO( << "Applying Shift image filter" );
......@@ -314,7 +304,6 @@ private:
}
else
{
otbAppLogINFO( << "Inverse FFT" );
//inverse fft
typedef otb::VectorImage<InputPixelType> TInputImage;
typedef TInputImage::Pointer TInputImagePointer;
......@@ -327,7 +316,7 @@ private:
std::complex<InputPixelType>, 2 > TComplexImage;
//typedef TOutputImage for InverseFFTImageFilter output
typedef otb::Image< OutputPixelType > TOutputImage;
// a unary functor to convert vectorimage to complex image
typedef itk::UnaryFunctorImageFilter
<TInputImage,
......@@ -341,7 +330,6 @@ private:
if( shift)
{
otbAppLogINFO( << "Applying Shift image filter" );
typedef itk::FFTShiftImageFilter<
TInputImage,
TInputImage > FFTShiftFilterType;
......@@ -373,9 +361,6 @@ private:
SetParameterOutputImage<TOutputImage>("out", invFilter->GetOutput());
}
}
// at the end, cleanup FFTW Threads
CleanupFFTWThreads();
}
template<otb::Wavelet::Wavelet TWaveletOperator>
......
......@@ -26,29 +26,13 @@ otb_test_application(NAME apTvDomainTransform_fft_shift_fwd
-dir fwd
-out ${TEMP}/apTvDomainTransform_fft_shift_fwd.tif
)
otb_test_application(NAME apTvDomainTransform_fft_fwd
APP DomainTransform
OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif
-mode fft
-dir fwd
-out ${TEMP}/apTvDomainTransform_fft_fwd.tif
)
otb_test_application(NAME apTvDomainTransform_fft_shift_inv
APP DomainTransform
OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif
-mode fft
-mode.fft.shift true
-dir inv
-out ${TEMP}/apTvDomainTransform_fft_shift_inv.tif
)
otb_test_application(NAME apTvDomainTransform_fft_inv
APP DomainTransform
OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif
-mode fft
-dir inv
-out ${TEMP}/apTvDomainTransform_fft_inv.tif
-out ${TEMP}/apTvDomainTransform_fft_shift_inv.tif
)
......@@ -424,7 +424,6 @@ int main(int ac, char* av[])
std::cout << "------------- End control baseline tests -------------" << std::endl;
#ifdef OTB_USE_MPI
otb::MPIConfig::Instance()->terminate();
}
#endif
return result;
......
......@@ -53,9 +53,6 @@ public:
/** Initialize MPI Processus */
void Init(int& argc, char** &argv, bool abortOnException = true);
/** Shuts down the MPI environment. */
void terminate();
/** Abort all MPI processus. */
void abort(int errCode);
......@@ -88,8 +85,6 @@ private:
bool m_abortOnException;
// Boolean to test if the MPI environment is initialized
bool m_initialized;
// Boolean to test if the MPI environment is terminated
bool m_terminated;
static Pointer m_Singleton;
};
......
......@@ -77,94 +77,71 @@ MPIConfig::Pointer MPIConfig::Instance()
/** CreateInitialize MPI environment */
MPIConfig::MPIConfig()
: m_MyRank(0),
: m_MyRank(-1),
m_NbProcs(0),
m_abortOnException(true),
m_initialized(false),
m_terminated(false)
m_initialized(false)
{
}
/** Shuts down the MPI environment. */
MPIConfig::~MPIConfig()
{
terminate();
if (m_initialized)
{
if (std::uncaught_exception() && m_abortOnException)
{
abort(EXIT_FAILURE);
}
else
{
int finalized;
OTB_MPI_CHECK_RESULT(MPI_Finalized,(&finalized));
if (!finalized)
{
OTB_MPI_CHECK_RESULT(MPI_Finalize,());
}
}
}
}
/** Initialize MPI environment */
void MPIConfig::Init(int &argc, char **&argv, bool abortOnException) {
if( !m_terminated )
{
std::cout << "MPI Initialization : " << this << std::endl;
std::flush(std::cout);
// Abort on exception
m_abortOnException = abortOnException;
// Initialize
int initialized;
OTB_MPI_CHECK_RESULT( MPI_Initialized, ( &initialized ));
m_initialized = ( initialized == 1 );
if( !m_initialized )
{
OTB_MPI_CHECK_RESULT( MPI_Init, ( &argc, &argv ));
m_initialized = true;
}
// Get MPI rank
int irank = 0;
OTB_MPI_CHECK_RESULT( MPI_Comm_rank, ( MPI_COMM_WORLD, &irank ));
void MPIConfig::Init(int& argc, char** &argv, bool abortOnException) {
// Abort on exception
m_abortOnException = abortOnException;
// Initialize
int initialized;
OTB_MPI_CHECK_RESULT(MPI_Initialized,(&initialized));
m_initialized = (initialized == 1);
if (!m_initialized) {
OTB_MPI_CHECK_RESULT(MPI_Init, (&argc, &argv));
m_initialized = true;
}
// Get MPI rank
int irank = 0;
OTB_MPI_CHECK_RESULT(MPI_Comm_rank, (MPI_COMM_WORLD , &irank));
if( irank < 0 )
{
logError( "Negative MPI rank" );
abort( EXIT_FAILURE );
}
if(irank<0)
{
logError("Negative MPI rank");
abort(EXIT_FAILURE);
}
m_MyRank = static_cast<unsigned int>(irank);
m_MyRank = static_cast<unsigned int>(irank);
// Get MPI NbProocs
// Get MPI NbProocs
int inbprocs = 0;
int inbprocs=0;
OTB_MPI_CHECK_RESULT( MPI_Comm_size, ( MPI_COMM_WORLD, &inbprocs ));
OTB_MPI_CHECK_RESULT(MPI_Comm_size, (MPI_COMM_WORLD , &inbprocs));
if( inbprocs < 1 )
{
logError( "Negative or null number of processes" );
abort( EXIT_FAILURE );
}
if(inbprocs<1)
{
logError("Negative or null number of processes");
abort(EXIT_FAILURE);
}
m_NbProcs = static_cast<unsigned int>(inbprocs);
}
}
/** Shuts down the MPI environment. */
void MPIConfig::terminate()
{
if( m_initialized && !m_terminated )
{
std::cout << "Terminate : " << this << std::endl;
std::flush(std::cout);
if( std::uncaught_exception() && m_abortOnException )
{
std::cout << "Abord" << std::endl;
abort( EXIT_FAILURE );
}
else
{
std::cout << "Start Finalize MPI" << std::endl;
std::flush( std::cout );
int finalized;
OTB_MPI_CHECK_RESULT( MPI_Finalized, ( &finalized ));
if( !finalized )
{
std::cout << "Start 2nd End Finalize MPI" << std::endl;
//OTB_MPI_CHECK_RESULT( MPI_Finalize, ( ));
std::cout << "End 2nd Finalize MPI" << std::endl;
}
std::cout << "End Finalize MPI" << std::endl;
std::flush( std::cout );
}
m_terminated = true;
}
m_NbProcs = static_cast<unsigned int>(inbprocs);
}
void MPIConfig::abort(int errCode)
......
......@@ -303,13 +303,19 @@ int main(int argc, char* argv[])
LauncherType::Pointer launcher = LauncherType::New();
//if (launcher->Load(exp) == true)
bool sucess = launcher->Load(vexp) && launcher->ExecuteAndWriteOutput();
if (launcher->Load(vexp) == true)
{
if (launcher->ExecuteAndWriteOutput() == false)
{
return EXIT_FAILURE;
}
}
else
{
return EXIT_FAILURE;
}
// shutdown MPI after application finished
#ifdef OTB_USE_MPI
otb::MPIConfig::Instance()->terminate();
#endif
return sucess ? EXIT_SUCCESS : EXIT_FAILURE;
return EXIT_SUCCESS;
}
const std::string GetChildNodeTextOf(TiXmlElement *parentElement, std::string key)
......
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