From 4db0a62a068894a55f70bad5e80c33d4434fc834 Mon Sep 17 00:00:00 2001 From: tqchen Date: Wed, 11 Feb 2015 20:31:46 -0800 Subject: [PATCH] bugfix of lazy prepare --- src/allreduce_robust.cc | 5 ++++- src/engine_empty.cc | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/allreduce_robust.cc b/src/allreduce_robust.cc index 7f379237f..3ac7e8795 100644 --- a/src/allreduce_robust.cc +++ b/src/allreduce_robust.cc @@ -77,7 +77,10 @@ void AllreduceRobust::Allreduce(void *sendrecvbuf_, PreprocFunction prepare_fun, void *prepare_arg) { // skip action in single node - if (world_size == 1) return; + if (world_size == 1) { + if (prepare_fun != NULL) prepare_fun(prepare_arg); + return; + } bool recovered = RecoverExec(sendrecvbuf_, type_nbytes * count, 0, seq_counter); // now we are free to remove the last result, if any if (resbuf.LastSeqNo() != -1 && diff --git a/src/engine_empty.cc b/src/engine_empty.cc index 298872ea0..a29a35b0c 100644 --- a/src/engine_empty.cc +++ b/src/engine_empty.cc @@ -92,6 +92,7 @@ void Allreduce_(void *sendrecvbuf, mpi::OpType op, IEngine::PreprocFunction prepare_fun, void *prepare_arg) { + if (prepare_fun != NULL) prepare_fun(prepare_arg); } // code for reduce handle @@ -106,6 +107,8 @@ void ReduceHandle::Init(IEngine::ReduceFunction redfunc, size_t type_nbytes) {} void ReduceHandle::Allreduce(void *sendrecvbuf, size_t type_nbytes, size_t count, IEngine::PreprocFunction prepare_fun, - void *prepare_arg) {} + void *prepare_arg) { + if (prepare_fun != NULL) prepare_fun(prepare_arg); +} } // namespace engine } // namespace rabit