add sync module

This commit is contained in:
tqchen 2015-01-18 21:31:09 -08:00
parent 152e08974d
commit ba0b950a84
10 changed files with 42 additions and 29 deletions

View File

@ -2,7 +2,7 @@ export CC = gcc
export CXX = g++ export CXX = g++
export MPICXX = mpicxx export MPICXX = mpicxx
export LDFLAGS= -Lrabit/lib -pthread -lm export LDFLAGS= -Lrabit/lib -pthread -lm
export CFLAGS = -Wall -O3 -msse2 -Wno-unknown-pragmas -fPIC -Irabit/include export CFLAGS = -Wall -O3 -msse2 -Wno-unknown-pragmas -fPIC
ifeq ($(no_omp),1) ifeq ($(no_omp),1)
CFLAGS += -DDISABLE_OPENMP CFLAGS += -DDISABLE_OPENMP
@ -23,47 +23,49 @@ OBJ = updater.o gbm.o io.o main.o
MPIBIN = xgboost.mpi MPIBIN = xgboost.mpi
SLIB = wrapper/libxgboostwrapper.so SLIB = wrapper/libxgboostwrapper.so
.PHONY: clean all mpi python Rpack librabit librabit_mpi .PHONY: clean all mpi python Rpack
all: $(BIN) $(OBJ) $(SLIB) $(MOCKBIN) all: $(BIN) $(OBJ) $(SLIB) $(MOCKBIN)
mpi: $(MPIBIN) mpi: $(MPIBIN)
# rules to get rabit library
librabit:
if [ ! -d rabit ]; then git clone https://github.com/tqchen/rabit.git; fi
cd rabit;make lib/librabit.a lib/librabit_mock.a; cd -
librabit_mpi:
if [ ! -d rabit ]; then git clone https://github.com/tqchen/rabit.git; fi
cd rabit;make lib/librabit_mpi.a; cd -
python: wrapper/libxgboostwrapper.so python: wrapper/libxgboostwrapper.so
# now the wrapper takes in two files. io and wrapper part # now the wrapper takes in two files. io and wrapper part
updater.o: src/tree/updater.cpp src/tree/*.hpp src/*.h src/tree/*.h src/utils/*.h updater.o: src/tree/updater.cpp src/tree/*.hpp src/*.h src/tree/*.h src/utils/*.h
gbm.o: src/gbm/gbm.cpp src/gbm/*.hpp src/gbm/*.h gbm.o: src/gbm/gbm.cpp src/gbm/*.hpp src/gbm/*.h
io.o: src/io/io.cpp src/io/*.hpp src/utils/*.h src/learner/dmatrix.h src/*.h io.o: src/io/io.cpp src/io/*.hpp src/utils/*.h src/learner/dmatrix.h src/*.h
main.o: src/xgboost_main.cpp src/utils/*.h src/*.h src/learner/*.hpp src/learner/*.h main.o: src/xgboost_main.cpp src/utils/*.h src/*.h src/learner/*.hpp src/learner/*.h
xgboost.mpi: updater.o gbm.o io.o main.o librabit_mpi xgboost.mpi: updater.o gbm.o io.o main.o subtree/rabit/lib/librabit_mpi.a
xgboost.mock: updater.o gbm.o io.o main.o librabit xgboost.mock: updater.o gbm.o io.o main.o subtree/rabit/lib/librabit_mock.a
xgboost: updater.o gbm.o io.o main.o librabit xgboost: updater.o gbm.o io.o main.o subtree/rabit/lib/librabit.a
wrapper/libxgboostwrapper.so: wrapper/xgboost_wrapper.cpp src/utils/*.h src/*.h src/learner/*.hpp src/learner/*.h updater.o gbm.o io.o librabit wrapper/libxgboostwrapper.so: wrapper/xgboost_wrapper.cpp src/utils/*.h src/*.h src/learner/*.hpp src/learner/*.h updater.o gbm.o io.o subtree/rabit/lib/librabit.a
# dependency on rabit
subtree/rabit/lib/librabit.a: subtree/rabit/src/engine.cc
cd subtree/rabit;make lib/librabit.a; cd -
subtree/rabit/lib/librabit_empty.a: subtree/rabit/src/engine_empty.cc
cd subtree/rabit;make lib/librabit_empty.a; cd -
subtree/rabit/lib/librabit_mock.a: subtree/rabit/src/engine_mock.cc
cd subtree/rabit;make lib/librabit_mock.a; cd -
subtree/rabit/lib/librabit_mpi.a: subtree/rabit/src/engine_mpi.cc
cd subtree/rabit;make lib/librabit_mpi.a; cd -
$(BIN) : $(BIN) :
$(CXX) $(CFLAGS) -o $@ $(filter %.cpp %.o %.c, $^) $(LDFLAGS) -lrabit $(CXX) $(CFLAGS) -o $@ $(filter %.cpp %.o %.c %.cc %.a, $^) $(LDFLAGS)
$(MOCKBIN) : $(MOCKBIN) :
$(CXX) $(CFLAGS) -o $@ $(filter %.cpp %.o %.c, $^) $(LDFLAGS) -lrabit_mock $(CXX) $(CFLAGS) -o $@ $(filter %.cpp %.o %.c %.cc %.a, $^) $(LDFLAGS)
$(SLIB) : $(SLIB) :
$(CXX) $(CFLAGS) -fPIC -shared -o $@ $(filter %.cpp %.o %.c, $^) $(LDFLAGS) -lrabit $(CXX) $(CFLAGS) -fPIC -shared -o $@ $(filter %.cpp %.o %.c %.a %.cc, $^) $(LDFLAGS)
$(OBJ) : $(OBJ) :
$(CXX) -c $(CFLAGS) -o $@ $(firstword $(filter %.cpp %.c, $^) ) $(CXX) -c $(CFLAGS) -o $@ $(firstword $(filter %.cpp %.c %.cc, $^) )
$(MPIOBJ) : $(MPIOBJ) :
$(MPICXX) -c $(CFLAGS) -o $@ $(firstword $(filter %.cpp %.c, $^) ) $(MPICXX) -c $(CFLAGS) -o $@ $(firstword $(filter %.cpp %.c, $^) )
$(MPIBIN) : $(MPIBIN) :
$(MPICXX) $(CFLAGS) -o $@ $(filter %.cpp %.o %.c, $^) $(LDFLAGS) -lrabit_mpi $(MPICXX) $(CFLAGS) -o $@ $(filter %.cpp %.o %.c %.cc %.a, $^) $(LDFLAGS)
install: install:
cp -f -r $(BIN) $(INSTALL_PATH) cp -f -r $(BIN) $(INSTALL_PATH)
@ -91,3 +93,4 @@ Rpack:
clean: clean:
$(RM) $(OBJ) $(BIN) $(MPIBIN) $(MPIOBJ) $(SLIB) *.o */*.o */*/*.o *~ */*~ */*/*~ $(RM) $(OBJ) $(BIN) $(MPIBIN) $(MPIOBJ) $(SLIB) *.o */*.o */*/*.o *~ */*~ */*/*~
cd subtree/rabit; make clean; cd -

View File

@ -11,8 +11,7 @@
#include <cmath> #include <cmath>
#include <climits> #include <climits>
#include <algorithm> #include <algorithm>
// rabit library for synchronization #include "../sync/sync.h"
#include <rabit.h>
#include "./evaluation.h" #include "./evaluation.h"
#include "./helper_utils.h" #include "./helper_utils.h"

View File

@ -10,8 +10,7 @@
#include <utility> #include <utility>
#include <string> #include <string>
#include <limits> #include <limits>
// rabit library for synchronization #include "../sync/sync.h"
#include <rabit.h>
#include "../utils/io.h" #include "../utils/io.h"
#include "../utils/base64.h" #include "../utils/base64.h"
#include "./objective.h" #include "./objective.h"

12
src/sync/sync.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef XGBOOST_SYNC_H_
#define XGBOOST_SYNC_H_
/*!
* \file sync.h
* \brief the synchronization module of rabit
* redirects to subtree rabit header
* \author Tianqi Chen
*/
#include "../../subtree/rabit/include/rabit.h"
#endif // XGBOOST_SYNC_H_

View File

@ -8,7 +8,7 @@
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
#include <limits> #include <limits>
#include <rabit.h> #include "../sync/sync.h"
#include "../utils/random.h" #include "../utils/random.h"
#include "../utils/quantile.h" #include "../utils/quantile.h"

View File

@ -6,7 +6,7 @@
* and construct a tree * and construct a tree
* \author Tianqi Chen * \author Tianqi Chen
*/ */
#include <rabit.h> #include "../sync/sync.h"
#include "../utils/bitmap.h" #include "../utils/bitmap.h"
#include "../utils/io.h" #include "../utils/io.h"
#include "./updater_colmaker-inl.hpp" #include "./updater_colmaker-inl.hpp"

View File

@ -7,7 +7,7 @@
*/ */
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
#include <rabit.h> #include "../sync/sync.h"
#include "../utils/quantile.h" #include "../utils/quantile.h"
#include "../utils/group_data.h" #include "../utils/group_data.h"
#include "./updater_basemaker-inl.hpp" #include "./updater_basemaker-inl.hpp"

View File

@ -7,7 +7,7 @@
*/ */
#include <vector> #include <vector>
#include <limits> #include <limits>
#include <rabit.h> #include "../sync/sync.h"
#include "./param.h" #include "./param.h"
#include "./updater.h" #include "./updater.h"
#include "../utils/omp.h" #include "../utils/omp.h"

View File

@ -7,7 +7,7 @@
*/ */
#include <vector> #include <vector>
#include <limits> #include <limits>
#include <rabit.h> #include "../sync/sync.h"
#include "./updater.h" #include "./updater.h"
namespace xgboost { namespace xgboost {

View File

@ -4,7 +4,7 @@
#include <ctime> #include <ctime>
#include <string> #include <string>
#include <cstring> #include <cstring>
#include <rabit.h> #include "./sync/sync.h"
#include "io/io.h" #include "io/io.h"
#include "utils/utils.h" #include "utils/utils.h"
#include "utils/config.h" #include "utils/config.h"