Allow using external dmlc-core (#91)

* Set `RABIT_BUILD_DMLC=1` if use dmlc-core in rabit

* remove dmlc-core
This commit is contained in:
Chen Qin 2019-04-26 00:28:45 -07:00 committed by Jiaming Yuan
parent e3d51d3e62
commit 5c3b36f346
8 changed files with 36 additions and 18 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "dmlc-core"]
path = dmlc-core
url = https://github.com/dmlc/dmlc-core

View File

@ -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

View File

@ -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
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/dmlc-core/include>"
)
endforeach()
if(RABIT_BUILD_DMLC)
foreach(lib ${rabit_libs})
#include "./internal/utils.h"
target_include_directories(${lib} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/dmlc-core/include>"
)
endforeach()
else()
foreach(lib ${rabit_libs})
#include "./internal/utils.h"
target_include_directories(${lib} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../dmlc_core/include>"
)
endforeach()
endif()
if(RABIT_BUILD_TESTS)
list(REMOVE_ITEM rabit_libs "rabit_mock") # remove here to avoid installing it

View File

@ -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

@ -1 +0,0 @@
Subproject commit 13d5acb8ba7e79550bbf2f730f1a3944ff0fa68b

View File

@ -9,7 +9,10 @@
#include <vector>
#include <string>
#include "./internal/utils.h"
#ifndef DMLC_IO_H_
#include "../../dmlc-core/include/dmlc/io.h"
#endif // DMLC_IO_H_
namespace rabit {
/*!

View File

@ -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

View File

@ -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<char*>(&sl), sizeof(sl)) == -1) {
Socket::Error("SO_LINGER");
}
}