This commit is contained in:
tqchen 2015-05-02 21:47:43 -07:00
parent fa99857467
commit e0b7da0302

View File

@ -90,6 +90,7 @@ class AllreduceBase : public IEngine {
PreprocFunction prepare_fun = NULL, PreprocFunction prepare_fun = NULL,
void *prepare_arg = NULL) { void *prepare_arg = NULL) {
if (prepare_fun != NULL) prepare_fun(prepare_arg); if (prepare_fun != NULL) prepare_fun(prepare_arg);
if (world_size == 1) return;
utils::Assert(TryAllreduce(sendrecvbuf_, utils::Assert(TryAllreduce(sendrecvbuf_,
type_nbytes, count, reducer) == kSuccess, type_nbytes, count, reducer) == kSuccess,
"Allreduce failed"); "Allreduce failed");
@ -101,6 +102,7 @@ class AllreduceBase : public IEngine {
* \param root the root worker id to broadcast the data * \param root the root worker id to broadcast the data
*/ */
virtual void Broadcast(void *sendrecvbuf_, size_t total_size, int root) { virtual void Broadcast(void *sendrecvbuf_, size_t total_size, int root) {
if (world_size == 1) return;
utils::Assert(TryBroadcast(sendrecvbuf_, total_size, root) == kSuccess, utils::Assert(TryBroadcast(sendrecvbuf_, total_size, root) == kSuccess,
"Broadcast failed"); "Broadcast failed");
} }