Merge remote-tracking branch 'borglab/develop' into develop

release/4.3a0
Peter Mullen 2019-12-20 17:23:29 -08:00
commit 34e429af9e
11 changed files with 99 additions and 103 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# common tasks before either build or test # common tasks before either build or test
function prepare () function configure()
{ {
set -e # Make sure any error makes the script to return an error code set -e # Make sure any error makes the script to return an error code
set -x # echo set -x # echo
@ -14,21 +14,23 @@ function prepare ()
rm -fr $BUILD_DIR || true rm -fr $BUILD_DIR || true
mkdir $BUILD_DIR && cd $BUILD_DIR mkdir $BUILD_DIR && cd $BUILD_DIR
if [ -z "$CMAKE_BUILD_TYPE" ]; then
CMAKE_BUILD_TYPE=Debug
fi
if [ -z "$GTSAM_ALLOW_DEPRECATED_SINCE_V4" ]; then
GTSAM_ALLOW_DEPRECATED_SINCE_V4=OFF
fi
if [ ! -z "$GCC_VERSION" ]; then if [ ! -z "$GCC_VERSION" ]; then
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 60 \ export CC=gcc-$GCC_VERSION
--slave /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION export CXX=g++-$GCC_VERSION
sudo update-alternatives --set gcc /usr/bin/gcc-$GCC_VERSION
fi fi
# GTSAM_BUILD_WITH_MARCH_NATIVE=OFF: to avoid crashes in builder VMs
cmake $SOURCE_DIR \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} \
-DGTSAM_BUILD_TESTS=${GTSAM_BUILD_TESTS:-OFF} \
-DGTSAM_BUILD_UNSTABLE=${GTSAM_BUILD_UNSTABLE:-ON} \
-DGTSAM_BUILD_EXAMPLES_ALWAYS=${GTSAM_BUILD_EXAMPLES_ALWAYS:-ON} \
-DGTSAM_ALLOW_DEPRECATED_SINCE_V4=${GTSAM_ALLOW_DEPRECATED_SINCE_V4:-OFF} \
-DGTSAM_BUILD_WITH_MARCH_NATIVE=OFF \
-DCMAKE_VERBOSE_MAKEFILE=ON
} }
# common tasks after either build or test # common tasks after either build or test
function finish () function finish ()
{ {
@ -41,17 +43,12 @@ function finish ()
# compile the code with the intent of populating the cache # compile the code with the intent of populating the cache
function build () function build ()
{ {
prepare export GTSAM_BUILD_EXAMPLES_ALWAYS=ON
export GTSAM_BUILD_TESTS=OFF
cmake $SOURCE_DIR \ configure
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
-DGTSAM_BUILD_TESTS=OFF \
-DGTSAM_BUILD_UNSTABLE=$GTSAM_BUILD_UNSTABLE \
-DGTSAM_BUILD_EXAMPLES_ALWAYS=ON \
-DGTSAM_ALLOW_DEPRECATED_SINCE_V4=$GTSAM_ALLOW_DEPRECATED_SINCE_V4
# Actual build: make -j2
VERBOSE=1 make -j2
finish finish
} }
@ -59,14 +56,10 @@ function build ()
# run the tests # run the tests
function test () function test ()
{ {
prepare export GTSAM_BUILD_EXAMPLES_ALWAYS=OFF
export GTSAM_BUILD_TESTS=ON
cmake $SOURCE_DIR \ configure
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
-DGTSAM_BUILD_TESTS=ON \
-DGTSAM_BUILD_UNSTABLE=$GTSAM_BUILD_UNSTABLE \
-DGTSAM_BUILD_EXAMPLES_ALWAYS=OFF \
-DGTSAM_ALLOW_DEPRECATED_SINCE_V4=OFF
# Actual build: # Actual build:
make -j2 check make -j2 check

View File

@ -7,11 +7,12 @@ addons:
apt: apt:
sources: sources:
- ubuntu-toolchain-r-test - ubuntu-toolchain-r-test
- sourceline: 'deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
packages: packages:
- g++-8 - g++-9
- clang-3.8 - clang-9
- build-essential - build-essential pkg-config
- pkg-config
- cmake - cmake
- libpython-dev python-numpy - libpython-dev python-numpy
- libboost-all-dev - libboost-all-dev
@ -28,8 +29,14 @@ stages:
- compile - compile
- test - test
env:
global:
- MAKEFLAGS="-j2"
- CCACHE_SLOPPINESS=pch_defines,time_macros
# Compile stage without building examples/tests to populate the caches. # Compile stage without building examples/tests to populate the caches.
jobs: jobs:
# -------- STAGE 1: COMPILE -----------
include: include:
# on Mac, GCC # on Mac, GCC
- stage: compile - stage: compile
@ -68,46 +75,45 @@ jobs:
- stage: compile - stage: compile
os: linux os: linux
compiler: clang compiler: clang
env: CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_UNSTABLE=OFF env: CC=clang-9 CXX=clang++-9 CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_UNSTABLE=OFF
script: bash .travis.sh -b script: bash .travis.sh -b
- stage: compile - stage: compile
os: linux os: linux
compiler: clang compiler: clang
env: CMAKE_BUILD_TYPE=Release env: CC=clang-9 CXX=clang++-9 CMAKE_BUILD_TYPE=Release
script: bash .travis.sh -b script: bash .travis.sh -b
# on Linux, with deprecated ON to make sure that path still compiles # on Linux, with deprecated ON to make sure that path still compiles
- stage: compile - stage: compile
os: linux os: linux
compiler: clang compiler: clang
env: CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_UNSTABLE=OFF GTSAM_ALLOW_DEPRECATED_SINCE_V4=ON env: CC=clang-9 CXX=clang++-9 CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_UNSTABLE=OFF GTSAM_ALLOW_DEPRECATED_SINCE_V4=ON
script: bash .travis.sh -b script: bash .travis.sh -b
# -------- STAGE 2: TESTS -----------
# Matrix configuration: # on Mac, GCC
os: - stage: test
- osx os: osx
- linux
compiler:
- gcc
- clang
env:
global:
- MAKEFLAGS="-j2"
- CCACHE_SLOPPINESS=pch_defines,time_macros
- GTSAM_ALLOW_DEPRECATED_SINCE_V4=OFF
- GTSAM_BUILD_UNSTABLE=ON
matrix:
- CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_UNSTABLE=OFF
- CMAKE_BUILD_TYPE=Release
script:
- bash .travis.sh -t
matrix:
exclude:
# Exclude g++ debug on Linux as it consistently times out
- os: linux
compiler: gcc
env : CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_UNSTABLE=OFF
# Exclude clang on Linux/clang in release until issue #57 is solved
- os: linux
compiler: clang compiler: clang
env: CMAKE_BUILD_TYPE=Release env: CMAKE_BUILD_TYPE=Release
script: bash .travis.sh -t
- stage: test
os: osx
compiler: clang
env: CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_UNSTABLE=OFF
script: bash .travis.sh -t
- stage: test
os: linux
compiler: gcc
env: CMAKE_BUILD_TYPE=Release
script: bash .travis.sh -t
# Exclude g++ debug on Linux as it consistently times out
# - stage: test
# os: linux
# compiler: gcc
# env: CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_UNSTABLE=OFF
# script: bash .travis.sh -t
# Exclude clang on Linux/clang in release until issue #57 is solved
# - stage: test
# os: linux
# compiler: clang
# env: CC=clang-9 CXX=clang++-9 CMAKE_BUILD_TYPE=Release
# script: bash .travis.sh -t

View File

@ -434,7 +434,7 @@ add_subdirectory(timing)
# Build gtsam_unstable # Build gtsam_unstable
if (GTSAM_BUILD_UNSTABLE) if (GTSAM_BUILD_UNSTABLE)
add_subdirectory(gtsam_unstable) add_subdirectory(gtsam_unstable)
endif(GTSAM_BUILD_UNSTABLE) endif()
# Matlab toolbox # Matlab toolbox
if (GTSAM_INSTALL_MATLAB_TOOLBOX) if (GTSAM_INSTALL_MATLAB_TOOLBOX)

View File

@ -29,14 +29,22 @@
# undef max # undef max
# undef ERROR # undef ERROR
#include <functional> // std::hash()
// Use TBB concurrent_unordered_map for ConcurrentMap // Use TBB concurrent_unordered_map for ConcurrentMap
# define CONCURRENT_MAP_BASE tbb::concurrent_unordered_map<KEY, VALUE> template <typename KEY, typename VALUE>
using ConcurrentMapBase = tbb::concurrent_unordered_map<
KEY,
VALUE,
std::hash<KEY>
>;
#else #else
// If we're not using TBB, use a FastMap for ConcurrentMap // If we're not using TBB, use a FastMap for ConcurrentMap
#include <gtsam/base/FastMap.h> #include <gtsam/base/FastMap.h>
# define CONCURRENT_MAP_BASE gtsam::FastMap<KEY, VALUE> template <typename KEY, typename VALUE>
using ConcurrentMapBase = gtsam::FastMap<KEY, VALUE>;
#endif #endif
@ -57,11 +65,11 @@ namespace gtsam {
* @addtogroup base * @addtogroup base
*/ */
template<typename KEY, typename VALUE> template<typename KEY, typename VALUE>
class ConcurrentMap : public CONCURRENT_MAP_BASE { class ConcurrentMap : public ConcurrentMapBase<KEY,VALUE> {
public: public:
typedef CONCURRENT_MAP_BASE Base; typedef ConcurrentMapBase<KEY,VALUE> Base;
/** Default constructor */ /** Default constructor */
ConcurrentMap() {} ConcurrentMap() {}

View File

@ -115,8 +115,8 @@ class DSFMap {
/// Small utility class for representing a wrappable pairs of ints. /// Small utility class for representing a wrappable pairs of ints.
class IndexPair : public std::pair<size_t,size_t> { class IndexPair : public std::pair<size_t,size_t> {
public: public:
IndexPair(): std::pair<size_t,size_t>(0,0) {} inline IndexPair(): std::pair<size_t,size_t>(0,0) {}
IndexPair(size_t i, size_t j) : std::pair<size_t,size_t>(i,j) {} inline IndexPair(size_t i, size_t j) : std::pair<size_t,size_t>(i,j) {}
inline size_t i() const { return first; }; inline size_t i() const { return first; };
inline size_t j() const { return second; }; inline size_t j() const { return second; };
}; };

View File

@ -89,12 +89,9 @@ public:
/** /**
* Create a duplicate object returned as a pointer to the generic Value interface. * Create a duplicate object returned as a pointer to the generic Value interface.
* For the sake of performance, this function use singleton pool allocator instead of the normal heap allocator.
* The result must be deleted with Value::deallocate_, not with the 'delete' operator.
*/ */
virtual Value* clone_() const { virtual Value* clone_() const {
void *place = boost::singleton_pool<PoolTag, sizeof(GenericValue)>::malloc(); GenericValue* ptr = new GenericValue(*this); // calls copy constructor to fill in
GenericValue* ptr = new (place) GenericValue(*this); // calls copy constructor to fill in
return ptr; return ptr;
} }
@ -102,8 +99,7 @@ public:
* Destroy and deallocate this object, only if it was originally allocated using clone_(). * Destroy and deallocate this object, only if it was originally allocated using clone_().
*/ */
virtual void deallocate_() const { virtual void deallocate_() const {
this->~GenericValue(); // Virtual destructor cleans up the derived object delete this;
boost::singleton_pool<PoolTag, sizeof(GenericValue)>::free((void*) this); // Release memory from pool
} }
/** /**
@ -118,10 +114,7 @@ public:
// Call retract on the derived class using the retract trait function // Call retract on the derived class using the retract trait function
const T retractResult = traits<T>::Retract(GenericValue<T>::value(), delta); const T retractResult = traits<T>::Retract(GenericValue<T>::value(), delta);
// Create a Value pointer copy of the result Value* resultAsValue = new GenericValue(retractResult);
void* resultAsValuePlace =
boost::singleton_pool<PoolTag, sizeof(GenericValue)>::malloc();
Value* resultAsValue = new (resultAsValuePlace) GenericValue(retractResult);
// Return the pointer to the Value base class // Return the pointer to the Value base class
return resultAsValue; return resultAsValue;
@ -172,12 +165,6 @@ public:
return *this; return *this;
} }
private:
/// Fake Tag struct for singleton pool allocator. In fact, it is never used!
struct PoolTag {
};
private: private:
/** Serialization function */ /** Serialization function */

View File

@ -22,6 +22,7 @@
#include <gtsam/config.h> // for GTSAM_USE_TBB #include <gtsam/config.h> // for GTSAM_USE_TBB
#include <boost/optional/optional.hpp> #include <boost/optional/optional.hpp>
#include <gtsam/dllexport.h>
#include <string> #include <string>
#include <typeinfo> #include <typeinfo>
@ -117,7 +118,7 @@ public:
}; };
/// Thread-safe runtime error exception /// Thread-safe runtime error exception
class RuntimeErrorThreadsafe: public ThreadsafeException<RuntimeErrorThreadsafe> { class GTSAM_EXPORT RuntimeErrorThreadsafe: public ThreadsafeException<RuntimeErrorThreadsafe> {
public: public:
/// Construct with a string describing the exception /// Construct with a string describing the exception
RuntimeErrorThreadsafe(const std::string& description) : RuntimeErrorThreadsafe(const std::string& description) :

View File

@ -196,7 +196,7 @@ namespace gtsam {
/** /**
* Small class that calls internal::tic at construction, and internol::toc when destroyed * Small class that calls internal::tic at construction, and internol::toc when destroyed
*/ */
class AutoTicToc { class GTSAM_EXPORT AutoTicToc {
private: private:
size_t id_; size_t id_;
const char* label_; const char* label_;

View File

@ -31,7 +31,7 @@ namespace gtsam {
/** The common parameters for Nonlinear optimizers. Most optimizers /** The common parameters for Nonlinear optimizers. Most optimizers
* deriving from NonlinearOptimizer also subclass the parameters. * deriving from NonlinearOptimizer also subclass the parameters.
*/ */
class NonlinearOptimizerParams { class GTSAM_EXPORT NonlinearOptimizerParams {
public: public:
/** See NonlinearOptimizerParams::verbosity */ /** See NonlinearOptimizerParams::verbosity */
enum Verbosity { enum Verbosity {
@ -52,7 +52,7 @@ public:
virtual ~NonlinearOptimizerParams() { virtual ~NonlinearOptimizerParams() {
} }
GTSAM_EXPORT virtual void print(const std::string& str = "") const; virtual void print(const std::string& str = "") const;
size_t getMaxIterations() const { return maxIterations; } size_t getMaxIterations() const { return maxIterations; }
double getRelativeErrorTol() const { return relativeErrorTol; } double getRelativeErrorTol() const { return relativeErrorTol; }
@ -68,8 +68,8 @@ public:
verbosity = verbosityTranslator(src); verbosity = verbosityTranslator(src);
} }
GTSAM_EXPORT static Verbosity verbosityTranslator(const std::string &s) ; static Verbosity verbosityTranslator(const std::string &s) ;
GTSAM_EXPORT static std::string verbosityTranslator(Verbosity value) ; static std::string verbosityTranslator(Verbosity value) ;
/** See NonlinearOptimizerParams::linearSolverType */ /** See NonlinearOptimizerParams::linearSolverType */
enum LinearSolverType { enum LinearSolverType {
@ -144,10 +144,10 @@ public:
} }
private: private:
GTSAM_EXPORT std::string linearSolverTranslator(LinearSolverType linearSolverType) const; std::string linearSolverTranslator(LinearSolverType linearSolverType) const;
GTSAM_EXPORT LinearSolverType linearSolverTranslator(const std::string& linearSolverType) const; LinearSolverType linearSolverTranslator(const std::string& linearSolverType) const;
GTSAM_EXPORT std::string orderingTypeTranslator(Ordering::OrderingType type) const; std::string orderingTypeTranslator(Ordering::OrderingType type) const;
GTSAM_EXPORT Ordering::OrderingType orderingTypeTranslator(const std::string& type) const; Ordering::OrderingType orderingTypeTranslator(const std::string& type) const;
}; };
// For backward compatibility: // For backward compatibility:

View File

@ -30,7 +30,7 @@ namespace gtsam {
/* ************************************************************************* */ /* ************************************************************************* */
/// A clique in a SymbolicBayesTree /// A clique in a SymbolicBayesTree
class SymbolicBayesTreeClique : class GTSAM_EXPORT SymbolicBayesTreeClique :
public BayesTreeCliqueBase<SymbolicBayesTreeClique, SymbolicFactorGraph> public BayesTreeCliqueBase<SymbolicBayesTreeClique, SymbolicFactorGraph>
{ {
public: public:
@ -45,7 +45,7 @@ namespace gtsam {
/* ************************************************************************* */ /* ************************************************************************* */
/// A Bayes tree that represents the connectivity between variables but is not associated with any /// A Bayes tree that represents the connectivity between variables but is not associated with any
/// probability functions. /// probability functions.
class SymbolicBayesTree : class GTSAM_EXPORT SymbolicBayesTree :
public BayesTree<SymbolicBayesTreeClique> public BayesTree<SymbolicBayesTreeClique>
{ {
private: private:
@ -59,7 +59,7 @@ namespace gtsam {
SymbolicBayesTree() {} SymbolicBayesTree() {}
/** check equality */ /** check equality */
GTSAM_EXPORT bool equals(const This& other, double tol = 1e-9) const; bool equals(const This& other, double tol = 1e-9) const;
private: private:
/** Serialization function */ /** Serialization function */

View File

@ -12,6 +12,7 @@
#include <list> #include <list>
#include <vector> #include <vector>
#include <stdexcept> #include <stdexcept>
#include <string>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include "PartitionWorkSpace.h" #include "PartitionWorkSpace.h"