From 7fb701bcffe89b8024c5b1de7c6baa222ffc2ddf Mon Sep 17 00:00:00 2001 From: Chen Qin Date: Wed, 24 Apr 2019 15:57:09 -0700 Subject: [PATCH 1/3] [one dmlc-core] by default build with dmlc-core from xgboost, use RABIT_BUILD_DMLC=1 if use dmlc-core in rabit --- .gitmodules | 3 --- .travis.yml | 1 + CMakeLists.txt | 25 ++++++++++++++++++------- Makefile | 9 ++++++++- include/rabit/serializable.h | 3 +++ scripts/travis_script.sh | 10 +++++----- 6 files changed, 35 insertions(+), 16 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 8e517101..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "dmlc-core"] - path = dmlc-core - url = https://github.com/dmlc/dmlc-core diff --git a/.travis.yml b/.travis.yml index a2eff4dc..9359c713 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,6 +48,7 @@ addons: update: true before_install: + - git clone https://github.com/dmlc/dmlc-core - export TRAVIS=dmlc-core/scripts/travis/ - source ${TRAVIS}/travis_setup_env.sh - ${TRAVIS}/travis_osx_install.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 19882c32..300cbdad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ project(rabit VERSION 0.2.0) option(RABIT_BUILD_TESTS "Build rabit tests" OFF) option(RABIT_BUILD_MPI "Build MPI" OFF) +option(RABIT_BUILD_DMLC "Include DMLC_CORE in build" ON) add_library(rabit src/allreduce_base.cc src/allreduce_robust.cc src/engine.cc src/c_api.cc) add_library(rabit_base src/allreduce_base.cc src/engine_base.cc src/c_api.cc) @@ -26,13 +27,23 @@ if(RABIT_BUILD_TESTS) list(APPEND rabit_libs rabit_mock) # add to list to apply build settings, then remove endif() -foreach(lib ${rabit_libs}) - #include "./internal/utils.h" - target_include_directories(${lib} PUBLIC - "$" - "$" - ) -endforeach() +if(RABIT_BUILD_DMLC) + foreach(lib ${rabit_libs}) + #include "./internal/utils.h" + target_include_directories(${lib} PUBLIC + "$" + "$" + ) + endforeach() +else() + foreach(lib ${rabit_libs}) + #include "./internal/utils.h" + target_include_directories(${lib} PUBLIC + "$" + "$" + ) + endforeach() +endif() if(RABIT_BUILD_TESTS) list(REMOVE_ITEM rabit_libs "rabit_mock") # remove here to avoid installing it diff --git a/Makefile b/Makefile index 5599d4f3..7ca884b9 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,13 @@ OS := $(shell uname) +RABIT_BUILD_DMLC = 0 + +ifeq ($(RABIT_BUILD_DMLC),1) + DMLC=dmlc-core +else + DMLC=../dmlc-core +endif + export WARNFLAGS= -Wall -Wextra -Wno-unused-parameter -Wno-unknown-pragmas -std=c++11 export CFLAGS = -O3 $(WARNFLAGS) -I $(DMLC)/include -I include/ export LDFLAGS =-Llib @@ -74,7 +82,6 @@ ALIB= lib/librabit.a lib/librabit_empty.a lib/librabit_mock.a lib/librabit_base. MPISLIB= lib/librabit_mpi.so MPIALIB= lib/librabit_mpi.a HEADERS=src/*.h include/rabit/*.h include/rabit/internal/*.h -DMLC=dmlc-core .PHONY: clean all install mpi python lint doc doxygen diff --git a/include/rabit/serializable.h b/include/rabit/serializable.h index 514b7a70..84b2f1a6 100644 --- a/include/rabit/serializable.h +++ b/include/rabit/serializable.h @@ -9,7 +9,10 @@ #include #include #include "./internal/utils.h" + +#ifndef DMLC_IO_H_ #include "../../dmlc-core/include/dmlc/io.h" +#endif // DMLC_IO_H_ namespace rabit { /*! diff --git a/scripts/travis_script.sh b/scripts/travis_script.sh index ae150487..d97b0253 100755 --- a/scripts/travis_script.sh +++ b/scripts/travis_script.sh @@ -2,7 +2,7 @@ # main script of travis if [ ${TASK} == "lint" ]; then - make lint || exit -1 + make lint RABIT_BUILD_DMLC=1 || exit -1 fi if [ ${TASK} == "doc" ]; then @@ -11,24 +11,24 @@ if [ ${TASK} == "doc" ]; then fi if [ ${TASK} == "build" ]; then - make all || exit -1 + make all RABIT_BUILD_DMLC=1 || exit -1 fi if [ ${TASK} == "mpi-build" ]; then ./scripts/mpi_build.sh cd test - make mpi && make speed_test.mpi || exit -1 + make mpi RABIT_BUILD_DMLC=1 && make speed_test.mpi RABIT_BUILD_DMLC=1 || exit -1 fi if [ ${TASK} == "test" ]; then cd test - make all || exit -1 + make all RABIT_BUILD_DMLC=1 || exit -1 ../scripts/travis_runtest.sh || exit -1 fi if [ ${TASK} == "cmake-build" ]; then mkdir build cd build - cmake .. + cmake .. -DRABIT_BUILD_DMLC=ON make all || exit -1 fi \ No newline at end of file From cb17156e4d0c698ed8ee98b1467998e79570bfaf Mon Sep 17 00:00:00 2001 From: Chen Qin Date: Thu, 25 Apr 2019 21:07:18 -0700 Subject: [PATCH 2/3] remove dmlc-core --- dmlc-core | 1 - 1 file changed, 1 deletion(-) delete mode 160000 dmlc-core diff --git a/dmlc-core b/dmlc-core deleted file mode 160000 index 13d5acb8..00000000 --- a/dmlc-core +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 13d5acb8ba7e79550bbf2f730f1a3944ff0fa68b From b6174af6e233b8e7a3985a372e6180dbf88e356c Mon Sep 17 00:00:00 2001 From: Chen Qin Date: Thu, 25 Apr 2019 23:24:35 -0700 Subject: [PATCH 3/3] compatible with windows --- src/socket.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/socket.h b/src/socket.h index d6e6f597..c96f04d9 100644 --- a/src/socket.h +++ b/src/socket.h @@ -287,7 +287,7 @@ class TCPSocket : public Socket{ struct linger sl; sl.l_onoff = 1; /* non-zero value enables linger option in kernel */ sl.l_linger = timeout; /* timeout interval in seconds */ - if (setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &sl, sizeof(sl)) == -1) { + if (setsockopt(sockfd, SOL_SOCKET, SO_LINGER, reinterpret_cast(&sl), sizeof(sl)) == -1) { Socket::Error("SO_LINGER"); } }