Squashed 'subtree/rabit/' changes from 1db6449..85b7463

85b7463 change def of reducer to take function ptr
fe6366e add engine base
a98720e more deps

git-subtree-dir: subtree/rabit
git-subtree-split: 85b746394e
This commit is contained in:
tqchen
2015-01-19 21:26:25 -08:00
parent 81749e6b63
commit ea50f8e030
10 changed files with 78 additions and 24 deletions

View File

@@ -17,11 +17,15 @@
namespace rabit {
namespace engine {
// singleton sync manager
#ifndef RABIT_USE_BASE
#ifndef RABIT_USE_MOCK
AllreduceRobust manager;
#else
AllreduceMock manager;
#endif
#else
AllreduceBase manager;
#endif
/*! \brief intiialize the synchronization module */
void Init(int argc, char *argv[]) {

15
src/engine_base.cc Normal file
View File

@@ -0,0 +1,15 @@
/*!
* Copyright (c) 2014 by Contributors
* \file engine_mock.cc
* \brief this is an engine implementation that will
* insert failures in certain call point, to test if the engine is robust to failure
* \author Tianqi Chen
*/
// define use MOCK, os we will use mock Manager
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_DEPRECATE
#define NOMINMAX
// switch engine to AllreduceMock
#define RABIT_USE_BASE
#include "./engine.cc"

View File

@@ -159,12 +159,17 @@ void ReduceHandle::Init(IEngine::ReduceFunction redfunc, size_t type_nbytes) {
utils::Assert(handle_ == NULL, "cannot initialize reduce handle twice");
if (type_nbytes != 0) {
MPI::Datatype *dtype = new MPI::Datatype();
*dtype = MPI::CHAR.Create_contiguous(type_nbytes);
if (type_nbytes % 8 == 0) {
*dtype = MPI::LONG.Create_contiguous(type_nbytes / sizeof(long));
} else if (type_nbytes % 4 == 0) {
*dtype = MPI::INT.Create_contiguous(type_nbytes / sizeof(int));
} else {
*dtype = MPI::CHAR.Create_contiguous(type_nbytes);
}
dtype->Commit();
created_type_nbytes_ = type_nbytes;
htype_ = dtype;
}
MPI::Op *op = new MPI::Op();
MPI::User_function *pf = redfunc;
op->Init(pf, true);
@@ -183,7 +188,13 @@ void ReduceHandle::Allreduce(void *sendrecvbuf,
} else {
dtype->Free();
}
*dtype = MPI::CHAR.Create_contiguous(type_nbytes);
if (type_nbytes % 8 == 0) {
*dtype = MPI::LONG.Create_contiguous(type_nbytes / sizeof(long));
} else if (type_nbytes % 4 == 0) {
*dtype = MPI::INT.Create_contiguous(type_nbytes / sizeof(int));
} else {
*dtype = MPI::CHAR.Create_contiguous(type_nbytes);
}
dtype->Commit();
created_type_nbytes_ = type_nbytes;
}