refactor: librabit

This commit is contained in:
tqchen 2016-02-27 10:14:26 -08:00
parent 73b6e9bbd0
commit 7479791f6a
33 changed files with 412 additions and 801 deletions

View File

@ -22,17 +22,16 @@ BPATH=.
# objectives that makes up rabit library # objectives that makes up rabit library
MPIOBJ= $(BPATH)/engine_mpi.o MPIOBJ= $(BPATH)/engine_mpi.o
OBJ= $(BPATH)/allreduce_base.o $(BPATH)/allreduce_robust.o $(BPATH)/engine.o $(BPATH)/engine_empty.o $(BPATH)/engine_mock.o\ OBJ= $(BPATH)/allreduce_base.o $(BPATH)/allreduce_robust.o $(BPATH)/engine.o $(BPATH)/engine_empty.o $(BPATH)/engine_mock.o\
$(BPATH)/rabit_wrapper.o $(BPATH)/engine_base.o $(BPATH)/c_api.o $(BPATH)/engine_base.o
SLIB= wrapper/librabit_wrapper.so wrapper/librabit_wrapper_mock.so wrapper/librabit_wrapper_mpi.so SLIB= lib/librabit.so lib/librabit_mpi.so lib/librabit_mock.so lib/librabit_base.so
ALIB= lib/librabit.a lib/librabit_mpi.a lib/librabit_empty.a lib/librabit_mock.a lib/librabit_base.a ALIB= lib/librabit.a lib/librabit_mpi.a lib/librabit_empty.a lib/librabit_mock.a lib/librabit_base.a
HEADERS=src/*.h include/*.h include/rabit/*.h HEADERS=src/*.h include/rabit/*.h include/rabit/internal/*.h
DMLC=dmlc-core DMLC=dmlc-core
.PHONY: clean all install mpi python lint doc doxygen .PHONY: clean all install mpi python lint doc doxygen
all: lib/librabit.a lib/librabit_mock.a wrapper/librabit_wrapper.so wrapper/librabit_wrapper_mock.so lib/librabit_base.a all: lib/librabit.a lib/librabit_mock.a lib/librabit.so lib/librabit_base.a lib/librabit_mock.so
mpi: lib/librabit_mpi.a wrapper/librabit_wrapper_mpi.so mpi: lib/librabit_mpi.a lib/librabit_mpi.so
python: wrapper/librabit_wrapper.so wrapper/librabit_wrapper_mock.so
$(BPATH)/allreduce_base.o: src/allreduce_base.cc $(HEADERS) $(BPATH)/allreduce_base.o: src/allreduce_base.cc $(HEADERS)
$(BPATH)/engine.o: src/engine.cc $(HEADERS) $(BPATH)/engine.o: src/engine.cc $(HEADERS)
@ -41,17 +40,13 @@ $(BPATH)/engine_mpi.o: src/engine_mpi.cc $(HEADERS)
$(BPATH)/engine_empty.o: src/engine_empty.cc $(HEADERS) $(BPATH)/engine_empty.o: src/engine_empty.cc $(HEADERS)
$(BPATH)/engine_mock.o: src/engine_mock.cc $(HEADERS) $(BPATH)/engine_mock.o: src/engine_mock.cc $(HEADERS)
$(BPATH)/engine_base.o: src/engine_base.cc $(HEADERS) $(BPATH)/engine_base.o: src/engine_base.cc $(HEADERS)
$(BPATH)/c_api.o: src/c_api.cc $(HEADERS)
lib/librabit.a: $(BPATH)/allreduce_base.o $(BPATH)/allreduce_robust.o $(BPATH)/engine.o lib/librabit.a lib/librabit.so: $(BPATH)/allreduce_base.o $(BPATH)/allreduce_robust.o $(BPATH)/engine.o $(BPATH)/c_api.o
lib/librabit_base.a: $(BPATH)/allreduce_base.o $(BPATH)/engine_base.o lib/librabit_base.a lib/librabit_base.so: $(BPATH)/allreduce_base.o $(BPATH)/engine_base.o $(BPATH)/c_api.o
lib/librabit_mock.a: $(BPATH)/allreduce_base.o $(BPATH)/allreduce_robust.o $(BPATH)/engine_mock.o lib/librabit_mock.a lib/librabit_mock.so: $(BPATH)/allreduce_base.o $(BPATH)/allreduce_robust.o $(BPATH)/engine_mock.o $(BPATH)/c_api.o
lib/librabit_empty.a: $(BPATH)/engine_empty.o lib/librabit_empty.a: $(BPATH)/engine_empty.o $(BPATH)/c_api.o
lib/librabit_mpi.a: $(MPIOBJ) lib/librabit_mpi.a lib/librabit_mpi.so: $(MPIOBJ)
# wrapper code
$(BPATH)/rabit_wrapper.o: wrapper/rabit_wrapper.cc
wrapper/librabit_wrapper.so: $(BPATH)/rabit_wrapper.o lib/librabit.a
wrapper/librabit_wrapper_mock.so: $(BPATH)/rabit_wrapper.o lib/librabit_mock.a
wrapper/librabit_wrapper_mpi.so: $(BPATH)/rabit_wrapper.o lib/librabit_mpi.a
$(OBJ) : $(OBJ) :
$(CXX) -c $(CFLAGS) -o $@ $(firstword $(filter %.cpp %.c %.cc, $^) ) $(CXX) -c $(CFLAGS) -o $@ $(firstword $(filter %.cpp %.c %.cc, $^) )
@ -66,11 +61,10 @@ $(SLIB) :
$(CXX) $(CFLAGS) -shared -o $@ $(filter %.cpp %.o %.c %.cc %.a, $^) $(LDFLAGS) $(CXX) $(CFLAGS) -shared -o $@ $(filter %.cpp %.o %.c %.cc %.a, $^) $(LDFLAGS)
lint: lint:
$(DMLC)/scripts/lint.py rabit $(LINT_LANG) src include wrapper $(DMLC)/scripts/lint.py rabit $(LINT_LANG) src include
doc doxygen: doc doxygen:
cd include; doxygen ../doc/Doxyfile; cd - cd include; doxygen ../doc/Doxyfile; cd -
clean: clean:
$(RM) $(OBJ) $(MPIOBJ) $(ALIB) $(MPIALIB) $(SLIB) *~ src/*~ include/*~ include/*/*~ wrapper/*~ $(RM) $(OBJ) $(MPIOBJ) $(ALIB) $(MPIALIB) $(SLIB) *~ src/*~ include/*~ include/*/*~

View File

@ -95,7 +95,7 @@ WARN_LOGFILE =
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# configuration options related to the input files # configuration options related to the input files
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
INPUT = . dmlc INPUT = rabit dmlc
INPUT_ENCODING = UTF-8 INPUT_ENCODING = UTF-8
FILE_PATTERNS = FILE_PATTERNS =
RECURSIVE = NO RECURSIVE = NO

View File

@ -7,7 +7,7 @@ import sys
import numpy as np import numpy as np
# import rabit, the tracker script will setup the lib path correctly # import rabit, the tracker script will setup the lib path correctly
# for normal run without tracker script, add following line # for normal run without tracker script, add following line
# sys.path.append(os.path.dirname(__file__) + '/../wrapper') # sys.path.append(os.path.dirname(__file__) + '/../python')
import rabit import rabit
rabit.init() rabit.init()

View File

@ -1,7 +0,0 @@
Library Header Files
====
* This folder contains all the header needed to use the library
* To use it, add the "include" folder to the search path of the compiler
* User only needs to know [rabit.h](rabit.h) and [rabit_serializable.h](rabit_serializable.h) in order to use the library
* Folder [rabit](rabit) contains headers for internal engine and template's implementation
* Not all .h files in the project are in the "include" folder, .h files that are internally used by the library remain at [src](../src)

135
include/rabit/c_api.h Normal file
View File

@ -0,0 +1,135 @@
/*!
* Copyright by Contributors
* \file rabit_c_api.h
* \author Tianqi Chen
* \brief a C style API of rabit.
*/
#ifndef RABIT_C_API_H_
#define RABIT_C_API_H_
#ifdef __cplusplus
#define RABIT_EXTERN_C extern "C"
#endif
#if defined(_MSC_VER) || defined(_WIN32)
#define RABIT_DLL RABIT_EXTERN_C __declspec(dllexport)
#else
#define RABIT_DLL RABIT_EXTERN_C
#endif
// manually define unsign long
typedef unsigned long rbt_ulong; // NOLINT(*)
/*!
* \brief intialize the rabit module,
* call this once before using anything
* The additional arguments is not necessary.
* Usually rabit will detect settings
* from environment variables.
* \param argc number of arguments in argv
* \param argv the array of input arguments
*/
RABIT_DLL void RabitInit(int argc, char *argv[]);
/*!
* \brief finalize the rabit engine,
* call this function after you finished all jobs.
*/
RABIT_DLL void RabitFinalize();
/*! \brief get rank of current process */
RABIT_DLL int RabitGetRank();
/*! \brief get total number of process */
RABIT_DLL int RabitGetWorldSize();
/*!
* \brief print the msg to the tracker,
* this function can be used to communicate the information of the progress to
* the user who monitors the tracker
* \param msg the message to be printed
*/
RABIT_DLL void RabitTrackerPrint(const char *msg);
/*!
* \brief get name of processor
* \param out_name hold output string
* \param out_len hold length of output string
* \param max_len maximum buffer length of input
*/
RABIT_DLL void RabitGetProcessorName(char *out_name,
rbt_ulong *out_len,
rbt_ulong max_len);
/*!
* \brief broadcast an memory region to all others from root
*
* Example: int a = 1; Broadcast(&a, sizeof(a), root);
* \param sendrecv_data the pointer to send or recive buffer,
* \param size the size of the data
* \param root the root of process
*/
RABIT_DLL void RabitBroadcast(void *sendrecv_data,
rbt_ulong size, int root);
/*!
* \brief perform in-place allreduce, on sendrecvbuf
* this function is NOT thread-safe
*
* Example Usage: the following code gives sum of the result
* vector<int> data(10);
* ...
* Allreduce<op::Sum>(&data[0], data.size());
* ...
* \param sendrecvbuf buffer for both sending and recving data
* \param count number of elements to be reduced
* \param enum_dtype the enumeration of data type, see rabit::engine::mpi::DataType in engine.h of rabit include
* \param enum_op the enumeration of operation type, see rabit::engine::mpi::OpType in engine.h of rabit
* \param prepare_fun Lazy preprocessing function, if it is not NULL, prepare_fun(prepare_arg)
* will be called by the function before performing Allreduce, to intialize the data in sendrecvbuf_.
* If the result of Allreduce can be recovered directly, then prepare_func will NOT be called
* \param prepare_arg argument used to passed into the lazy preprocessing function
*/
RABIT_DLL void RabitAllreduce(void *sendrecvbuf,
size_t count,
int enum_dtype,
int enum_op,
void (*prepare_fun)(void *arg),
void *prepare_arg);
/*!
* \brief load latest check point
* \param out_global_model hold output of serialized global_model
* \param out_global_len the output length of serialized global model
* \param out_local_model hold output of serialized local_model, can be NULL
* \param out_local_len the output length of serialized local model, can be NULL
*
* \return the version number of check point loaded
* if returned version == 0, this means no model has been CheckPointed
* nothing will be touched
*/
RABIT_DLL int RabitLoadCheckPoint(char **out_global_model,
rbt_ulong *out_global_len,
char **out_local_model,
rbt_ulong *out_local_len);
/*!
* \brief checkpoint the model, meaning we finished a stage of execution
* every time we call check point, there is a version number which will increase by one
*
* \param global_model hold content of serialized global_model
* \param global_len the content length of serialized global model
* \param local_model hold content of serialized local_model, can be NULL
* \param local_len the content length of serialized local model, can be NULL
*
* NOTE: local_model requires explicit replication of the model for fault-tolerance, which will
* bring replication cost in CheckPoint function. global_model do not need explicit replication.
* So only CheckPoint with global_model if possible
*/
RABIT_DLL void RabitCheckPoint(const char *global_model,
rbt_ulong global_len,
const char *local_model,
rbt_ulong local_len);
/*!
* \return version number of current stored model,
* which means how many calls to CheckPoint we made so far
*/
RABIT_DLL int RabitVersionNumber();
#endif // RABIT_C_API_H_

View File

@ -4,10 +4,10 @@
* \brief This file defines the core interface of rabit library * \brief This file defines the core interface of rabit library
* \author Tianqi Chen, Nacho, Tianyi * \author Tianqi Chen, Nacho, Tianyi
*/ */
#ifndef RABIT_ENGINE_H_ #ifndef RABIT_INTERNAL_ENGINE_H_
#define RABIT_ENGINE_H_ #define RABIT_INTERNAL_ENGINE_H_
#include <string> #include <string>
#include "../rabit_serializable.h" #include "../serializable.h"
namespace MPI { namespace MPI {
/*! \brief MPI data type just to be compatible with MPI reduce function*/ /*! \brief MPI data type just to be compatible with MPI reduce function*/
@ -241,7 +241,8 @@ class ReduceHandle {
* \param prepare_arg argument used to pass into the lazy preprocessing function * \param prepare_arg argument used to pass into the lazy preprocessing function
*/ */
void Allreduce(void *sendrecvbuf, void Allreduce(void *sendrecvbuf,
size_t type_nbytes, size_t count, size_t type_nbytes,
size_t count,
IEngine::PreprocFunction prepare_fun = NULL, IEngine::PreprocFunction prepare_fun = NULL,
void *prepare_arg = NULL); void *prepare_arg = NULL);
/*! \return the number of bytes occupied by the type */ /*! \return the number of bytes occupied by the type */
@ -259,4 +260,4 @@ class ReduceHandle {
}; };
} // namespace engine } // namespace engine
} // namespace rabit } // namespace rabit
#endif // RABIT_ENGINE_H_ #endif // RABIT_INTERNAL_ENGINE_H_

View File

@ -4,15 +4,15 @@
* \brief utilities with different serializable implementations * \brief utilities with different serializable implementations
* \author Tianqi Chen * \author Tianqi Chen
*/ */
#ifndef RABIT_IO_H_ #ifndef RABIT_INTERNAL_IO_H_
#define RABIT_IO_H_ #define RABIT_INTERNAL_IO_H_
#include <cstdio> #include <cstdio>
#include <vector> #include <vector>
#include <cstring> #include <cstring>
#include <string> #include <string>
#include <algorithm> #include <algorithm>
#include "./utils.h" #include "./utils.h"
#include "../rabit_serializable.h" #include "../serializable.h"
namespace rabit { namespace rabit {
namespace utils { namespace utils {
@ -103,4 +103,4 @@ struct MemoryBufferStream : public SeekStream {
}; // class MemoryBufferStream }; // class MemoryBufferStream
} // namespace utils } // namespace utils
} // namespace rabit } // namespace rabit
#endif // RABIT_IO_H_ #endif // RABIT_INTERNAL_IO_H_

View File

@ -5,8 +5,8 @@
* *
* \author Tianqi Chen * \author Tianqi Chen
*/ */
#ifndef RABIT_RABIT_INL_H_ #ifndef RABIT_INTERNAL_RABIT_INL_H_
#define RABIT_RABIT_INL_H_ #define RABIT_INTERNAL_RABIT_INL_H_
// use engine for implementation // use engine for implementation
#include <vector> #include <vector>
#include <string> #include <string>
@ -325,4 +325,4 @@ inline void SerializeReducer<DType>::Allreduce(DType *sendrecvobj,
} }
#endif #endif
} // namespace rabit } // namespace rabit
#endif // RABIT_RABIT_INL_H_ #endif // RABIT_INTERNAL_RABIT_INL_H_

View File

@ -4,8 +4,8 @@
* \brief This file defines the utils for timing * \brief This file defines the utils for timing
* \author Tianqi Chen, Nacho, Tianyi * \author Tianqi Chen, Nacho, Tianyi
*/ */
#ifndef RABIT_TIMER_H_ #ifndef RABIT_INTERNAL_TIMER_H_
#define RABIT_TIMER_H_ #define RABIT_INTERNAL_TIMER_H_
#include <time.h> #include <time.h>
#ifdef __MACH__ #ifdef __MACH__
#include <mach/clock.h> #include <mach/clock.h>
@ -38,4 +38,4 @@ inline double GetTime(void) {
} }
} // namespace utils } // namespace utils
} // namespace rabit } // namespace rabit
#endif // RABIT_TIMER_H_ #endif // RABIT_INTERNAL_TIMER_H_

View File

@ -4,8 +4,8 @@
* \brief simple utils to support the code * \brief simple utils to support the code
* \author Tianqi Chen * \author Tianqi Chen
*/ */
#ifndef RABIT_UTILS_H_ #ifndef RABIT_INTERNAL_UTILS_H_
#define RABIT_UTILS_H_ #define RABIT_INTERNAL_UTILS_H_
#define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS
#include <cstdio> #include <cstdio>
#include <string> #include <string>
@ -188,4 +188,4 @@ inline const char* BeginPtr(const std::string &str) {
return &str[0]; return &str[0];
} }
} // namespace rabit } // namespace rabit
#endif // RABIT_UTILS_H_ #endif // RABIT_INTERNAL_UTILS_H_

View File

@ -22,15 +22,24 @@
#if DMLC_USE_CXX11 #if DMLC_USE_CXX11
#include <functional> #include <functional>
#endif // C++11 #endif // C++11
// contains definition of Serializable
#include "./rabit_serializable.h"
// engine definition of rabit, defines internal implementation // engine definition of rabit, defines internal implementation
// to use rabit interface, there is no need to read engine.h // to use rabit interface, there is no need to read engine.h
// rabit.h and serializable.h are enough to use the interface // rabit.h and serializable.h are enough to use the interface
#include "./rabit/engine.h" #include "./internal/engine.h"
/*! \brief rabit namespace */ /*! \brief rabit namespace */
namespace rabit { namespace rabit {
/*!
* \brief defines stream used in rabit
* see definition of Stream in dmlc/io.h
*/
typedef dmlc::Stream Stream;
/*!
* \brief defines serializable objects used in rabit
* see definition of Serializable in dmlc/io.h
*/
typedef dmlc::Serializable Serializable;
/*! /*!
* \brief reduction operators namespace * \brief reduction operators namespace
*/ */
@ -65,16 +74,16 @@ inline void Init(int argc, char *argv[]);
/*! /*!
* \brief finalizes the rabit engine, call this function after you finished with all the jobs * \brief finalizes the rabit engine, call this function after you finished with all the jobs
*/ */
inline void Finalize(void); inline void Finalize();
/*! \brief gets rank of the current process */ /*! \brief gets rank of the current process */
inline int GetRank(void); inline int GetRank();
/*! \brief gets total number of processes */ /*! \brief gets total number of processes */
inline int GetWorldSize(void); inline int GetWorldSize();
/*! \brief whether rabit env is in distributed mode */ /*! \brief whether rabit env is in distributed mode */
inline bool IsDistributed(void); inline bool IsDistributed();
/*! \brief gets processor's name */ /*! \brief gets processor's name */
inline std::string GetProcessorName(void); inline std::string GetProcessorName();
/*! /*!
* \brief prints the msg to the tracker, * \brief prints the msg to the tracker,
* this function can be used to communicate progress information to * this function can be used to communicate progress information to
@ -241,7 +250,7 @@ inline void LazyCheckPoint(const Serializable *global_model);
* which means how many calls to CheckPoint we made so far * which means how many calls to CheckPoint we made so far
* \sa LoadCheckPoint, CheckPoint * \sa LoadCheckPoint, CheckPoint
*/ */
inline int VersionNumber(void); inline int VersionNumber();
// ----- extensions that allow customized reducer ------ // ----- extensions that allow customized reducer ------
// helper class to do customized reduce, user do not need to know the type // helper class to do customized reduce, user do not need to know the type
namespace engine { namespace engine {
@ -258,7 +267,7 @@ class ReduceHandle;
template<typename DType, void (*freduce)(DType &dst, const DType &src)> // NOLINT(*) template<typename DType, void (*freduce)(DType &dst, const DType &src)> // NOLINT(*)
class Reducer { class Reducer {
public: public:
Reducer(void); Reducer();
/*! /*!
* \brief customized in-place all reduce operation * \brief customized in-place all reduce operation
* \param sendrecvbuf the in place send-recv buffer * \param sendrecvbuf the in place send-recv buffer
@ -299,7 +308,7 @@ class Reducer {
template<typename DType> template<typename DType>
class SerializeReducer { class SerializeReducer {
public: public:
SerializeReducer(void); SerializeReducer();
/*! /*!
* \brief customized in-place all reduce operation * \brief customized in-place all reduce operation
* \param sendrecvobj pointer to the array of objects to be reduced * \param sendrecvobj pointer to the array of objects to be reduced
@ -338,5 +347,6 @@ class SerializeReducer {
}; };
} // namespace rabit } // namespace rabit
// implementation of template functions // implementation of template functions
#include "./rabit/rabit-inl.h" #include "./internal/
rabit-inl.h"
#endif // RABIT_RABIT_H_ // NOLINT(*) #endif // RABIT_RABIT_H_ // NOLINT(*)

View File

@ -1,6 +1,6 @@
/*! /*!
* Copyright (c) 2014 by Contributors * Copyright (c) 2014 by Contributors
* \file rabit_serializable.h * \file serializable.h
* \brief defines serializable interface of rabit * \brief defines serializable interface of rabit
* \author Tianqi Chen * \author Tianqi Chen
*/ */
@ -8,8 +8,8 @@
#define RABIT_SERIALIZABLE_H_ #define RABIT_SERIALIZABLE_H_
#include <vector> #include <vector>
#include <string> #include <string>
#include "./rabit/utils.h" #include "./internal/utils.h"
#include "./dmlc/io.h" #include "../dmlc/io.h"
namespace rabit { namespace rabit {
/*! /*!

View File

@ -14,29 +14,58 @@ import numpy as np
# version information about the doc # version information about the doc
__version__ = '1.0' __version__ = '1.0'
if os.name == 'nt':
WRAPPER_PATH = os.path.dirname(__file__) + '\\..\\windows\\x64\\Release\\rabit_wrapper%s.dll'
else:
WRAPPER_PATH = os.path.dirname(__file__) + '/librabit_wrapper%s.so'
_LIB = None _LIB = None
def _find_lib_path(dll_name):
"""Find the rabit dynamic library files.
Returns
-------
lib_path: list(string)
List of all found library path to rabit
"""
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
# make pythonpack hack: copy this directory one level upper for setup.py
dll_path = [curr_path,
os.path.join(curr_path, '../lib/'),
os.path.join(curr_path, './lib/')]
if os.name == 'nt':
dll_path = [os.path.join(p, dll_name) for p in dll_path]
else:
dll_path = [os.path.join(p, dll_name) for p in dll_path]
lib_path = [p for p in dll_path if os.path.exists(p) and os.path.isfile(p)]
#From github issues, most of installation errors come from machines w/o compilers
if len(lib_path) == 0 and not os.environ.get('XGBOOST_BUILD_DOC', False):
raise RuntimeError(
'Cannot find Rabit Libarary in the candicate path, ' +
'did you install compilers and run build.sh in root path?\n'
'List of candidates:\n' + ('\n'.join(dll_path)))
return lib_path
# load in xgboost library # load in xgboost library
def _loadlib(lib='standard'): def _loadlib(lib='standard', lib_dll=None):
"""Load rabit library.""" """Load rabit library."""
global _LIB global _LIB
if _LIB != None: if _LIB is not None:
warnings.warn('rabit.int call was ignored because it has'\ warnings.warn('rabit.int call was ignored because it has'\
' already been initialized', level=2) ' already been initialized', level=2)
return return
if lib_dll is not None:
_LIB = lib_dll
return
if lib == 'standard': if lib == 'standard':
_LIB = ctypes.cdll.LoadLibrary(WRAPPER_PATH % '') dll_name = 'librabit'
elif lib == 'mock':
_LIB = ctypes.cdll.LoadLibrary(WRAPPER_PATH % '_mock')
elif lib == 'mpi':
_LIB = ctypes.cdll.LoadLibrary(WRAPPER_PATH % '_mpi')
else: else:
raise Exception('unknown rabit lib %s, can be standard, mock, mpi' % lib) dll_name = 'librabit_' + lib
if os.name == 'nt':
dll_name += '.dll'
else:
dll_name += '.so'
_LIB = ctypes.cdll.LoadLibrary(_find_lib_path(dll_name)[0])
_LIB.RabitGetRank.restype = ctypes.c_int _LIB.RabitGetRank.restype = ctypes.c_int
_LIB.RabitGetWorldSize.restype = ctypes.c_int _LIB.RabitGetWorldSize.restype = ctypes.c_int
_LIB.RabitVersionNumber.restype = ctypes.c_int _LIB.RabitVersionNumber.restype = ctypes.c_int
@ -53,7 +82,7 @@ MIN = 1
SUM = 2 SUM = 2
BITOR = 3 BITOR = 3
def init(args=None, lib='standard'): def init(args=None, lib='standard', lib_dll=None):
"""Intialize the rabit module, call this once before using anything. """Intialize the rabit module, call this once before using anything.
Parameters Parameters
@ -62,12 +91,16 @@ def init(args=None, lib='standard'):
The list of arguments used to initialized the rabit The list of arguments used to initialized the rabit
usually you need to pass in sys.argv. usually you need to pass in sys.argv.
Defaults to sys.argv when it is None. Defaults to sys.argv when it is None.
lib: {'standard', 'mock', 'mpi'} lib: {'standard', 'mock', 'mpi'}, optional
Type of library we want to load Type of library we want to load
When cdll is specified
lib_dll: ctypes.DLL, optional
The DLL object used as lib.
When this is presented argument lib will be ignored.
""" """
if args is None: if args is None:
args = sys.argv args = sys.argv
_loadlib(lib) _loadlib(lib, lib_dll)
arr = (ctypes.c_char_p * len(args))() arr = (ctypes.c_char_p * len(args))()
arr[:] = args arr[:] = args
_LIB.RabitInit(len(args), arr) _LIB.RabitInit(len(args), arr)

View File

@ -15,8 +15,8 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <algorithm> #include <algorithm>
#include "../include/rabit/utils.h" #include "../include/rabit/internal/utils.h"
#include "../include/rabit/engine.h" #include "../include/rabit/internal/engine.h"
#include "./socket.h" #include "./socket.h"
namespace MPI { namespace MPI {

View File

@ -11,8 +11,8 @@
#include <vector> #include <vector>
#include <map> #include <map>
#include <sstream> #include <sstream>
#include "../include/rabit/engine.h" #include "../include/rabit/internal/engine.h"
#include "../include/rabit/timer.h" #include "../include/rabit/internal/timer.h"
#include "./allreduce_robust.h" #include "./allreduce_robust.h"
namespace rabit { namespace rabit {

View File

@ -10,10 +10,10 @@
#define NOMINMAX #define NOMINMAX
#include <limits> #include <limits>
#include <utility> #include <utility>
#include "../include/rabit/io.h" #include "../include/rabit/internal/io.h"
#include "../include/rabit/utils.h" #include "../include/rabit/internal/utils.h"
#include "../include/rabit/engine.h" #include "../include/rabit/internal/engine.h"
#include "../include/rabit/rabit-inl.h" #include "../include/rabit/internal/rabit-inl.h"
#include "./allreduce_robust.h" #include "./allreduce_robust.h"
namespace rabit { namespace rabit {
@ -1180,4 +1180,3 @@ AllreduceRobust::RingPassing(void *sendrecvbuf_,
} }
} // namespace engine } // namespace engine
} // namespace rabit } // namespace rabit

View File

@ -13,7 +13,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <algorithm> #include <algorithm>
#include "../include/rabit/engine.h" #include "../include/rabit/internal/engine.h"
#include "./allreduce_base.h" #include "./allreduce_base.h"
namespace rabit { namespace rabit {

View File

@ -5,10 +5,11 @@
#include <cstring> #include <cstring>
#include <string> #include <string>
#include "../include/rabit.h" #include "../include/rabit/rabit.h"
#include "./rabit_wrapper.h" #include "../include/rabit/c_api.h"
namespace rabit { namespace rabit {
namespace wrapper { namespace c_api {
// helper use to avoid BitOR operator // helper use to avoid BitOR operator
template<typename OP, typename DType> template<typename OP, typename DType>
struct FHelper { struct FHelper {
@ -21,6 +22,7 @@ struct FHelper {
prepare_fun, prepare_arg); prepare_fun, prepare_arg);
} }
}; };
template<typename DType> template<typename DType>
struct FHelper<op::BitOR, DType> { struct FHelper<op::BitOR, DType> {
inline static void inline static void
@ -31,6 +33,7 @@ struct FHelper<op::BitOR, DType> {
utils::Error("DataType does not support bitwise or operation"); utils::Error("DataType does not support bitwise or operation");
} }
}; };
template<typename OP> template<typename OP>
inline void Allreduce_(void *sendrecvbuf_, inline void Allreduce_(void *sendrecvbuf_,
size_t count, size_t count,
@ -117,8 +120,9 @@ inline void Allreduce(void *sendrecvbuf,
default: utils::Error("unknown enum_op"); default: utils::Error("unknown enum_op");
} }
} }
// temporal memory for global and local model
std::string global_buffer, local_buffer;
// wrapper for serialization // wrapper for serialization
struct ReadWrapper : public Serializable { struct ReadWrapper : public Serializable {
std::string *p_str; std::string *p_str;
@ -138,6 +142,7 @@ struct ReadWrapper : public Serializable {
utils::Error("not implemented"); utils::Error("not implemented");
} }
}; };
struct WriteWrapper : public Serializable { struct WriteWrapper : public Serializable {
const char *data; const char *data;
size_t length; size_t length;
@ -154,25 +159,30 @@ struct WriteWrapper : public Serializable {
fo->Write(data, length * sizeof(char)); fo->Write(data, length * sizeof(char));
} }
}; };
} // namespace wrapper } // namespace c_api
} // namespace rabit } // namespace rabit
extern "C" {
void RabitInit(int argc, char *argv[]) { void RabitInit(int argc, char *argv[]) {
rabit::Init(argc, argv); rabit::Init(argc, argv);
} }
void RabitFinalize(void) {
void RabitFinalize() {
rabit::Finalize(); rabit::Finalize();
} }
int RabitGetRank(void) {
int RabitGetRank() {
return rabit::GetRank(); return rabit::GetRank();
} }
int RabitGetWorldSize(void) {
int RabitGetWorldSize() {
return rabit::GetWorldSize(); return rabit::GetWorldSize();
} }
void RabitTrackerPrint(const char *msg) { void RabitTrackerPrint(const char *msg) {
std::string m(msg); std::string m(msg);
rabit::TrackerPrint(m); rabit::TrackerPrint(m);
} }
void RabitGetProcessorName(char *out_name, void RabitGetProcessorName(char *out_name,
rbt_ulong *out_len, rbt_ulong *out_len,
rbt_ulong max_len) { rbt_ulong max_len) {
@ -183,31 +193,39 @@ extern "C" {
strcpy(out_name, s.c_str()); // NOLINT(*) strcpy(out_name, s.c_str()); // NOLINT(*)
*out_len = static_cast<rbt_ulong>(s.length()); *out_len = static_cast<rbt_ulong>(s.length());
} }
void RabitBroadcast(void *sendrecv_data, void RabitBroadcast(void *sendrecv_data,
rbt_ulong size, int root) { rbt_ulong size, int root) {
rabit::Broadcast(sendrecv_data, size, root); rabit::Broadcast(sendrecv_data, size, root);
} }
void RabitAllreduce(void *sendrecvbuf, void RabitAllreduce(void *sendrecvbuf,
size_t count, size_t count,
int enum_dtype, int enum_dtype,
int enum_op, int enum_op,
void (*prepare_fun)(void *arg), void (*prepare_fun)(void *arg),
void *prepare_arg) { void *prepare_arg) {
rabit::wrapper::Allreduce rabit::c_api::Allreduce
(sendrecvbuf, count, (sendrecvbuf, count,
static_cast<rabit::engine::mpi::DataType>(enum_dtype), static_cast<rabit::engine::mpi::DataType>(enum_dtype),
static_cast<rabit::engine::mpi::OpType>(enum_op), static_cast<rabit::engine::mpi::OpType>(enum_op),
prepare_fun, prepare_arg); prepare_fun, prepare_arg);
} }
int RabitLoadCheckPoint(char **out_global_model, int RabitLoadCheckPoint(char **out_global_model,
rbt_ulong *out_global_len, rbt_ulong *out_global_len,
char **out_local_model, char **out_local_model,
rbt_ulong *out_local_len) { rbt_ulong *out_local_len) {
// NOTE: this function is not thread-safe
using rabit::BeginPtr; using rabit::BeginPtr;
using namespace rabit::wrapper; using namespace rabit::c_api; // NOLINT(*)
static std::string global_buffer;
static std::string local_buffer;
ReadWrapper sg(&global_buffer); ReadWrapper sg(&global_buffer);
ReadWrapper sl(&local_buffer); ReadWrapper sl(&local_buffer);
int version; int version;
if (out_local_model == NULL) { if (out_local_model == NULL) {
version = rabit::LoadCheckPoint(&sg, NULL); version = rabit::LoadCheckPoint(&sg, NULL);
*out_global_model = BeginPtr(global_buffer); *out_global_model = BeginPtr(global_buffer);
@ -221,11 +239,12 @@ extern "C" {
} }
return version; return version;
} }
void RabitCheckPoint(const char *global_model, void RabitCheckPoint(const char *global_model,
rbt_ulong global_len, rbt_ulong global_len,
const char *local_model, const char *local_model,
rbt_ulong local_len) { rbt_ulong local_len) {
using namespace rabit::wrapper; using namespace rabit::c_api; // NOLINT(*)
WriteWrapper sg(global_model, global_len); WriteWrapper sg(global_model, global_len);
WriteWrapper sl(local_model, local_len); WriteWrapper sl(local_model, local_len);
if (local_model == NULL) { if (local_model == NULL) {
@ -234,7 +253,7 @@ extern "C" {
rabit::CheckPoint(&sg, &sl); rabit::CheckPoint(&sg, &sl);
} }
} }
int RabitVersionNumber(void) {
int RabitVersionNumber() {
return rabit::VersionNumber(); return rabit::VersionNumber();
} }
}

View File

@ -10,7 +10,7 @@
#define _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_DEPRECATE
#define NOMINMAX #define NOMINMAX
#include "../include/rabit/engine.h" #include "../include/rabit/internal/engine.h"
#include "./allreduce_base.h" #include "./allreduce_base.h"
#include "./allreduce_robust.h" #include "./allreduce_robust.h"

View File

@ -25,7 +25,7 @@
#endif #endif
#include <string> #include <string>
#include <cstring> #include <cstring>
#include "../include/rabit/utils.h" #include "../include/rabit/internal/utils.h"
#if defined(_WIN32) #if defined(_WIN32)
typedef int ssize_t; typedef int ssize_t;

View File

@ -10,16 +10,16 @@ OBJ = $(RABIT_OBJ) speed_test.o model_recover.o local_recover.o lazy_recover.o
MPIBIN = speed_test.mpi MPIBIN = speed_test.mpi
.PHONY: clean all lib mpi .PHONY: clean all lib mpi
all: $(BIN) $(MPIBIN) all: $(BIN)
lib: lib:
cd ..;make;cd - cd ..;make;cd -
mpi: mpi:
cd ..;make mpi;cd - cd ..;make mpi;cd -
# programs # programs
speed_test.o: speed_test.cc ../include/*.h lib mpi speed_test.o: speed_test.cc ../include/rabit/*.h lib mpi
model_recover.o: model_recover.cc ../include/*.h lib model_recover.o: model_recover.cc ../include/rabit/*.h lib
local_recover.o: local_recover.cc ../include/*.h lib local_recover.o: local_recover.cc ../include/rabit/*.h lib
lazy_recover.o: lazy_recover.cc ../include/*.h lib lazy_recover.o: lazy_recover.cc ../include/rabit/*.h lib
# we can link against MPI version to get use MPI # we can link against MPI version to get use MPI
speed_test: speed_test.o $(RABIT_OBJ) speed_test: speed_test.o $(RABIT_OBJ)

View File

@ -1,7 +1,6 @@
// this is a test case to test whether rabit can recover model when // this is a test case to test whether rabit can recover model when
// facing an exception // facing an exception
#include <rabit.h> #include <rabit/rabit.h>
#include <rabit/utils.h>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cmath> #include <cmath>

View File

@ -1,7 +1,6 @@
// this is a test case to test whether rabit can recover model when // this is a test case to test whether rabit can recover model when
// facing an exception // facing an exception
#include <rabit.h> #include <rabit/rabit.h>
#include <rabit/utils.h>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cmath> #include <cmath>

View File

@ -1,7 +1,6 @@
// this is a test case to test whether rabit can recover model when // this is a test case to test whether rabit can recover model when
// facing an exception // facing an exception
#include <rabit.h> #include <rabit/rabit.h>
#include <rabit/utils.h>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cmath> #include <cmath>

View File

@ -1,7 +1,6 @@
// This program is used to test the speed of rabit API // This program is used to test the speed of rabit API
#include <rabit.h> #include <rabit/rabit.h>
#include <rabit/utils.h> #include <rabit/internal/timer.h>
#include <rabit/timer.h>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cmath> #include <cmath>

View File

@ -1,29 +1,29 @@
# this is a makefile used to show testcases of rabit # this is a makefile used to show testcases of rabit
.PHONY: all .PHONY: all
all: model_recover_10_10k model_recover_10_10k_die_same all: model_recover_10_10k model_recover_10_10k_die_same model_recover_10_10k_die_hard local_recover_10_10k
# this experiment test recovery with actually process exit, use keepalive to keep program alive # this experiment test recovery with actually process exit, use keepalive to keep program alive
model_recover_10_10k: model_recover_10_10k:
../tracker/rabit_demo.py -n 10 model_recover 10000 mock=0,0,1,0 mock=1,1,1,0 ../dmlc-core/tracker/dmlc-submit --cluster local --num-workers=10 model_recover 10000 mock=0,0,1,0 mock=1,1,1,0
model_recover_10_10k_die_same: model_recover_10_10k_die_same:
../tracker/rabit_demo.py -n 10 model_recover 10000 mock=0,0,1,0 mock=1,1,1,0 mock=0,1,1,0 mock=4,1,1,0 mock=9,1,1,0 ../dmlc-core/tracker/dmlc-submit --cluster local --num-workers=10 model_recover 10000 mock=0,0,1,0 mock=1,1,1,0 mock=0,1,1,0 mock=4,1,1,0 mock=9,1,1,0
model_recover_10_10k_die_hard: model_recover_10_10k_die_hard:
../tracker/rabit_demo.py -n 10 model_recover 10000 mock=0,0,1,0 mock=1,1,1,0 mock=1,1,1,1 mock=0,1,1,0 mock=4,1,1,0 mock=9,1,1,0 mock=8,1,2,0 mock=4,1,3,0 ../dmlc-core/tracker/dmlc-submit --cluster local --num-workers=10 model_recover 10000 mock=0,0,1,0 mock=1,1,1,0 mock=1,1,1,1 mock=0,1,1,0 mock=4,1,1,0 mock=9,1,1,0 mock=8,1,2,0 mock=4,1,3,0
local_recover_10_10k: local_recover_10_10k:
../tracker/rabit_demo.py -n 10 local_recover 10000 mock=0,0,1,0 mock=1,1,1,0 mock=0,1,1,0 mock=4,1,1,0 mock=9,1,1,0 mock=1,1,1,1 ../dmlc-core/tracker/dmlc-submit --cluster local --num-workers=10 local_recover 10000 mock=0,0,1,0 mock=1,1,1,0 mock=0,1,1,0 mock=4,1,1,0 mock=9,1,1,0 mock=1,1,1,1
pylocal_recover_10_10k: pylocal_recover_10_10k:
../tracker/rabit_demo.py -n 10 ./local_recover.py 10000 mock=0,0,1,0 mock=1,1,1,0 mock=0,1,1,0 mock=4,1,1,0 mock=9,1,1,0 mock=1,1,1,1 ../dmlc-core/tracker/dmlc-submit --cluster local --num-workers=10 ./local_recover.py 10000 mock=0,0,1,0 mock=1,1,1,0 mock=0,1,1,0 mock=4,1,1,0 mock=9,1,1,0 mock=1,1,1,1
lazy_recover_10_10k_die_hard: lazy_recover_10_10k_die_hard:
../tracker/rabit_demo.py -n 10 lazy_recover 10000 mock=0,0,1,0 mock=1,1,1,0 mock=1,1,1,1 mock=0,1,1,0 mock=4,1,1,0 mock=9,1,1,0 mock=8,1,2,0 mock=4,1,3,0 ../dmlc-core/tracker/dmlc-submit --cluster local --num-workers=10 lazy_recover 10000 mock=0,0,1,0 mock=1,1,1,0 mock=1,1,1,1 mock=0,1,1,0 mock=4,1,1,0 mock=9,1,1,0 mock=8,1,2,0 mock=4,1,3,0
lazy_recover_10_10k_die_same: lazy_recover_10_10k_die_same:
../tracker/rabit_demo.py -n 10 lazy_recover 10000 mock=0,0,1,0 mock=1,1,1,0 mock=0,1,1,0 mock=4,1,1,0 mock=9,1,1,0 ../dmlc-core/tracker/dmlc-submit --cluster local --num-workers=10 lazy_recover 10000 mock=0,0,1,0 mock=1,1,1,0 mock=0,1,1,0 mock=4,1,1,0 mock=9,1,1,0
ringallreduce_10_10k: ringallreduce_10_10k:
../tracker/rabit_demo.py -v 1 -n 10 model_recover 100 rabit_reduce_ring_mincount=10 ../dmlc-core/tracker/dmlc-submit --cluster local -num-workers=10 model_recover 100 rabit_reduce_ring_mincount=10

9
windows/.gitignore vendored
View File

@ -1,9 +0,0 @@
*.suo
*.exp
*sdf
*.exe
ipch
x64
*.filters
Release
*.user

View File

@ -1,12 +0,0 @@
The solution has been created with Visual Studio Express 2010.
Make sure to compile the Release version
Build
====
* Build the project ```rabit``` , this will give you ```rabit.lib``` in ```x64\Release```
Build Your code with rabit
====
* Add include to the dependency path of your project
* Add ```rabit.lib``` to the linker dependency
* The project basic is an example to show you how to build rabit with basic.cc

View File

@ -1,118 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{A6A95246-EB0A-46BA-9471-5939CB6B0006}</ProjectGuid>
<RootNamespace>basic</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>$(OutDir)\rabit.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\guide\basic.cc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,50 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rabit", "rabit\rabit.vcxproj", "{D7B77D06-4F5F-4BD7-B81E-7CC8EBBE684F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic", "basic\basic.vcxproj", "{A6A95246-EB0A-46BA-9471-5939CB6B0006}"
ProjectSection(ProjectDependencies) = postProject
{D7B77D06-4F5F-4BD7-B81E-7CC8EBBE684F} = {D7B77D06-4F5F-4BD7-B81E-7CC8EBBE684F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rabit_wrapper", "rabit_wrapper\rabit_wrapper.vcxproj", "{2F89A7C5-CA4F-4D77-A728-6702D9F33F9F}"
ProjectSection(ProjectDependencies) = postProject
{D7B77D06-4F5F-4BD7-B81E-7CC8EBBE684F} = {D7B77D06-4F5F-4BD7-B81E-7CC8EBBE684F}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D7B77D06-4F5F-4BD7-B81E-7CC8EBBE684F}.Debug|Win32.ActiveCfg = Debug|Win32
{D7B77D06-4F5F-4BD7-B81E-7CC8EBBE684F}.Debug|Win32.Build.0 = Debug|Win32
{D7B77D06-4F5F-4BD7-B81E-7CC8EBBE684F}.Debug|x64.ActiveCfg = Debug|x64
{D7B77D06-4F5F-4BD7-B81E-7CC8EBBE684F}.Debug|x64.Build.0 = Debug|x64
{D7B77D06-4F5F-4BD7-B81E-7CC8EBBE684F}.Release|Win32.ActiveCfg = Release|Win32
{D7B77D06-4F5F-4BD7-B81E-7CC8EBBE684F}.Release|Win32.Build.0 = Release|Win32
{D7B77D06-4F5F-4BD7-B81E-7CC8EBBE684F}.Release|x64.ActiveCfg = Release|x64
{D7B77D06-4F5F-4BD7-B81E-7CC8EBBE684F}.Release|x64.Build.0 = Release|x64
{A6A95246-EB0A-46BA-9471-5939CB6B0006}.Debug|Win32.ActiveCfg = Debug|Win32
{A6A95246-EB0A-46BA-9471-5939CB6B0006}.Debug|Win32.Build.0 = Debug|Win32
{A6A95246-EB0A-46BA-9471-5939CB6B0006}.Debug|x64.ActiveCfg = Debug|Win32
{A6A95246-EB0A-46BA-9471-5939CB6B0006}.Release|Win32.ActiveCfg = Release|Win32
{A6A95246-EB0A-46BA-9471-5939CB6B0006}.Release|Win32.Build.0 = Release|Win32
{A6A95246-EB0A-46BA-9471-5939CB6B0006}.Release|x64.ActiveCfg = Release|x64
{A6A95246-EB0A-46BA-9471-5939CB6B0006}.Release|x64.Build.0 = Release|x64
{2F89A7C5-CA4F-4D77-A728-6702D9F33F9F}.Debug|Win32.ActiveCfg = Debug|Win32
{2F89A7C5-CA4F-4D77-A728-6702D9F33F9F}.Debug|Win32.Build.0 = Debug|Win32
{2F89A7C5-CA4F-4D77-A728-6702D9F33F9F}.Debug|x64.ActiveCfg = Debug|Win32
{2F89A7C5-CA4F-4D77-A728-6702D9F33F9F}.Release|Win32.ActiveCfg = Release|Win32
{2F89A7C5-CA4F-4D77-A728-6702D9F33F9F}.Release|Win32.Build.0 = Release|Win32
{2F89A7C5-CA4F-4D77-A728-6702D9F33F9F}.Release|x64.ActiveCfg = Release|x64
{2F89A7C5-CA4F-4D77-A728-6702D9F33F9F}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -1,133 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{D7B77D06-4F5F-4BD7-B81E-7CC8EBBE684F}</ProjectGuid>
<RootNamespace>rabit</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\allreduce_base.cc" />
<ClCompile Include="..\..\src\allreduce_robust.cc" />
<ClCompile Include="..\..\src\engine.cc" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\rabit.h" />
<ClInclude Include="..\..\include\rabit\engine.h" />
<ClInclude Include="..\..\include\rabit\io.h" />
<ClInclude Include="..\..\include\rabit\rabit-inl.h" />
<ClInclude Include="..\..\include\rabit\timer.h" />
<ClInclude Include="..\..\include\rabit\utils.h" />
<ClInclude Include="..\..\include\rabit_serializable.h" />
<ClInclude Include="..\..\src\allreduce_base.h" />
<ClInclude Include="..\..\src\allreduce_mock.h" />
<ClInclude Include="..\..\src\allreduce_robust.h" />
<ClInclude Include="..\..\src\socket.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,121 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{2F89A7C5-CA4F-4D77-A728-6702D9F33F9F}</ProjectGuid>
<RootNamespace>rabit_wrapper</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>..\..\x64\Release\rabit.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>$(OutDir)\rabit.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\wrapper\rabit_wrapper.cc" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\wrapper\rabit_wrapper.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,126 +0,0 @@
/*!
* Copyright by Contributors
* \file rabit_wrapper.h
* \author Tianqi Chen
* \brief a C style wrapper of rabit
* can be used to create wrapper of other languages
*/
#ifndef RABIT_WRAPPER_H_
#define RABIT_WRAPPER_H_
#ifdef _MSC_VER
#define RABIT_DLL __declspec(dllexport)
#else
#define RABIT_DLL
#endif
// manually define unsign long
typedef unsigned long rbt_ulong; // NOLINT(*)
#ifdef __cplusplus
extern "C" {
#endif
/*!
* \brief intialize the rabit module, call this once before using anything
* \param argc number of arguments in argv
* \param argv the array of input arguments
*/
RABIT_DLL void RabitInit(int argc, char *argv[]);
/*!
* \brief finalize the rabit engine, call this function after you finished all jobs
*/
RABIT_DLL void RabitFinalize(void);
/*! \brief get rank of current process */
RABIT_DLL int RabitGetRank(void);
/*! \brief get total number of process */
RABIT_DLL int RabitGetWorldSize(void);
/*!
* \brief print the msg to the tracker,
* this function can be used to communicate the information of the progress to
* the user who monitors the tracker
* \param msg the message to be printed
*/
RABIT_DLL void RabitTrackerPrint(const char *msg);
/*!
* \brief get name of processor
* \param out_name hold output string
* \param out_len hold length of output string
* \param max_len maximum buffer length of input
*/
RABIT_DLL void RabitGetProcessorName(char *out_name,
rbt_ulong *out_len,
rbt_ulong max_len);
/*!
* \brief broadcast an memory region to all others from root
*
* Example: int a = 1; Broadcast(&a, sizeof(a), root);
* \param sendrecv_data the pointer to send or recive buffer,
* \param size the size of the data
* \param root the root of process
*/
RABIT_DLL void RabitBroadcast(void *sendrecv_data,
rbt_ulong size, int root);
/*!
* \brief perform in-place allreduce, on sendrecvbuf
* this function is NOT thread-safe
*
* Example Usage: the following code gives sum of the result
* vector<int> data(10);
* ...
* Allreduce<op::Sum>(&data[0], data.size());
* ...
* \param sendrecvbuf buffer for both sending and recving data
* \param count number of elements to be reduced
* \param enum_dtype the enumeration of data type, see rabit::engine::mpi::DataType in engine.h of rabit include
* \param enum_op the enumeration of operation type, see rabit::engine::mpi::OpType in engine.h of rabit
* \param prepare_fun Lazy preprocessing function, if it is not NULL, prepare_fun(prepare_arg)
* will be called by the function before performing Allreduce, to intialize the data in sendrecvbuf_.
* If the result of Allreduce can be recovered directly, then prepare_func will NOT be called
* \param prepare_arg argument used to passed into the lazy preprocessing function
*/
RABIT_DLL void RabitAllreduce(void *sendrecvbuf,
size_t count,
int enum_dtype,
int enum_op,
void (*prepare_fun)(void *arg),
void *prepare_arg);
/*!
* \brief load latest check point
* \param out_global_model hold output of serialized global_model
* \param out_global_len the output length of serialized global model
* \param out_local_model hold output of serialized local_model, can be NULL
* \param out_local_len the output length of serialized local model, can be NULL
*
* \return the version number of check point loaded
* if returned version == 0, this means no model has been CheckPointed
* nothing will be touched
*/
RABIT_DLL int RabitLoadCheckPoint(char **out_global_model,
rbt_ulong *out_global_len,
char **out_local_model,
rbt_ulong *out_local_len);
/*!
* \brief checkpoint the model, meaning we finished a stage of execution
* every time we call check point, there is a version number which will increase by one
*
* \param global_model hold content of serialized global_model
* \param global_len the content length of serialized global model
* \param local_model hold content of serialized local_model, can be NULL
* \param local_len the content length of serialized local model, can be NULL
*
* NOTE: local_model requires explicit replication of the model for fault-tolerance, which will
* bring replication cost in CheckPoint function. global_model do not need explicit replication.
* So only CheckPoint with global_model if possible
*/
RABIT_DLL void RabitCheckPoint(const char *global_model,
rbt_ulong global_len,
const char *local_model,
rbt_ulong local_len);
/*!
* \return version number of current stored model,
* which means how many calls to CheckPoint we made so far
*/
RABIT_DLL int RabitVersionNumber(void);
#ifdef __cplusplus
} // C
#endif
#endif // RABIT_WRAPPER_H_