Commit a3094ea3 authored by Julien Michel's avatar Julien Michel
Browse files

Merge branch 'develop' into dev-sar-s1

parents 23df0397 ecb04107
......@@ -198,3 +198,23 @@ endfunction()
function(otb_memcheck_ignore)
set_property(GLOBAL APPEND PROPERTY CTEST_CUSTOM_MEMCHECK_IGNORE ${ARGN})
endfunction()
#-----------------------------------------------------------------------------
# Function otb_add_test_mpi to run mpi tests
function(otb_add_test_mpi)
set( _OPTIONS_ARGS )
set( _ONE_VALUE_ARGS NAME NBPROCS COMMAND)
set( _MULTI_VALUE_ARGS )
cmake_parse_arguments( TEST_MPI "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
# Test nb procs
if( NOT TEST_MPI_NBPROCS )
set(TEST_MPI_NBPROCS 2)
endif()
# Test command line
foreach(arg IN LISTS TEST_MPI_UNPARSED_ARGUMENTS)
list(APPEND ARGS ${arg})
endforeach()
set (test_parameters -np ${TEST_MPI_NBPROCS} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TEST_MPI_COMMAND} ${ARGS})
otb_add_test(NAME ${TEST_MPI_NAME} COMMAND ${MPIEXEC} ${test_parameters})
endfunction()
Most files in this release are marked with the copyrights of the
organizations who have edited them. The copyrights below are in no
particular order and generally reflect members of the Open MPI core
team who have contributed code to this release. The copyrights for
code used under license from other parties are included in the
corresponding files.
Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
University Research and Technology
Corporation. All rights reserved.
Copyright (c) 2004-2010 The University of Tennessee and The University
of Tennessee Research Foundation. All rights
reserved.
Copyright (c) 2004-2010 High Performance Computing Center Stuttgart,
University of Stuttgart. All rights reserved.
Copyright (c) 2004-2008 The Regents of the University of California.
All rights reserved.
Copyright (c) 2006-2010 Los Alamos National Security, LLC. All rights
reserved.
Copyright (c) 2006-2010 Cisco Systems, Inc. All rights reserved.
Copyright (c) 2006-2010 Voltaire, Inc. All rights reserved.
Copyright (c) 2006-2011 Sandia National Laboratories. All rights reserved.
Copyright (c) 2006-2010 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
Copyright (c) 2006-2010 The University of Houston. All rights reserved.
Copyright (c) 2006-2009 Myricom, Inc. All rights reserved.
Copyright (c) 2007-2008 UT-Battelle, LLC. All rights reserved.
Copyright (c) 2007-2010 IBM Corporation. All rights reserved.
Copyright (c) 1998-2005 Forschungszentrum Juelich, Juelich Supercomputing
Centre, Federal Republic of Germany
Copyright (c) 2005-2008 ZIH, TU Dresden, Federal Republic of Germany
Copyright (c) 2007 Evergrid, Inc. All rights reserved.
Copyright (c) 2008 Chelsio, Inc. All rights reserved.
Copyright (c) 2008-2009 Institut National de Recherche en
Informatique. All rights reserved.
Copyright (c) 2007 Lawrence Livermore National Security, LLC.
All rights reserved.
Copyright (c) 2007-2009 Mellanox Technologies. All rights reserved.
Copyright (c) 2006-2010 QLogic Corporation. All rights reserved.
Copyright (c) 2008-2010 Oak Ridge National Labs. All rights reserved.
Copyright (c) 2006-2010 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2009 Bull SAS. All rights reserved.
Copyright (c) 2010 ARM ltd. All rights reserved.
Copyright (c) 2010-2011 Alex Brick . All rights reserved.
Copyright (c) 2012 The University of Wisconsin-La Crosse. All rights
reserved.
Copyright (c) 2013-2016 Intel, Inc. All rights reserved.
Copyright (c) 2011-2014 NVIDIA Corporation. All rights reserved.
$COPYRIGHT$
Additional copyrights may follow
$HEADER$
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer listed
in this license in the documentation and/or other materials
provided with the distribution.
- Neither the name of the copyright holders nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
The copyright holders provide no reassurances that the source code
provided does not infringe any patent, copyright, or any other
intellectual property rights of third parties. The copyright holders
disclaim any liability to any recipient for claims brought against
recipient by any third party for infringement of that parties
intellectual property rights.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software is in the public domain, furnished "as is", without
technical support, and with no warranty, express or implied, as to its
usefulness for any purpose.
......@@ -180,6 +180,9 @@ public:
/** Get description about overviews available into the file specified */
std::vector<std::string> GetOverviewsInfo() ITK_OVERRIDE;
/** Returns gdal pixel type as string */
std::string GetGdalPixelTypeAsString() const;
protected:
/**
* Constructor.
......
......@@ -1997,4 +1997,12 @@ bool GDALImageIO::CreationOptionContains(std::string partialOption) const
return (i != m_CreationOptions.size());
}
std::string GDALImageIO::GetGdalPixelTypeAsString() const
{
std::string name = GDALGetDataTypeName(m_PxType->pixType);
return name;
}
} // end namespace otb
......@@ -32,6 +32,9 @@
#include "itkMersenneTwisterRandomVariateGenerator.h"
#ifdef OTB_USE_MPI
#include "otbMPIConfig.h"
#endif
typedef int (*MainFuncPointer)(int, char*[]);
std::map<std::string, MainFuncPointer> StringToTestFunctionMap;
......@@ -64,6 +67,10 @@ void LoadTestEnv()
int main(int ac, char* av[])
{
#ifdef OTB_USE_MPI
otb::MPIConfig::Instance()->Init(ac,av);
#endif
bool lFlagRegression(false);
double lToleranceDiffValue(0);
double lEpsilon(0);
......@@ -332,6 +339,11 @@ int main(int ac, char* av[])
result = EXIT_SUCCESS;
#ifdef OTB_USE_MPI
otb::MPIConfig::Pointer mpiConfig = otb::MPIConfig::Instance();
if (mpiConfig->GetMyRank() == 0)
{
#endif
std::cout << " -> Test EXIT SUCCESS." << std::endl;
if (lFlagRegression == false)
{
......@@ -410,6 +422,9 @@ int main(int ac, char* av[])
}
std::cout << "------------- End control baseline tests -------------" << std::endl;
#ifdef OTB_USE_MPI
}
#endif
return result;
}
}
......
......@@ -15,6 +15,9 @@ otb_module(OTBTestKernel
OTBOSSIMAdapters
OTBImageManipulation
OPTIONAL_DEPENDS
OTBMPIConfig
DESCRIPTION
"${DOCUMENTATION}"
)
......@@ -7,6 +7,7 @@ target_link_libraries(OTBTestKernel
${OTBGDAL_LIBRARIES}
${OTBOSSIMAdapters_LIBRARIES}
${OTBImageManipulation_LIBRARIES}
${OTBMPIConfig_LIBRARIES}
)
otb_module_target(OTBTestKernel)
......
project(MPIConfig)
set(MPIConfig_LIBRARIES MPIConfig)
set(OTBMPIConfig_LIBRARIES OTBMPIConfig)
otb_module_impl()
General
=======
This is a template module for the ORFEO
Toolbox(https://www.orfeo-toolbox.org/). It is designed to work with OTBv5
modular system and to be places in OTB/Module/Remote.
This module is empty it is just a template to be used as a starting point for a
module with actual content. It contains the template for sources (src folder),
test (test folder) and application (app folder).
Getting Started
===============
The official OTB Wiki documentation on adding an external module is here:
http://wiki.orfeo-toolbox.org/index.php/How_to_write_a_remote_module
Remote Module
-------------
After a module has been created as a git repository it can be included
as a remote module, which enables automatic fetching. Add a file in
"OTB/Modules/Remote" called "YourModule.remote.cmake", for this module
it would be "ExternalExample.remote.cmake" with the followlowing contents:
otb_fetch_module(ExternalTemplate
"A template for a module."
GIT_REPOSITORY https://github.com/orfeotoolbox/otbExternalModuleTemplate
GIT_TAG master
)
Editing
=======
The CMakeLists.txt and otb-modules need to be modified with the name of the
module, something along the following:
sed 's/ExternalTemplate/MyModule/g' CMakeLists.txt otb-module.cmake
There is the inplace option to sed, but it's not portable, so do this change by
hand or look up the option in sed.
Then hack away at you code in include, src, test and app folders.
License
=======
This software is distributed under the Apache License. Please see LICENSE for
details.
Author
======
Manuel Grizonnet
Thanks
======
It is a fork of the ITK template module provided by Bradley Lowekamp
(https://github.com/blowekamp/itkExternalTemplate.git) which was adapted for the
ORFEO ToolBox.
Compilation des tests
=====================
module load cmake/3.4.3 openmpi/1.10.2 otb/develop
cd build
rm -rf *
cmake -DCMAKE_CXX_FLAGS="-Wno-unused-local-typedefs -std=c++11" ..
make
ctest
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbMPIConfig_h
#define __otbMPIConfig_h
#include "itkObject.h"
#include "itkMacro.h"
#include "itkObjectFactory.h"
namespace otb {
/** \class MPI config
* \brief Manage MPI ressources
* TODO
*
*
* \ingroup OTBMPIConfig
*/
class MPIConfig: public itk::LightObject
{
public:
/** Standard class typedefs. */
typedef MPIConfig Self;
typedef itk::Object Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Retrieve the singleton instance */
static Pointer Instance();
/** Run-time type information (and related methods). */
itkTypeMacro(MPIConfig, itk::LightObject);
/** MPI Parameters accessors */
itkGetMacro(MyRank, unsigned int);
itkGetMacro(NbProcs,unsigned int);
/** Initialize MPI Processus */
void Init(int& argc, char** &argv, bool abortOnException = true);
/** Abort all MPI processus. */
void abort(int errCode);
/** Blocks until all processes have reached this routine */
void barrier();
/** Log error */
void logError(const std::string message);
/** Log info */
void logInfo(const std::string message);
protected:
/** Constructor */
MPIConfig();
/** Destructor */
virtual ~MPIConfig();
private:
MPIConfig(const MPIConfig &); //purposely not implemented
void operator =(const MPIConfig&); //purposely not implemented
// MPI rank
unsigned int m_MyRank;
// Number of MPI processus
unsigned int m_NbProcs;
// Boolean to abort on exception
bool m_abortOnException;
// Boolean to test if the MPI environment is initialized
bool m_initialized;
static Pointer m_Singleton;
};
} // End namespace otb
#endif //__otbMPIConfig_h
set(DOCUMENTATION "Provides a helper class to configure and use MPI.")
otb_module(OTBMPIConfig
DEPENDS
OTBITK
OTBImageIO
OTBStreaming
OTBMPI
TEST_DEPENDS
OTBBoost
OTBImageBase
OTBImageManipulation
OTBMPITiffWriter
OTBTestKernel
DESCRIPTION
"${DOCUMENTATION}"
)
#${otb-module} will be the name of this module and will not need to be
#changed when this module is renamed.
set(${otb-module}_SRC
otbMPIConfig.cxx
)
add_library(${otb-module} ${${otb-module}_SRC})
target_link_libraries(${otb-module} ${OTBCommon_LIBRARIES} ${OTBMPI_LIBRARIES})
otb_module_target(${otb-module})
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "otbMPIConfig.h"
#include <exception>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#include <mpi.h>
/**
* Call the MPI routine MPIFunc with arguments Args (surrounded by
* parentheses). If the result is not MPI_SUCCESS, throw an exception.
*/
#define OTB_MPI_CHECK_RESULT( MPIFunc, Args ) \
{ \
int _result = MPIFunc Args; \
if (_result != MPI_SUCCESS) \
{ \
std::stringstream message; \
message << "otb::ERROR: " << #MPIFunc << " (Code = " << _result; \
::itk::ExceptionObject _e(__FILE__, __LINE__, message.str().c_str()); \
throw _e; \
} \
}
namespace otb {
/** Initialize the singleton */
MPIConfig::Pointer MPIConfig::m_Singleton = NULL;
MPIConfig::Pointer MPIConfig::Instance()
{
if(m_Singleton.GetPointer() == NULL)
{
m_Singleton = itk::ObjectFactory<Self>::Create();
if(m_Singleton.GetPointer() == NULL)
{
m_Singleton = new MPIConfig;
}
m_Singleton->UnRegister();
}
return m_Singleton;
}
/** CreateInitialize MPI environment */
MPIConfig::MPIConfig()
: m_MyRank(-1),
m_NbProcs(0),
m_abortOnException(true),
m_initialized(false)
{
}
/** Shuts down the MPI environment. */
MPIConfig::~MPIConfig()
{
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) {
// 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);
}
m_MyRank = static_cast<unsigned int>(irank);
// Get MPI NbProocs
int inbprocs=0;
OTB_MPI_CHECK_RESULT(MPI_Comm_size, (MPI_COMM_WORLD , &inbprocs));
if(inbprocs<1)
{
logError("Negative or null number of processes");
abort(EXIT_FAILURE);
}
m_NbProcs = static_cast<unsigned int>(inbprocs);
}
void MPIConfig::abort(int errCode)
{
OTB_MPI_CHECK_RESULT(MPI_Abort, (MPI_COMM_WORLD, errCode));
}
void MPIConfig::barrier()
{
OTB_MPI_CHECK_RESULT(MPI_Barrier, (MPI_COMM_WORLD));
}
void MPIConfig::logError(const std::string message) {
if (m_MyRank == 0)
{
std::cerr << message << std::endl;
}
}
void MPIConfig::logInfo(const std::string message) {
if (m_MyRank == 0)
{
std::cout << message << std::endl;
}
}
} // End namespace otb
otb_module_test()
#${otb-module} will be the name of this module and will not need to be #changed when this module is renamed.
set(${otb-module}Tests
otbMPIConfigTestDriver.cxx
otbMPIConfigTest.cxx
)
add_executable(otbMPIConfigTestDriver ${${otb-module}Tests})
target_link_libraries(otbMPIConfigTestDriver ${${otb-module}-Test_LIBRARIES} ${Boost_SYSTEM_LIBRARY} ${Boost_CHRONO_LIBRARY})
otb_module_target_label(otbMPIConfigTestDriver)
# MPI Hello test
otb_add_test_mpi(NAME otbMPIConfigTest
NBPROCS 2
COMMAND otbMPIConfigTestDriver otbMPIConfigTest )
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "otbMPIConfig.h"
#include <iostream>
#include "itkMultiThreader.h"
int otbMPIConfigTest(int argc, char* argv[]) {
// MPI Configuration
typedef otb::MPIConfig MPIConfigType;
MPIConfigType::Pointer config = MPIConfigType::Instance();
config->Init(argc,argv,true);