Skip to content

Commit

Permalink
Merge pull request #7 from elucideye/pr.cereal.only
Browse files Browse the repository at this point in the history
remove boost serialization
  • Loading branch information
headupinclouds authored Jul 25, 2017
2 parents 74d3a16 + 5d58fe2 commit 505e38c
Show file tree
Hide file tree
Showing 16 changed files with 97 additions and 272 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ language:
sudo:
- false

dist:
- trusty

# Install packages differs for container-based infrastructure
# * https://docs.travis-ci.com/user/migrating-from-legacy/#How-do-I-install-APT-sources-and-packages%3F
# * http://stackoverflow.com/a/30925448/2288008
Expand Down Expand Up @@ -89,7 +92,7 @@ install:
# Install Python package 'requests'
# 'easy_install3' is not installed by 'brew install python3' on OS X 10.9 Maverick
- if [[ "`uname`" == "Darwin" ]]; then pip3 install requests; fi
- if [[ "`uname`" == "Linux" ]]; then travis_retry easy_install3 --user requests==2.10.0; fi
- if [[ "`uname`" == "Linux" ]]; then travis_retry pip3 install --user requests; fi

# Install latest Polly toolchains and scripts
- wget https://github.com/ruslo/polly/archive/master.zip
Expand Down
39 changes: 13 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,39 @@

# TODO: Add a more recent xgboost to hunter

cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.3)

### Hunter snapshot that will be used ###
include("cmake/HunterGate.cmake")

HunterGate(
URL "https://github.com/ruslo/hunter/archive/v0.18.44.tar.gz"
SHA1 "a78f0b377b8e53c038f12fc18b0c02564c4534c8"
FILEPATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Hunter/config.cmake"
)
URL "https://github.com/ruslo/hunter/archive/v0.19.40.tar.gz"
SHA1 "dd4850329b2e5ed91684f964f8bbc29328898d56"
FILEPATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Hunter/config.cmake"
)

set(XGBOOSTCPP_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}")

project(xgboostcpp VERSION 0.1.0) # WIP!

if(CMAKE_INTERPROCEDURAL_OPTIMIZATION)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) # for 3rd parties added by add_subdirectory
cmake_policy(SET CMP0069 NEW)
endif()

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# make sure these are before first hunter_add_package() call
option(XGBOOSTER_BUILD_TESTS "Build tests" ON)
option(XGBOOSTER_BUILD_APPS "Build applications" ON)
option(XGBOOSTER_SERIALIZE_WITH_BOOST "Serialize w/ boost" OFF) # hunter update
option(XGBOOSTER_SERIALIZE_WITH_CEREAL "Serialize w/ cereal" ON) # hunter update
option(XGBOOSTER_ADD_TO_STRING "Add local to_string definitions" OFF) # for android
option(XGBOOSTER_DO_LEAN "Build for prediction only (size reduction)" OFF)

###################
## Dependencies ###
###################

if(XGBOOSTER_SERIALIZE_WITH_BOOST)
# boost
hunter_add_package(Boost COMPONENTS filesystem system serialization iostreams)
find_package(Boost CONFIG REQUIRED filesystem system serialization iostreams)

# boost-pba
hunter_add_package(boost-pba)
find_package(boost-pba CONFIG REQUIRED)

set(xgboostcpp_boost_libs
boost-pba::boost-pba
Boost::filesystem
Boost::system
Boost::serialization
Boost::iostreams
)

endif()

# cereal
if(XGBOOSTER_SERIALIZE_WITH_CEREAL)
hunter_add_package(cereal)
Expand Down Expand Up @@ -85,4 +72,4 @@ endif()
## Project ###
##############

add_subdirectory(src)
add_subdirectory(src)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ may need to run:

```
git submodule update --init --recursive --quiet
```
```
18 changes: 11 additions & 7 deletions bin/build-android.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#!/bin/bash

TOOLCHAIN=android-ndk-r10e-api-19-armeabi-v7a-neon-hid-sections
TOOLCHAIN=android-ndk-r10e-api-19-armeabi-v7a-neon-hid-sections-lto

CONFIG=MinSizeRel

INSTALL="--strip"

ARGS=(
--verbose
--config Release
--fwd ANDROID=TRUE
HUNTER_CONFIGURATION_TYPES=Release
XGBOOSTER_SERIALIZE_WITH_BOOST=OFF
--config ${CONFIG}
--fwd
ANDROID=TRUE
HUNTER_CONFIGURATION_TYPES=${CONFIG}
XGBOOSTER_SERIALIZE_WITH_CEREAL=ON
XGBOOSTER_ADD_TO_STRING=ON
XGBOOSTER_DO_LEAN=${XGBOOSTER_DO_LEAN}
)

export HUNTER_ROOT=${HOME}/devel/ruslo/hunter
build.py --toolchain ${TOOLCHAIN} ${ARGS[@]} --clear
polly.py --toolchain ${TOOLCHAIN} ${ARGS[@]} ${INSTALL} --clear
17 changes: 16 additions & 1 deletion bin/build-libcxx.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
#!/bin/bash

build.py --toolchain libcxx --verbose --fwd HUNTER_CONFIGURATION_TYPES=Release --jobs 8 --clear --strip
CONFIG=MinSizeRel
TOOLCHAIN=osx-10-12-lto
INSTALL=--install

ARGS=(
--verbose
--config ${CONFIG}
--fwd
HUNTER_CONFIGURATION_TYPES=${CONFIG}
XGBOOSTER_SERIALIZE_WITH_CEREAL=ON
XGBOOSTER_ADD_TO_STRING=ON
)

polly.py --toolchain ${TOOLCHAIN} ${ARGS[@]} --jobs 8 ${INSTALL} --reconfig # --test




13 changes: 7 additions & 6 deletions bin/build-xcode.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/bin/bash

TOOLCHAIN=xcode

CONFIG=MinSizeRel

ARGS=(
--verbose
--config Release
--fwd HUNTER_CONFIGURATION_TYPES=Release
XGBOOSTER_SERIALIZE_WITH_BOOST=OFF
--config ${CONFIG}
--fwd HUNTER_CONFIGURATION_TYPES=${CONFIG}
XGBOOSTER_SERIALIZE_WITH_CEREAL=ON
--jobs 8
)

export HUNTER_ROOT=${HOME}/devel/ruslo/hunter
build.py --toolchain xcode ${ARGS[@]} --reconfig --install --open --test

build.py --toolchain ${TOOLCHAIN} ${ARGS[@]} --reconfig --install --open --test
8 changes: 2 additions & 6 deletions cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
set(XGBOOST_CMAKE_ARGS
XGBOOST_USE_HALF=ON
XGBOOST_USE_BOOST=ON
XGBOOST_DO_LEAN=ON
XGBOOST_ADD_TO_STRING=${XGBOOSTER_ADD_TO_STRING}
XGBOOST_USE_BOOST=${XGBOOSTER_SERIALIZE_WITH_BOOST}
XGBOOST_DO_LEAN=${XGBOOSTER_DO_LEAN}
XGBOOST_USE_CEREAL=${XGBOOSTER_SERIALIZE_WITH_CEREAL}
)

if(ANDROID)
list(APPEND XGBOOST_CMAKE_ARGS XGBOOST_ADD_TO_STRING=ON)
endif()

hunter_config(Boost VERSION ${HUNTER_Boost_VERSION} CMAKE_ARGS IOSTREAMS_NO_BZIP2=1)
hunter_config(xgboost VERSION ${HUNTER_xgboost_VERSION} CMAKE_ARGS ${XGBOOST_CMAKE_ARGS})
hunter_config(xgboost GIT_SUBMODULE "src/3rdparty/xgboost" CMAKE_ARGS ${XGBOOST_CMAKE_ARGS})
43 changes: 17 additions & 26 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
## Customize linker flags
include(CheckCCompilerFlag)
if(NOT MSVC)
check_c_compiler_flag("-Wl,-dead_strip" FLAG_dead_strip)
if(NOT FLAG_dead_strip)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections,--icf=safe")
else()
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-dead_strip")
set(CMAKE_EXE_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-dead_strip")
endif()
endif()

###############
### xgboost ###
###############

option(DRISHTI_USE_LOCAL_XGBOOST "Use local xgboost" ON)
if(DRISHTI_USE_LOCAL_XGBOOST)
option(SKIP_INSTALL "Avoid installation of submodule libraries" OFF)
hunter_add_package(xgboost)
find_package(xgboost CONFIG REQUIRED)

option(SKIP_INSTALL "Skip the package install" OFF)
option(XGBOOST_USE_BOOST "Use boost serialization" ${XGBOOSTER_SERIALIZE_WITH_BOOST})
option(XGBOOST_USE_CEREAL "Use cereal serialization" ${XGBOOSTER_SERIALIZE_WITH_CEREAL})
option(XGBOOST_ADD_TO_STRING "Add standard library std::to_string()" ${XGBOOSTER_ADD_TO_STRING})
option(XGBOOST_USE_HALF "Support half precision floating point storage" ON)
option(XGBOOST_DO_LEAN "Build lean library for evaluation only" OFF)

add_subdirectory(3rdparty/xgboost)
unset(SKIP_INSTALL CACHE)
add_library(xgboost::xgboost ALIAS xgboost)
set_property(TARGET xgboost PROPERTY FOLDER "libs/3rdparty")
target_include_directories(xgboost PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/3rdparty>")

else()
hunter_add_package(xgboost)
find_package(xgboost CONFIG REQUIRED)
endif()
add_subdirectory(lib)
add_subdirectory(test)

message("XGBOOST_USE_BOOST = ${XGBOOST_USE_BOOST}")
message("XGBOOST_USE_CEREAL = ${XGBOOST_USE_CEREAL}")
message("XGBOOSTER_SERIALIZE_WITH_BOOST = ${XGBOOSTER_SERIALIZE_WITH_BOOST}")
message("XGBOOSTER_SERIALIZE_WITH_CEREAL = ${XGBOOSTER_SERIALIZE_WITH_CEREAL}")

add_subdirectory(lib)
add_subdirectory(test)
14 changes: 2 additions & 12 deletions src/lib/xgboostcpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,19 @@ set(xgboostcpp_SRCS
to_string.h
)

if(XGBOOSTER_SERIALIZE_WITH_BOOST)
list(APPEND xgboostcpp_SRCS XGBoosterIOArchiveBoost.cpp)
endif()

if(XGBOOSTER_SERIALIZE_WITH_CEREAL)
list(APPEND xgboostcpp_SRCS XGBoosterIOArchiveCereal.cpp)
endif()

add_library(xgboostcpp "${xgboostcpp_SRCS}")
target_link_libraries(xgboostcpp PRIVATE xgboost::xgboost)

if(XGBOOSTER_SERIALIZE_WITH_BOOST)
target_link_libraries(xgboostcpp PRIVATE ${xgboostcpp_boost_libs})
target_compile_definitions(xgboostcpp PUBLIC XGBOOSTER_SERIALIZE_WITH_BOOST=1)
endif()

if(XGBOOSTER_SERIALIZE_WITH_CEREAL)
target_link_libraries(xgboostcpp PRIVATE cereal::cereal)
target_compile_definitions(xgboostcpp PUBLIC XGBOOSTER_SERIALIZE_WITH_CEREAL=1)
endif()

# Note: boost will optionally set
# * XGBOOST_USE_BOOST=1
# * XGBOOST_USE_CEREAL=1

set_property(TARGET xgboostcpp PROPERTY FOLDER "libs")
Expand All @@ -52,12 +42,12 @@ if(NOT is_ios)
)
endif()

if(XGBOOSTER_BUILD_TESTS)
# We can't run training if XGBOOSTER_DO_LEAN==ON
if(XGBOOSTER_BUILD_TESTS AND NOT XGBOOSTER_DO_LEAN)
if(NOT (ANDROID OR IOS))
add_subdirectory(ut)
endif()
endif()


###################
##### install #####
Expand Down
75 changes: 0 additions & 75 deletions src/lib/xgboostcpp/XGBoosterIOArchiveBoost.cpp

This file was deleted.

10 changes: 3 additions & 7 deletions src/lib/xgboostcpp/XGBoosterIOArchiveCereal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ template void XGBooster::Recipe::serialize<IArchive>(IArchive &ar, const unsigne
template void XGBooster::Impl::serialize<IArchive>(IArchive &ar, const unsigned int);
XGBOOSTCPP_NAMESPACE_END

template void xgboost::gbm::serialize(OArchive & ar, xgboost::gbm::IGradBooster &gb, const unsigned int version);
template void xgboost::gbm::serialize(OArchive & ar, xgboost::gbm::GBTree &gbt, const unsigned int version);
template void xgboost::gbm::serialize(OArchive & ar, xgboost::gbm::GBLinear &gbt, const unsigned int version);

template void xgboost::gbm::serialize(IArchive & ar, xgboost::gbm::IGradBooster &gb, const unsigned int version);
template void xgboost::gbm::serialize(IArchive & ar, xgboost::gbm::GBTree &gbt, const unsigned int version);
template void xgboost::gbm::serialize(IArchive & ar, xgboost::gbm::GBLinear &gbt, const unsigned int version);
template void xgboost::gbm::IGradBooster::serialize(OArchive & ar, const unsigned int version);
template void xgboost::gbm::GBTree::serialize(OArchive & ar, const unsigned int version);
template void xgboost::gbm::GBLinear::serialize(OArchive & ar, const unsigned int version);
Loading

0 comments on commit 505e38c

Please sign in to comment.