fresh name fresh start
This commit is contained in:
parent
16f729115e
commit
eb2ca06d67
12
README.md
12
README.md
@ -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
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef ALLREDUCE_UTILS_CONFIG_H_
|
||||
#define ALLREDUCE_UTILS_CONFIG_H_
|
||||
#ifndef RABIT_UTILS_CONFIG_H_
|
||||
#define RABIT_UTILS_CONFIG_H_
|
||||
/*!
|
||||
* \file config.h
|
||||
* \brief helper class to load in configures from file
|
||||
@ -12,6 +12,7 @@
|
||||
#include <fstream>
|
||||
#include "./utils.h"
|
||||
|
||||
namespace rabit {
|
||||
namespace utils {
|
||||
/*!
|
||||
* \brief base implementation of config reader
|
||||
@ -191,5 +192,5 @@ class ConfigIterator: public ConfigStreamReader {
|
||||
std::ifstream fi;
|
||||
};
|
||||
} // namespace utils
|
||||
|
||||
#endif // ALLREDUCE_UTILS_CONFIG_H_
|
||||
} // namespace rabit
|
||||
#endif // RABIT_UTILS_CONFIG_H_
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include "./engine_base.h"
|
||||
#include "./engine_robust.h"
|
||||
|
||||
namespace rabit {
|
||||
namespace engine {
|
||||
// singleton sync manager
|
||||
AllReduceRobust manager;
|
||||
@ -37,3 +38,4 @@ IEngine *GetEngine(void) {
|
||||
return &manager;
|
||||
}
|
||||
} // namespace engine
|
||||
} // namespace rabit
|
||||
|
||||
12
src/engine.h
12
src/engine.h
@ -3,17 +3,18 @@
|
||||
* \brief This file defines the core interface of allreduce library
|
||||
* \author Tianqi Chen, Nacho, Tianyi
|
||||
*/
|
||||
#ifndef ALLREDUCE_ENGINE_H
|
||||
#define ALLREDUCE_ENGINE_H
|
||||
#ifndef RABIT_ENGINE_H
|
||||
#define RABIT_ENGINE_H
|
||||
#include "./io.h"
|
||||
|
||||
|
||||
namespace MPI {
|
||||
/*! \brief MPI data type just to be compatible with MPI reduce function*/
|
||||
class Datatype;
|
||||
}
|
||||
|
||||
/*! \brief namespace of allreduce functionality */
|
||||
/*! \brief namespace of rabit */
|
||||
namespace rabit {
|
||||
/*! \brief core interface of engine */
|
||||
namespace engine {
|
||||
/*! \brief interface of core AllReduce engine */
|
||||
class IEngine {
|
||||
@ -79,4 +80,5 @@ void Finalize(void);
|
||||
IEngine *GetEngine(void);
|
||||
|
||||
} // namespace engine
|
||||
#endif // ALLREDUCE_ENGINE_H
|
||||
} // namespace rabit
|
||||
#endif // RABIT_ENGINE_H
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
#include <cstring>
|
||||
#include "./engine_base.h"
|
||||
|
||||
namespace rabit {
|
||||
namespace engine {
|
||||
// constructor
|
||||
AllReduceBase::AllReduceBase(void) {
|
||||
@ -373,4 +374,5 @@ AllReduceBase::TryBroadcast(void *sendrecvbuf_, size_t total_size, int root) {
|
||||
}
|
||||
return kSuccess;
|
||||
}
|
||||
} // namespace engine
|
||||
} // namespace engine
|
||||
} // namespace rabit
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
*
|
||||
* \author Tianqi Chen, Ignacio Cano, Tianyi Zhou
|
||||
*/
|
||||
#ifndef ALLREDUCE_ENGINE_BASE_H
|
||||
#define ALLREDUCE_ENGINE_BASE_H
|
||||
#ifndef RABIT_ENGINE_BASE_H
|
||||
#define RABIT_ENGINE_BASE_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@ -25,7 +25,7 @@ class Datatype {
|
||||
Datatype(size_t type_size) : type_size(type_size) {}
|
||||
};
|
||||
}
|
||||
|
||||
namespace rabit {
|
||||
namespace engine {
|
||||
/*! \brief implementation of basic AllReduce engine */
|
||||
class AllReduceBase : public IEngine {
|
||||
@ -246,4 +246,5 @@ class AllReduceBase : public IEngine {
|
||||
int world_size;
|
||||
};
|
||||
} // namespace engine
|
||||
#endif // ALLREDUCE_ENGINE_BASE_H
|
||||
} // namespace rabit
|
||||
#endif // RABIT_ENGINE_BASE_H
|
||||
|
||||
@ -4,9 +4,10 @@
|
||||
*
|
||||
* \author Tianqi Chen
|
||||
*/
|
||||
#ifndef ALLREDUCE_ENGINE_ROBUST_INL_H
|
||||
#define ALLREDUCE_ENGINE_ROBUST_INL_H
|
||||
#ifndef RABIT_ENGINE_ROBUST_INL_H
|
||||
#define RABIT_ENGINE_ROBUST_INL_H
|
||||
|
||||
namespace rabit {
|
||||
namespace engine {
|
||||
/*!
|
||||
* \brief run message passing algorithm on the allreduce tree
|
||||
@ -147,4 +148,5 @@ AllReduceRobust::MsgPassing(const NodeType &node_value,
|
||||
return kSuccess;
|
||||
}
|
||||
} // namespace engine
|
||||
#endif // ALLREDUCE_ENGINE_ROBUST_INL_H
|
||||
} // namespace rabit
|
||||
#endif // RABIT_ENGINE_ROBUST_INL_H
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#include "./utils.h"
|
||||
#include "./engine_robust.h"
|
||||
|
||||
namespace rabit {
|
||||
namespace engine {
|
||||
AllReduceRobust::AllReduceRobust(void) {
|
||||
result_buffer_round = 1;
|
||||
@ -589,3 +590,5 @@ bool AllReduceRobust::RecoverExec(void *buf, size_t size, int flag, int seqno) {
|
||||
return true;
|
||||
}
|
||||
} // namespace engine
|
||||
} // namespace rabit
|
||||
|
||||
|
||||
@ -7,12 +7,13 @@
|
||||
*
|
||||
* \author Tianqi Chen, Ignacio Cano, Tianyi Zhou
|
||||
*/
|
||||
#ifndef ALLREDUCE_ENGINE_ROBUST_H
|
||||
#define ALLREDUCE_ENGINE_ROBUST_H
|
||||
#ifndef RABIT_ENGINE_ROBUST_H
|
||||
#define RABIT_ENGINE_ROBUST_H
|
||||
#include <vector>
|
||||
#include "./engine.h"
|
||||
#include "./engine_base.h"
|
||||
|
||||
namespace rabit {
|
||||
namespace engine {
|
||||
/*! \brief implementation of fault tolerant all reduce engine */
|
||||
class AllReduceRobust : public AllReduceBase {
|
||||
@ -348,7 +349,8 @@ class AllReduceRobust : public AllReduceBase {
|
||||
|
||||
};
|
||||
} // namespace engine
|
||||
} // namespace rabit
|
||||
// implementation of inline template function
|
||||
#include "./engine_robust-inl.h"
|
||||
|
||||
#endif // ALLREDUCE_ENGINE_ROBUST_H
|
||||
#endif // RABIT_ENGINE_ROBUST_H
|
||||
|
||||
6
src/io.h
6
src/io.h
@ -1,5 +1,5 @@
|
||||
#ifndef ALLREDUCE_UTILS_IO_H
|
||||
#define ALLREDUCE_UTILS_IO_H
|
||||
#ifndef RABIT_UTILS_IO_H
|
||||
#define RABIT_UTILS_IO_H
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
@ -10,6 +10,7 @@
|
||||
* \brief general stream interface for serialization, I/O
|
||||
* \author Tianqi Chen
|
||||
*/
|
||||
namespace rabit {
|
||||
namespace utils {
|
||||
/*!
|
||||
* \brief interface of stream I/O, used to serialize model
|
||||
@ -211,4 +212,5 @@ class FileStream : public ISeekStream {
|
||||
FILE *fp;
|
||||
};
|
||||
} // namespace utils
|
||||
} // namespace rabit
|
||||
#endif
|
||||
|
||||
23
src/mock.h
23
src/mock.h
@ -1,17 +1,17 @@
|
||||
#ifndef ALLREDUCE_MOCK_H
|
||||
#define ALLREDUCE_MOCK_H
|
||||
#ifndef RABIT_MOCK_H
|
||||
#define RABIT_MOCK_H
|
||||
/*!
|
||||
* \file mock.h
|
||||
* \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 <map>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
namespace rabit {
|
||||
/*! \brief namespace of mock */
|
||||
namespace test {
|
||||
|
||||
@ -27,22 +27,22 @@ public:
|
||||
template<typename OP>
|
||||
inline void AllReduce(float *sendrecvbuf, size_t count) {
|
||||
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) {
|
||||
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) {
|
||||
utils::Assert(verify(checkpoint), "[%d] error when checkpointing", rank);
|
||||
sync::CheckPoint(model);
|
||||
rabit::CheckPoint(model);
|
||||
}
|
||||
|
||||
inline void Broadcast(std::string *sendrecv_data, int root) {
|
||||
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
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#ifndef ALLREDUCE_H
|
||||
#define ALLREDUCE_H
|
||||
#ifndef RABIT_RABIT_H
|
||||
#define RABIT_RABIT_H
|
||||
/*!
|
||||
* \file allreduce.h
|
||||
* \file rabit.h
|
||||
* \brief This file defines a template wrapper of engine to give more flexible
|
||||
* AllReduce operations
|
||||
*
|
||||
@ -9,8 +9,8 @@
|
||||
*/
|
||||
#include "./engine.h"
|
||||
|
||||
/*! \brief namespace of all reduce */
|
||||
namespace sync {
|
||||
/*! \brief namespace of rabit */
|
||||
namespace rabit {
|
||||
/*! \brief namespace of operator */
|
||||
namespace op {
|
||||
struct Max {
|
||||
@ -109,5 +109,5 @@ inline bool LoadCheckPoint(utils::ISerializable *p_model) {
|
||||
inline void CheckPoint(const utils::ISerializable &model) {
|
||||
engine::GetEngine()->CheckPoint(model);
|
||||
}
|
||||
} // namespace allreduce
|
||||
#endif // ALLREDUCE_H
|
||||
} // namespace rabit
|
||||
#endif // RABIT_ALLREDUCE_H
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef ALLREDUCE_SOCKET_H
|
||||
#define ALLREDUCE_SOCKET_H
|
||||
#ifndef RABIT_SOCKET_H
|
||||
#define RABIT_SOCKET_H
|
||||
/*!
|
||||
* \file socket.h
|
||||
* \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;
|
||||
#endif
|
||||
|
||||
namespace rabit {
|
||||
namespace utils {
|
||||
/*! \brief data structure for network address */
|
||||
struct SockAddr {
|
||||
@ -432,5 +433,6 @@ struct SelectHelper {
|
||||
SOCKET maxfd;
|
||||
fd_set read_set, write_set, except_set;
|
||||
};
|
||||
}
|
||||
} // namespace utils
|
||||
} // namespace rabit
|
||||
#endif
|
||||
|
||||
16
src/utils.h
16
src/utils.h
@ -1,5 +1,5 @@
|
||||
#ifndef ALLREDUCE_UTILS_H_
|
||||
#define ALLREDUCE_UTILS_H_
|
||||
#ifndef RABIT_UTILS_H_
|
||||
#define RABIT_UTILS_H_
|
||||
/*!
|
||||
* \file utils.h
|
||||
* \brief simple utils to support the code
|
||||
@ -11,7 +11,7 @@
|
||||
#include <cstdlib>
|
||||
#include <vector>
|
||||
|
||||
#ifndef ALLREDUCE_STRICT_CXX98_
|
||||
#ifndef RABIT_STRICT_CXX98_
|
||||
#include <cstdarg>
|
||||
#endif
|
||||
|
||||
@ -50,13 +50,14 @@ typedef long int64_t;
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
namespace rabit {
|
||||
/*! \brief namespace for helper utils of the project */
|
||||
namespace utils {
|
||||
|
||||
/*! \brief error message buffer length */
|
||||
const int kPrintBuffer = 1 << 12;
|
||||
|
||||
#ifndef ALLREDUCE_CUSTOMIZE_MSG_
|
||||
#ifndef RABIT_CUSTOMIZE_MSG_
|
||||
/*!
|
||||
* \brief handling of Assert error, caused by in-apropriate input
|
||||
* \param msg error message
|
||||
@ -81,14 +82,14 @@ inline void HandleLogPrint(const char *msg) {
|
||||
fflush(stderr);
|
||||
}
|
||||
#else
|
||||
#ifndef ALLREDUCE_STRICT_CXX98_
|
||||
#ifndef RABIT_STRICT_CXX98_
|
||||
// include declarations, some one must implement this
|
||||
void HandleAssertError(const char *msg);
|
||||
void HandleCheckError(const char *msg);
|
||||
void HandlePrint(const char *msg);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ALLREDUCE_STRICT_CXX98_
|
||||
#ifdef RABIT_STRICT_CXX98_
|
||||
// these function pointers are to be assigned
|
||||
extern "C" void (*Printf)(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];
|
||||
}
|
||||
}
|
||||
#endif // ALLREDUCE_UTILS_H_
|
||||
} // namespace rabit
|
||||
#endif // RABIT_UTILS_H_
|
||||
|
||||
@ -1,16 +1,15 @@
|
||||
#include <allreduce.h>
|
||||
#include <rabit.h>
|
||||
#include <utils.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include <mock.h>
|
||||
|
||||
|
||||
using namespace sync;
|
||||
using namespace rabit;
|
||||
|
||||
inline void TestMax(test::Mock &mock, size_t n) {
|
||||
int rank = sync::GetRank();
|
||||
int nproc = sync::GetWorldSize();
|
||||
int rank = rabit::GetRank();
|
||||
int nproc = rabit::GetWorldSize();
|
||||
|
||||
std::vector<float> ndata(n);
|
||||
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) {
|
||||
int rank = sync::GetRank();
|
||||
int nproc = sync::GetWorldSize();
|
||||
int rank = rabit::GetRank();
|
||||
int nproc = rabit::GetWorldSize();
|
||||
const int z = 131;
|
||||
|
||||
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) {
|
||||
int rank = sync::GetRank();
|
||||
int rank = rabit::GetRank();
|
||||
std::string s; s.resize(n);
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
s[i] = char(i % 126 + 1);
|
||||
@ -68,10 +67,10 @@ int main(int argc, char *argv[]) {
|
||||
return 0;
|
||||
}
|
||||
int n = atoi(argv[1]);
|
||||
sync::Init(argc, argv);
|
||||
int rank = sync::GetRank();
|
||||
int nproc = sync::GetWorldSize();
|
||||
std::string name = sync::GetProcessorName();
|
||||
rabit::Init(argc, argv);
|
||||
int rank = rabit::GetRank();
|
||||
int nproc = rabit::GetWorldSize();
|
||||
std::string name = rabit::GetProcessorName();
|
||||
|
||||
test::Mock mock(rank, argv[2], argv[3]);
|
||||
|
||||
@ -84,7 +83,7 @@ int main(int argc, char *argv[]) {
|
||||
TestBcast(mock, n, i);
|
||||
}
|
||||
utils::LogPrintf("[%d] !!!TestBcast pass\n", rank);
|
||||
sync::Finalize();
|
||||
rabit::Finalize();
|
||||
printf("[%d] all check pass\n", rank);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user