From 4ba494aa3fffa1b572307a163e5612d78c4bdf3d Mon Sep 17 00:00:00 2001 From: Fan Jiang Date: Fri, 21 Aug 2020 10:43:19 -0400 Subject: [PATCH 1/6] Cleanup preamble and specialization --- python/gtsam/preamble.h | 5 +---- python/gtsam/specializations.h | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/python/gtsam/preamble.h b/python/gtsam/preamble.h index 0a1199122..b67df2644 100644 --- a/python/gtsam/preamble.h +++ b/python/gtsam/preamble.h @@ -2,12 +2,9 @@ // These are required to save one copy operation on Python calls #ifdef GTSAM_ALLOCATOR_TBB PYBIND11_MAKE_OPAQUE(std::vector>); -PYBIND11_MAKE_OPAQUE(std::vector >); -PYBIND11_MAKE_OPAQUE(std::vector); -PYBIND11_MAKE_OPAQUE(std::vector>); #else PYBIND11_MAKE_OPAQUE(std::vector); +#endif PYBIND11_MAKE_OPAQUE(std::vector >); PYBIND11_MAKE_OPAQUE(std::vector); PYBIND11_MAKE_OPAQUE(std::vector>); -#endif diff --git a/python/gtsam/specializations.h b/python/gtsam/specializations.h index 2bd6a98a1..950dd8236 100644 --- a/python/gtsam/specializations.h +++ b/python/gtsam/specializations.h @@ -2,12 +2,9 @@ // These are required to save one copy operation on Python calls #ifdef GTSAM_ALLOCATOR_TBB py::bind_vector > >(m_, "KeyVector"); -py::bind_vector > >(m_, "Point2Vector"); -py::bind_vector >(m_, "Pose3Vector"); -py::bind_vector > > >(m_, "BetweenFactorPose3s"); #else py::bind_vector >(m_, "KeyVector"); +#endif py::bind_vector > >(m_, "Point2Vector"); py::bind_vector >(m_, "Pose3Vector"); py::bind_vector > > >(m_, "BetweenFactorPose3s"); -#endif From 86763e620c0c7fc919a96eb2362a928dac3812b6 Mon Sep 17 00:00:00 2001 From: Fan Jiang Date: Fri, 21 Aug 2020 10:43:39 -0400 Subject: [PATCH 2/6] Add TBB test for Python and GTSAM C++ --- .github/scripts/python.sh | 35 +++++++++++++++++++++++++++++ .github/scripts/unix.sh | 1 - .github/workflows/build-python.yml | 7 ++++++ .github/workflows/build-special.yml | 14 ++++++------ 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/.github/scripts/python.sh b/.github/scripts/python.sh index 38359e87d..6948cc385 100644 --- a/.github/scripts/python.sh +++ b/.github/scripts/python.sh @@ -6,6 +6,38 @@ set -x -e +# install TBB with _debug.so files +function install_tbb() +{ + TBB_BASEURL=https://github.com/oneapi-src/oneTBB/releases/download + TBB_VERSION=4.4.5 + TBB_DIR=tbb44_20160526oss + TBB_SAVEPATH="/tmp/tbb.tgz" + + if [ "$(uname)" == "Linux" ]; then + OS_SHORT="lin" + TBB_LIB_DIR="intel64/gcc4.4" + SUDO="sudo" + + elif [ "$(uname)" == "Darwin" ]; then + OS_SHORT="osx" + 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 CI 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/ + +} + if [ -z ${PYTHON_VERSION+x} ]; then echo "Please provide the Python version to build against!" exit 127 @@ -27,6 +59,8 @@ fi PATH=$PATH:$($PYTHON -c "import site; print(site.USER_BASE)")/bin +[ "${GTSAM_WITH_TBB:-OFF}" = "ON" ] && install_tbb + case $WRAPPER in "cython") BUILD_CYTHON="ON" @@ -53,6 +87,7 @@ cd $GITHUB_WORKSPACE/build cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release \ -DGTSAM_BUILD_TESTS=OFF -DGTSAM_BUILD_UNSTABLE=ON \ -DGTSAM_USE_QUATERNIONS=OFF \ + -DGTSAM_WITH_TBB=${GTSAM_WITH_TBB:-OFF} \ -DGTSAM_BUILD_EXAMPLES_ALWAYS=OFF \ -DGTSAM_BUILD_WITH_MARCH_NATIVE=OFF \ -DGTSAM_INSTALL_CYTHON_TOOLBOX=${BUILD_CYTHON} \ diff --git a/.github/scripts/unix.sh b/.github/scripts/unix.sh index f04100d0a..f85e67dc1 100644 --- a/.github/scripts/unix.sh +++ b/.github/scripts/unix.sh @@ -66,7 +66,6 @@ function configure() -DGTSAM_BUILD_EXAMPLES_ALWAYS=${GTSAM_BUILD_EXAMPLES_ALWAYS:-ON} \ -DGTSAM_ALLOW_DEPRECATED_SINCE_V41=${GTSAM_ALLOW_DEPRECATED_SINCE_V41:-OFF} \ -DGTSAM_USE_QUATERNIONS=${GTSAM_USE_QUATERNIONS:-OFF} \ - -DGTSAM_TYPEDEF_POINTS_TO_VECTOR=${GTSAM_TYPEDEF_POINTS_TO_VECTOR:-OFF} \ -DGTSAM_BUILD_WITH_MARCH_NATIVE=OFF \ -DBOOST_ROOT=$BOOST_ROOT \ -DBoost_NO_SYSTEM_PATHS=ON \ diff --git a/.github/workflows/build-python.yml b/.github/workflows/build-python.yml index 7a09c13d1..602d0980e 100644 --- a/.github/workflows/build-python.yml +++ b/.github/workflows/build-python.yml @@ -50,6 +50,13 @@ jobs: compiler: xcode version: "11.3.1" + - name: ubuntu-18.04-gcc-5 + os: ubuntu-18.04 + compiler: gcc + version: "5" + env: + GTSAM_WITH_TBB: ON + steps: - name: Checkout uses: actions/checkout@master diff --git a/.github/workflows/build-special.yml b/.github/workflows/build-special.yml index 21984311b..f561526c6 100644 --- a/.github/workflows/build-special.yml +++ b/.github/workflows/build-special.yml @@ -23,7 +23,7 @@ jobs: [ ubuntu-gcc-deprecated, ubuntu-gcc-quaternions, - ubuntu-gcc-points-vector, + ubuntu-gcc-tbb, ] build_type: [Debug, Release] @@ -41,11 +41,11 @@ jobs: version: "9" flag: quaternions - - name: ubuntu-gcc-points-vector + - name: ubuntu-gcc-tbb os: ubuntu-18.04 compiler: gcc version: "9" - flag: points-vector + flag: tbb steps: - name: Checkout @@ -101,11 +101,11 @@ jobs: GTSAM_USE_QUATERNIONS: ON run: echo "Use Quaternions for rotations" - - name: Set Typedef Points to Vector Flag - if: matrix.flag == 'points-vector' + - name: Set GTSAM_WITH_TBB Flag + if: matrix.flag == 'tbb' env: - GTSAM_TYPEDEF_POINTS_TO_VECTOR: ON - run: echo "Typedef Points to Vector" + GTSAM_WITH_TBB: ON + run: echo "GTSAM Uses TBB" - name: Build & Test run: | From 681bfe72f4b3ee09e42de9d01089347977eb9f59 Mon Sep 17 00:00:00 2001 From: Fan Jiang Date: Fri, 21 Aug 2020 10:51:23 -0400 Subject: [PATCH 3/6] Fix special builds --- .github/workflows/build-special.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-special.yml b/.github/workflows/build-special.yml index f561526c6..648365f24 100644 --- a/.github/workflows/build-special.yml +++ b/.github/workflows/build-special.yml @@ -91,21 +91,21 @@ jobs: - name: Set Allow Deprecated Flag if: matrix.flag == 'deprecated' - env: - GTSAM_ALLOW_DEPRECATED_SINCE_V41: ON - run: echo "Allow deprecated since version 4.1" + run: | + echo "::set-env name=GTSAM_ALLOW_DEPRECATED_SINCE_V41::ON" + echo "Allow deprecated since version 4.1" - name: Set Use Quaternions Flag if: matrix.flag == 'quaternions' - env: - GTSAM_USE_QUATERNIONS: ON - run: echo "Use Quaternions for rotations" + run: | + echo "::set-env name=GTSAM_USE_QUATERNIONS::ON" + echo "Use Quaternions for rotations" - name: Set GTSAM_WITH_TBB Flag if: matrix.flag == 'tbb' - env: - GTSAM_WITH_TBB: ON - run: echo "GTSAM Uses TBB" + run: | + echo "::set-env name=GTSAM_WITH_TBB::ON" + echo "GTSAM Uses TBB" - name: Build & Test run: | From f97fdd1cfdeefe49efd5ac1f97aad1a503b0847e Mon Sep 17 00:00:00 2001 From: Fan Jiang Date: Fri, 21 Aug 2020 10:53:08 -0400 Subject: [PATCH 4/6] Add TBB Python CI to matrix --- .github/workflows/build-python.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-python.yml b/.github/workflows/build-python.yml index 602d0980e..449915e7f 100644 --- a/.github/workflows/build-python.yml +++ b/.github/workflows/build-python.yml @@ -23,6 +23,7 @@ jobs: # ubuntu-18.04-gcc-9, # TODO Disabled for now because of timeouts ubuntu-18.04-clang-9, macOS-10.15-xcode-11.3.1, + ubuntu-18.04-gcc-5-tbb, ] build_type: [Debug, Release] @@ -50,7 +51,7 @@ jobs: compiler: xcode version: "11.3.1" - - name: ubuntu-18.04-gcc-5 + - name: ubuntu-18.04-gcc-5-tbb os: ubuntu-18.04 compiler: gcc version: "5" From 056c835cea03261824799bd9fde5c88c2bcaad5d Mon Sep 17 00:00:00 2001 From: Fan Jiang Date: Fri, 21 Aug 2020 11:20:36 -0400 Subject: [PATCH 5/6] Fix TBB env not propagated --- .github/workflows/build-python.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-python.yml b/.github/workflows/build-python.yml index 449915e7f..dc03ec6c9 100644 --- a/.github/workflows/build-python.yml +++ b/.github/workflows/build-python.yml @@ -55,8 +55,7 @@ jobs: os: ubuntu-18.04 compiler: gcc version: "5" - env: - GTSAM_WITH_TBB: ON + flag: tbb steps: - name: Checkout @@ -94,6 +93,11 @@ jobs: echo "::set-env name=CC::clang" echo "::set-env name=CXX::clang++" fi + - name: Set GTSAM_WITH_TBB Flag + if: matrix.flag == 'tbb' + run: | + echo "::set-env name=GTSAM_WITH_TBB::ON" + echo "GTSAM Uses TBB" - name: Build (Linux) if: runner.os == 'Linux' run: | From 8e5dbeba57aa4fb087f3c28272fc005eefa8de0a Mon Sep 17 00:00:00 2001 From: Fan Jiang Date: Fri, 21 Aug 2020 11:57:01 -0400 Subject: [PATCH 6/6] Fix preamble.h --- python/gtsam/preamble.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/gtsam/preamble.h b/python/gtsam/preamble.h index b67df2644..9f3032dd0 100644 --- a/python/gtsam/preamble.h +++ b/python/gtsam/preamble.h @@ -7,4 +7,5 @@ PYBIND11_MAKE_OPAQUE(std::vector); #endif PYBIND11_MAKE_OPAQUE(std::vector >); PYBIND11_MAKE_OPAQUE(std::vector); -PYBIND11_MAKE_OPAQUE(std::vector>); +PYBIND11_MAKE_OPAQUE(std::vector > >); +PYBIND11_MAKE_OPAQUE(std::vector > >);