commit
8194b931fe
35
.travis.sh
35
.travis.sh
|
@ -1,5 +1,37 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# install TBB with _debug.so files
|
||||||
|
function install_tbb()
|
||||||
|
{
|
||||||
|
TBB_BASEURL=https://github.com/oneapi-src/oneTBB/releases/download
|
||||||
|
TBB_VERSION=4.4.2
|
||||||
|
TBB_DIR=tbb44_20151115oss
|
||||||
|
TBB_SAVEPATH="/tmp/tbb.tgz"
|
||||||
|
|
||||||
|
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
|
||||||
|
OS_SHORT="lin"
|
||||||
|
TBB_LIB_DIR="intel64/gcc4.4"
|
||||||
|
SUDO="sudo"
|
||||||
|
|
||||||
|
elif [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||||
|
OS_SHORT="lin"
|
||||||
|
TBB_LIB_DIR=""
|
||||||
|
SUDO=""
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
wget "${TBB_BASEURL}/${TBB_VERSION}/${TBB_DIR}_${OS_SHORT}.tgz" -O $TBB_SAVEPATH
|
||||||
|
tar -C /tmp -xf $TBB_SAVEPATH
|
||||||
|
|
||||||
|
TBBROOT=/tmp/$TBB_DIR
|
||||||
|
# Copy the needed files to the correct places.
|
||||||
|
# This works correctly for travis builds, instead of setting path variables.
|
||||||
|
# This is what Homebrew does to install TBB on Macs
|
||||||
|
$SUDO cp -R $TBBROOT/lib/$TBB_LIB_DIR/* /usr/local/lib/
|
||||||
|
$SUDO cp -R $TBBROOT/include/ /usr/local/include/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
# common tasks before either build or test
|
# common tasks before either build or test
|
||||||
function configure()
|
function configure()
|
||||||
{
|
{
|
||||||
|
@ -14,6 +46,8 @@ function configure()
|
||||||
rm -fr $BUILD_DIR || true
|
rm -fr $BUILD_DIR || true
|
||||||
mkdir $BUILD_DIR && cd $BUILD_DIR
|
mkdir $BUILD_DIR && cd $BUILD_DIR
|
||||||
|
|
||||||
|
install_tbb
|
||||||
|
|
||||||
if [ ! -z "$GCC_VERSION" ]; then
|
if [ ! -z "$GCC_VERSION" ]; then
|
||||||
export CC=gcc-$GCC_VERSION
|
export CC=gcc-$GCC_VERSION
|
||||||
export CXX=g++-$GCC_VERSION
|
export CXX=g++-$GCC_VERSION
|
||||||
|
@ -24,6 +58,7 @@ function configure()
|
||||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} \
|
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} \
|
||||||
-DGTSAM_BUILD_TESTS=${GTSAM_BUILD_TESTS:-OFF} \
|
-DGTSAM_BUILD_TESTS=${GTSAM_BUILD_TESTS:-OFF} \
|
||||||
-DGTSAM_BUILD_UNSTABLE=${GTSAM_BUILD_UNSTABLE:-ON} \
|
-DGTSAM_BUILD_UNSTABLE=${GTSAM_BUILD_UNSTABLE:-ON} \
|
||||||
|
-DGTSAM_WITH_TBB=${GTSAM_WITH_TBB:-OFF} \
|
||||||
-DGTSAM_USE_QUATERNIONS=${GTSAM_USE_QUATERNIONS:-OFF} \
|
-DGTSAM_USE_QUATERNIONS=${GTSAM_USE_QUATERNIONS:-OFF} \
|
||||||
-DGTSAM_BUILD_EXAMPLES_ALWAYS=${GTSAM_BUILD_EXAMPLES_ALWAYS:-ON} \
|
-DGTSAM_BUILD_EXAMPLES_ALWAYS=${GTSAM_BUILD_EXAMPLES_ALWAYS:-ON} \
|
||||||
-DGTSAM_ALLOW_DEPRECATED_SINCE_V4=${GTSAM_ALLOW_DEPRECATED_SINCE_V4:-OFF} \
|
-DGTSAM_ALLOW_DEPRECATED_SINCE_V4=${GTSAM_ALLOW_DEPRECATED_SINCE_V4:-OFF} \
|
||||||
|
|
|
@ -18,7 +18,7 @@ addons:
|
||||||
- libboost-all-dev
|
- libboost-all-dev
|
||||||
|
|
||||||
# before_install:
|
# before_install:
|
||||||
# - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update ; fi
|
# - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update; fi
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache ; fi
|
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache ; fi
|
||||||
|
@ -89,6 +89,12 @@ jobs:
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: CC=clang-9 CXX=clang++-9 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
|
||||||
|
# on Linux, with GTSAM_WITH_TBB on to make sure GTSAM still compiles/tests
|
||||||
|
- stage: special
|
||||||
|
os: linux
|
||||||
|
compiler: gcc
|
||||||
|
env: CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_UNSTABLE=OFF GTSAM_WITH_TBB=ON
|
||||||
|
script: bash .travis.sh -b
|
||||||
# -------- STAGE 2: TESTS -----------
|
# -------- STAGE 2: TESTS -----------
|
||||||
# on Mac, GCC
|
# on Mac, GCC
|
||||||
- stage: test
|
- stage: test
|
||||||
|
|
|
@ -199,12 +199,17 @@ find_package(TBB 4.4 COMPONENTS tbb tbbmalloc)
|
||||||
|
|
||||||
# Set up variables if we're using TBB
|
# Set up variables if we're using TBB
|
||||||
if(TBB_FOUND AND GTSAM_WITH_TBB)
|
if(TBB_FOUND AND GTSAM_WITH_TBB)
|
||||||
set(GTSAM_USE_TBB 1) # This will go into config.h
|
set(GTSAM_USE_TBB 1) # This will go into config.h
|
||||||
# all definitions and link requisites will go via imported targets:
|
if (${TBB_VERSION_MAJOR} GREATER_EQUAL 2020)
|
||||||
# tbb & tbbmalloc
|
set(TBB_GREATER_EQUAL_2020 1)
|
||||||
list(APPEND GTSAM_ADDITIONAL_LIBRARIES tbb tbbmalloc)
|
else()
|
||||||
|
set(TBB_GREATER_EQUAL_2020 0)
|
||||||
|
endif()
|
||||||
|
# all definitions and link requisites will go via imported targets:
|
||||||
|
# tbb & tbbmalloc
|
||||||
|
list(APPEND GTSAM_ADDITIONAL_LIBRARIES tbb tbbmalloc)
|
||||||
else()
|
else()
|
||||||
set(GTSAM_USE_TBB 0) # This will go into config.h
|
set(GTSAM_USE_TBB 0) # This will go into config.h
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
|
@ -51,7 +51,11 @@ namespace gtsam {
|
||||||
Key key;
|
Key key;
|
||||||
size_t n;
|
size_t n;
|
||||||
boost::tie(key, n) = v;
|
boost::tie(key, n) = v;
|
||||||
|
#ifdef TBB_GREATER_EQUAL_2020
|
||||||
values_.emplace(key, x.segment(j, n));
|
values_.emplace(key, x.segment(j, n));
|
||||||
|
#else
|
||||||
|
values_.insert(std::make_pair(key, x.segment(j, n)));
|
||||||
|
#endif
|
||||||
j += n;
|
j += n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +64,11 @@ namespace gtsam {
|
||||||
VectorValues::VectorValues(const Vector& x, const Scatter& scatter) {
|
VectorValues::VectorValues(const Vector& x, const Scatter& scatter) {
|
||||||
size_t j = 0;
|
size_t j = 0;
|
||||||
for (const SlotEntry& v : scatter) {
|
for (const SlotEntry& v : scatter) {
|
||||||
|
#ifdef TBB_GREATER_EQUAL_2020
|
||||||
values_.emplace(v.key, x.segment(j, v.dimension));
|
values_.emplace(v.key, x.segment(j, v.dimension));
|
||||||
|
#else
|
||||||
|
values_.insert(std::make_pair(v.key, x.segment(j, v.dimension)));
|
||||||
|
#endif
|
||||||
j += v.dimension;
|
j += v.dimension;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +78,11 @@ namespace gtsam {
|
||||||
{
|
{
|
||||||
VectorValues result;
|
VectorValues result;
|
||||||
for(const KeyValuePair& v: other)
|
for(const KeyValuePair& v: other)
|
||||||
|
#ifdef TBB_GREATER_EQUAL_2020
|
||||||
result.values_.emplace(v.first, Vector::Zero(v.second.size()));
|
result.values_.emplace(v.first, Vector::Zero(v.second.size()));
|
||||||
|
#else
|
||||||
|
result.values_.insert(std::make_pair(v.first, Vector::Zero(v.second.size())));
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +98,11 @@ namespace gtsam {
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
VectorValues::iterator VectorValues::emplace(Key j, const Vector& value) {
|
VectorValues::iterator VectorValues::emplace(Key j, const Vector& value) {
|
||||||
|
#ifdef TBB_GREATER_EQUAL_2020
|
||||||
std::pair<iterator, bool> result = values_.emplace(j, value);
|
std::pair<iterator, bool> result = values_.emplace(j, value);
|
||||||
|
#else
|
||||||
|
std::pair<iterator, bool> result = values_.insert(std::make_pair(j, value));
|
||||||
|
#endif
|
||||||
if(!result.second)
|
if(!result.second)
|
||||||
throw std::invalid_argument(
|
throw std::invalid_argument(
|
||||||
"Requested to emplace variable '" + DefaultKeyFormatter(j)
|
"Requested to emplace variable '" + DefaultKeyFormatter(j)
|
||||||
|
@ -266,7 +282,11 @@ namespace gtsam {
|
||||||
VectorValues result;
|
VectorValues result;
|
||||||
// The result.end() hint here should result in constant-time inserts
|
// The result.end() hint here should result in constant-time inserts
|
||||||
for(const_iterator j1 = begin(), j2 = c.begin(); j1 != end(); ++j1, ++j2)
|
for(const_iterator j1 = begin(), j2 = c.begin(); j1 != end(); ++j1, ++j2)
|
||||||
|
#ifdef TBB_GREATER_EQUAL_2020
|
||||||
result.values_.emplace(j1->first, j1->second + j2->second);
|
result.values_.emplace(j1->first, j1->second + j2->second);
|
||||||
|
#else
|
||||||
|
result.values_.insert(std::make_pair(j1->first, j1->second + j2->second));
|
||||||
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -324,7 +344,11 @@ namespace gtsam {
|
||||||
VectorValues result;
|
VectorValues result;
|
||||||
// The result.end() hint here should result in constant-time inserts
|
// The result.end() hint here should result in constant-time inserts
|
||||||
for(const_iterator j1 = begin(), j2 = c.begin(); j1 != end(); ++j1, ++j2)
|
for(const_iterator j1 = begin(), j2 = c.begin(); j1 != end(); ++j1, ++j2)
|
||||||
|
#ifdef TBB_GREATER_EQUAL_2020
|
||||||
result.values_.emplace(j1->first, j1->second - j2->second);
|
result.values_.emplace(j1->first, j1->second - j2->second);
|
||||||
|
#else
|
||||||
|
result.values_.insert(std::make_pair(j1->first, j1->second - j2->second));
|
||||||
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -340,7 +364,11 @@ namespace gtsam {
|
||||||
{
|
{
|
||||||
VectorValues result;
|
VectorValues result;
|
||||||
for(const VectorValues::KeyValuePair& key_v: v)
|
for(const VectorValues::KeyValuePair& key_v: v)
|
||||||
|
#ifdef TBB_GREATER_EQUAL_2020
|
||||||
result.values_.emplace(key_v.first, a * key_v.second);
|
result.values_.emplace(key_v.first, a * key_v.second);
|
||||||
|
#else
|
||||||
|
result.values_.insert(std::make_pair(key_v.first, a * key_v.second));
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,11 @@ namespace gtsam {
|
||||||
* exist, it is inserted and an iterator pointing to the new element, along with 'true', is
|
* exist, it is inserted and an iterator pointing to the new element, along with 'true', is
|
||||||
* returned. */
|
* returned. */
|
||||||
std::pair<iterator, bool> tryInsert(Key j, const Vector& value) {
|
std::pair<iterator, bool> tryInsert(Key j, const Vector& value) {
|
||||||
return values_.emplace(j, value);
|
#ifdef TBB_GREATER_EQUAL_2020
|
||||||
|
return values_.emplace(j, value);
|
||||||
|
#else
|
||||||
|
return values_.insert(std::make_pair(j, value));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Erase the vector with the given key, or throw std::out_of_range if it does not exist */
|
/** Erase the vector with the given key, or throw std::out_of_range if it does not exist */
|
||||||
|
|
Loading…
Reference in New Issue