fresh name fresh start

This commit is contained in:
tqchen 2014-12-01 09:17:05 -08:00
parent 16f729115e
commit eb2ca06d67
15 changed files with 93 additions and 66 deletions

View File

@ -1,6 +1,12 @@
AllReduce Abstraction rabit: Robust Allreduce and Broadcast Interface
==== ====
* Tianqi, Nacho, Tianyi rabit is a light weight library designed to provide fault tolerant interface of Allreduce and Broadcast.
Go! Contributors: https://github.com/tqchen/rabit/graphs/contributors
Design Goal
====
* rabit should run fast
* rabit is light weight
* rabit dig safe burrows to avoid disasters

View File

@ -1,5 +1,5 @@
#ifndef ALLREDUCE_UTILS_CONFIG_H_ #ifndef RABIT_UTILS_CONFIG_H_
#define ALLREDUCE_UTILS_CONFIG_H_ #define RABIT_UTILS_CONFIG_H_
/*! /*!
* \file config.h * \file config.h
* \brief helper class to load in configures from file * \brief helper class to load in configures from file
@ -12,6 +12,7 @@
#include <fstream> #include <fstream>
#include "./utils.h" #include "./utils.h"
namespace rabit {
namespace utils { namespace utils {
/*! /*!
* \brief base implementation of config reader * \brief base implementation of config reader
@ -191,5 +192,5 @@ class ConfigIterator: public ConfigStreamReader {
std::ifstream fi; std::ifstream fi;
}; };
} // namespace utils } // namespace utils
} // namespace rabit
#endif // ALLREDUCE_UTILS_CONFIG_H_ #endif // RABIT_UTILS_CONFIG_H_

View File

@ -13,6 +13,7 @@
#include "./engine_base.h" #include "./engine_base.h"
#include "./engine_robust.h" #include "./engine_robust.h"
namespace rabit {
namespace engine { namespace engine {
// singleton sync manager // singleton sync manager
AllReduceRobust manager; AllReduceRobust manager;
@ -37,3 +38,4 @@ IEngine *GetEngine(void) {
return &manager; return &manager;
} }
} // namespace engine } // namespace engine
} // namespace rabit

View File

@ -3,17 +3,18 @@
* \brief This file defines the core interface of allreduce library * \brief This file defines the core interface of allreduce library
* \author Tianqi Chen, Nacho, Tianyi * \author Tianqi Chen, Nacho, Tianyi
*/ */
#ifndef ALLREDUCE_ENGINE_H #ifndef RABIT_ENGINE_H
#define ALLREDUCE_ENGINE_H #define RABIT_ENGINE_H
#include "./io.h" #include "./io.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*/
class Datatype; class Datatype;
} }
/*! \brief namespace of allreduce functionality */ /*! \brief namespace of rabit */
namespace rabit {
/*! \brief core interface of engine */
namespace engine { namespace engine {
/*! \brief interface of core AllReduce engine */ /*! \brief interface of core AllReduce engine */
class IEngine { class IEngine {
@ -79,4 +80,5 @@ void Finalize(void);
IEngine *GetEngine(void); IEngine *GetEngine(void);
} // namespace engine } // namespace engine
#endif // ALLREDUCE_ENGINE_H } // namespace rabit
#endif // RABIT_ENGINE_H

View File

@ -10,6 +10,7 @@
#include <cstring> #include <cstring>
#include "./engine_base.h" #include "./engine_base.h"
namespace rabit {
namespace engine { namespace engine {
// constructor // constructor
AllReduceBase::AllReduceBase(void) { AllReduceBase::AllReduceBase(void) {
@ -373,4 +374,5 @@ AllReduceBase::TryBroadcast(void *sendrecvbuf_, size_t total_size, int root) {
} }
return kSuccess; return kSuccess;
} }
} // namespace engine } // namespace engine
} // namespace rabit

View File

@ -8,8 +8,8 @@
* *
* \author Tianqi Chen, Ignacio Cano, Tianyi Zhou * \author Tianqi Chen, Ignacio Cano, Tianyi Zhou
*/ */
#ifndef ALLREDUCE_ENGINE_BASE_H #ifndef RABIT_ENGINE_BASE_H
#define ALLREDUCE_ENGINE_BASE_H #define RABIT_ENGINE_BASE_H
#include <vector> #include <vector>
#include <string> #include <string>
@ -25,7 +25,7 @@ class Datatype {
Datatype(size_t type_size) : type_size(type_size) {} Datatype(size_t type_size) : type_size(type_size) {}
}; };
} }
namespace rabit {
namespace engine { namespace engine {
/*! \brief implementation of basic AllReduce engine */ /*! \brief implementation of basic AllReduce engine */
class AllReduceBase : public IEngine { class AllReduceBase : public IEngine {
@ -246,4 +246,5 @@ class AllReduceBase : public IEngine {
int world_size; int world_size;
}; };
} // namespace engine } // namespace engine
#endif // ALLREDUCE_ENGINE_BASE_H } // namespace rabit
#endif // RABIT_ENGINE_BASE_H

View File

@ -4,9 +4,10 @@
* *
* \author Tianqi Chen * \author Tianqi Chen
*/ */
#ifndef ALLREDUCE_ENGINE_ROBUST_INL_H #ifndef RABIT_ENGINE_ROBUST_INL_H
#define ALLREDUCE_ENGINE_ROBUST_INL_H #define RABIT_ENGINE_ROBUST_INL_H
namespace rabit {
namespace engine { namespace engine {
/*! /*!
* \brief run message passing algorithm on the allreduce tree * \brief run message passing algorithm on the allreduce tree
@ -147,4 +148,5 @@ AllReduceRobust::MsgPassing(const NodeType &node_value,
return kSuccess; return kSuccess;
} }
} // namespace engine } // namespace engine
#endif // ALLREDUCE_ENGINE_ROBUST_INL_H } // namespace rabit
#endif // RABIT_ENGINE_ROBUST_INL_H

View File

@ -12,6 +12,7 @@
#include "./utils.h" #include "./utils.h"
#include "./engine_robust.h" #include "./engine_robust.h"
namespace rabit {
namespace engine { namespace engine {
AllReduceRobust::AllReduceRobust(void) { AllReduceRobust::AllReduceRobust(void) {
result_buffer_round = 1; result_buffer_round = 1;
@ -589,3 +590,5 @@ bool AllReduceRobust::RecoverExec(void *buf, size_t size, int flag, int seqno) {
return true; return true;
} }
} // namespace engine } // namespace engine
} // namespace rabit

View File

@ -7,12 +7,13 @@
* *
* \author Tianqi Chen, Ignacio Cano, Tianyi Zhou * \author Tianqi Chen, Ignacio Cano, Tianyi Zhou
*/ */
#ifndef ALLREDUCE_ENGINE_ROBUST_H #ifndef RABIT_ENGINE_ROBUST_H
#define ALLREDUCE_ENGINE_ROBUST_H #define RABIT_ENGINE_ROBUST_H
#include <vector> #include <vector>
#include "./engine.h" #include "./engine.h"
#include "./engine_base.h" #include "./engine_base.h"
namespace rabit {
namespace engine { namespace engine {
/*! \brief implementation of fault tolerant all reduce engine */ /*! \brief implementation of fault tolerant all reduce engine */
class AllReduceRobust : public AllReduceBase { class AllReduceRobust : public AllReduceBase {
@ -348,7 +349,8 @@ class AllReduceRobust : public AllReduceBase {
}; };
} // namespace engine } // namespace engine
} // namespace rabit
// implementation of inline template function // implementation of inline template function
#include "./engine_robust-inl.h" #include "./engine_robust-inl.h"
#endif // ALLREDUCE_ENGINE_ROBUST_H #endif // RABIT_ENGINE_ROBUST_H

View File

@ -1,5 +1,5 @@
#ifndef ALLREDUCE_UTILS_IO_H #ifndef RABIT_UTILS_IO_H
#define ALLREDUCE_UTILS_IO_H #define RABIT_UTILS_IO_H
#include <cstdio> #include <cstdio>
#include <vector> #include <vector>
#include <cstring> #include <cstring>
@ -10,6 +10,7 @@
* \brief general stream interface for serialization, I/O * \brief general stream interface for serialization, I/O
* \author Tianqi Chen * \author Tianqi Chen
*/ */
namespace rabit {
namespace utils { namespace utils {
/*! /*!
* \brief interface of stream I/O, used to serialize model * \brief interface of stream I/O, used to serialize model
@ -211,4 +212,5 @@ class FileStream : public ISeekStream {
FILE *fp; FILE *fp;
}; };
} // namespace utils } // namespace utils
} // namespace rabit
#endif #endif

View File

@ -1,17 +1,17 @@
#ifndef ALLREDUCE_MOCK_H #ifndef RABIT_MOCK_H
#define ALLREDUCE_MOCK_H #define RABIT_MOCK_H
/*! /*!
* \file mock.h * \file mock.h
* \brief This file defines a mock object to test the system * \brief This file defines a mock object to test the system
* \author Tianqi Chen, Nacho, Tianyi * \author Ignacio Cano
*/ */
#include "./allreduce.h" #include "./rabit.h"
#include "./config.h" #include "./config.h"
#include <map> #include <map>
#include <sstream> #include <sstream>
#include <fstream> #include <fstream>
namespace rabit {
/*! \brief namespace of mock */ /*! \brief namespace of mock */
namespace test { namespace test {
@ -27,22 +27,22 @@ public:
template<typename OP> template<typename OP>
inline void AllReduce(float *sendrecvbuf, size_t count) { inline void AllReduce(float *sendrecvbuf, size_t count) {
utils::Assert(verify(allReduce), "[%d] error when calling allReduce", rank); utils::Assert(verify(allReduce), "[%d] error when calling allReduce", rank);
sync::AllReduce<OP>(sendrecvbuf, count); rabit::AllReduce<OP>(sendrecvbuf, count);
} }
inline bool LoadCheckPoint(utils::ISerializable *p_model) { inline bool LoadCheckPoint(utils::ISerializable *p_model) {
utils::Assert(verify(loadCheckpoint), "[%d] error when loading checkpoint", rank); utils::Assert(verify(loadCheckpoint), "[%d] error when loading checkpoint", rank);
return sync::LoadCheckPoint(p_model); return rabit::LoadCheckPoint(p_model);
} }
inline void CheckPoint(const utils::ISerializable &model) { inline void CheckPoint(const utils::ISerializable &model) {
utils::Assert(verify(checkpoint), "[%d] error when checkpointing", rank); utils::Assert(verify(checkpoint), "[%d] error when checkpointing", rank);
sync::CheckPoint(model); rabit::CheckPoint(model);
} }
inline void Broadcast(std::string *sendrecv_data, int root) { inline void Broadcast(std::string *sendrecv_data, int root) {
utils::Assert(verify(broadcast), "[%d] error when broadcasting", rank); utils::Assert(verify(broadcast), "[%d] error when broadcasting", rank);
sync::Bcast(sendrecv_data, root); rabit::Bcast(sendrecv_data, root);
} }
@ -110,6 +110,7 @@ private:
}; };
} } // namespace test
} // namespace rabit
#endif // ALLREDUCE_MOCK_H #endif // RABIT_MOCK_H

View File

@ -1,7 +1,7 @@
#ifndef ALLREDUCE_H #ifndef RABIT_RABIT_H
#define ALLREDUCE_H #define RABIT_RABIT_H
/*! /*!
* \file allreduce.h * \file rabit.h
* \brief This file defines a template wrapper of engine to give more flexible * \brief This file defines a template wrapper of engine to give more flexible
* AllReduce operations * AllReduce operations
* *
@ -9,8 +9,8 @@
*/ */
#include "./engine.h" #include "./engine.h"
/*! \brief namespace of all reduce */ /*! \brief namespace of rabit */
namespace sync { namespace rabit {
/*! \brief namespace of operator */ /*! \brief namespace of operator */
namespace op { namespace op {
struct Max { struct Max {
@ -109,5 +109,5 @@ inline bool LoadCheckPoint(utils::ISerializable *p_model) {
inline void CheckPoint(const utils::ISerializable &model) { inline void CheckPoint(const utils::ISerializable &model) {
engine::GetEngine()->CheckPoint(model); engine::GetEngine()->CheckPoint(model);
} }
} // namespace allreduce } // namespace rabit
#endif // ALLREDUCE_H #endif // RABIT_ALLREDUCE_H

View File

@ -1,5 +1,5 @@
#ifndef ALLREDUCE_SOCKET_H #ifndef RABIT_SOCKET_H
#define ALLREDUCE_SOCKET_H #define RABIT_SOCKET_H
/*! /*!
* \file socket.h * \file socket.h
* \brief this file aims to provide a wrapper of sockets * \brief this file aims to provide a wrapper of sockets
@ -32,6 +32,7 @@ typedef size_t sock_size_t;
const int INVALID_SOCKET = -1; const int INVALID_SOCKET = -1;
#endif #endif
namespace rabit {
namespace utils { namespace utils {
/*! \brief data structure for network address */ /*! \brief data structure for network address */
struct SockAddr { struct SockAddr {
@ -432,5 +433,6 @@ struct SelectHelper {
SOCKET maxfd; SOCKET maxfd;
fd_set read_set, write_set, except_set; fd_set read_set, write_set, except_set;
}; };
} } // namespace utils
} // namespace rabit
#endif #endif

View File

@ -1,5 +1,5 @@
#ifndef ALLREDUCE_UTILS_H_ #ifndef RABIT_UTILS_H_
#define ALLREDUCE_UTILS_H_ #define RABIT_UTILS_H_
/*! /*!
* \file utils.h * \file utils.h
* \brief simple utils to support the code * \brief simple utils to support the code
@ -11,7 +11,7 @@
#include <cstdlib> #include <cstdlib>
#include <vector> #include <vector>
#ifndef ALLREDUCE_STRICT_CXX98_ #ifndef RABIT_STRICT_CXX98_
#include <cstdarg> #include <cstdarg>
#endif #endif
@ -50,13 +50,14 @@ typedef long int64_t;
#include <inttypes.h> #include <inttypes.h>
#endif #endif
namespace rabit {
/*! \brief namespace for helper utils of the project */ /*! \brief namespace for helper utils of the project */
namespace utils { namespace utils {
/*! \brief error message buffer length */ /*! \brief error message buffer length */
const int kPrintBuffer = 1 << 12; const int kPrintBuffer = 1 << 12;
#ifndef ALLREDUCE_CUSTOMIZE_MSG_ #ifndef RABIT_CUSTOMIZE_MSG_
/*! /*!
* \brief handling of Assert error, caused by in-apropriate input * \brief handling of Assert error, caused by in-apropriate input
* \param msg error message * \param msg error message
@ -81,14 +82,14 @@ inline void HandleLogPrint(const char *msg) {
fflush(stderr); fflush(stderr);
} }
#else #else
#ifndef ALLREDUCE_STRICT_CXX98_ #ifndef RABIT_STRICT_CXX98_
// include declarations, some one must implement this // include declarations, some one must implement this
void HandleAssertError(const char *msg); void HandleAssertError(const char *msg);
void HandleCheckError(const char *msg); void HandleCheckError(const char *msg);
void HandlePrint(const char *msg); void HandlePrint(const char *msg);
#endif #endif
#endif #endif
#ifdef ALLREDUCE_STRICT_CXX98_ #ifdef RABIT_STRICT_CXX98_
// these function pointers are to be assigned // these function pointers are to be assigned
extern "C" void (*Printf)(const char *fmt, ...); extern "C" void (*Printf)(const char *fmt, ...);
extern "C" int (*SPrintf)(char *buf, size_t size, const char *fmt, ...); extern "C" int (*SPrintf)(char *buf, size_t size, const char *fmt, ...);
@ -186,4 +187,5 @@ inline const T *BeginPtr(const std::vector<T> &vec) {
return &vec[0]; return &vec[0];
} }
} }
#endif // ALLREDUCE_UTILS_H_ } // namespace rabit
#endif // RABIT_UTILS_H_

View File

@ -1,16 +1,15 @@
#include <allreduce.h> #include <rabit.h>
#include <utils.h> #include <utils.h>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cmath> #include <cmath>
#include <mock.h> #include <mock.h>
using namespace rabit;
using namespace sync;
inline void TestMax(test::Mock &mock, size_t n) { inline void TestMax(test::Mock &mock, size_t n) {
int rank = sync::GetRank(); int rank = rabit::GetRank();
int nproc = sync::GetWorldSize(); int nproc = rabit::GetWorldSize();
std::vector<float> ndata(n); std::vector<float> ndata(n);
for (size_t i = 0; i < ndata.size(); ++i) { for (size_t i = 0; i < ndata.size(); ++i) {
@ -27,8 +26,8 @@ inline void TestMax(test::Mock &mock, size_t n) {
} }
inline void TestSum(test::Mock &mock, size_t n) { inline void TestSum(test::Mock &mock, size_t n) {
int rank = sync::GetRank(); int rank = rabit::GetRank();
int nproc = sync::GetWorldSize(); int nproc = rabit::GetWorldSize();
const int z = 131; const int z = 131;
std::vector<float> ndata(n); std::vector<float> ndata(n);
@ -47,7 +46,7 @@ inline void TestSum(test::Mock &mock, size_t n) {
} }
inline void TestBcast(test::Mock &mock, size_t n, int root) { inline void TestBcast(test::Mock &mock, size_t n, int root) {
int rank = sync::GetRank(); int rank = rabit::GetRank();
std::string s; s.resize(n); std::string s; s.resize(n);
for (size_t i = 0; i < n; ++i) { for (size_t i = 0; i < n; ++i) {
s[i] = char(i % 126 + 1); s[i] = char(i % 126 + 1);
@ -68,10 +67,10 @@ int main(int argc, char *argv[]) {
return 0; return 0;
} }
int n = atoi(argv[1]); int n = atoi(argv[1]);
sync::Init(argc, argv); rabit::Init(argc, argv);
int rank = sync::GetRank(); int rank = rabit::GetRank();
int nproc = sync::GetWorldSize(); int nproc = rabit::GetWorldSize();
std::string name = sync::GetProcessorName(); std::string name = rabit::GetProcessorName();
test::Mock mock(rank, argv[2], argv[3]); test::Mock mock(rank, argv[2], argv[3]);
@ -84,7 +83,7 @@ int main(int argc, char *argv[]) {
TestBcast(mock, n, i); TestBcast(mock, n, i);
} }
utils::LogPrintf("[%d] !!!TestBcast pass\n", rank); utils::LogPrintf("[%d] !!!TestBcast pass\n", rank);
sync::Finalize(); rabit::Finalize();
printf("[%d] all check pass\n", rank); printf("[%d] all check pass\n", rank);
return 0; return 0;
} }