From 2c0a0671ad94225ae6084223e55f377bd50daa6b Mon Sep 17 00:00:00 2001 From: tqchen Date: Fri, 19 Dec 2014 19:21:21 -0800 Subject: [PATCH] skip actions when there is only 1 node --- src/allreduce_robust.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/allreduce_robust.cc b/src/allreduce_robust.cc index 538609c62..7afd3546d 100644 --- a/src/allreduce_robust.cc +++ b/src/allreduce_robust.cc @@ -68,6 +68,8 @@ void AllreduceRobust::Allreduce(void *sendrecvbuf_, ReduceFunction reducer, PreprocFunction prepare_fun, void *prepare_arg) { + // skip action in single node + if (world_size == 1) 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 && @@ -98,6 +100,8 @@ void AllreduceRobust::Allreduce(void *sendrecvbuf_, * \param root the root worker id to broadcast the data */ void AllreduceRobust::Broadcast(void *sendrecvbuf_, size_t total_size, int root) { + // skip action in single node + if (world_size == 1) return; bool recovered = RecoverExec(sendrecvbuf_, total_size, 0, seq_counter); // now we are free to remove the last result, if any if (resbuf.LastSeqNo() != -1 && @@ -143,6 +147,8 @@ void AllreduceRobust::Broadcast(void *sendrecvbuf_, size_t total_size, int root) */ int AllreduceRobust::LoadCheckPoint(ISerializable *global_model, ISerializable *local_model) { + // skip action in single node + if (world_size == 1) return 0; if (num_local_replica == 0) { utils::Check(local_model == NULL, "need to set num_local_replica larger than 1 to checkpoint local_model"); } @@ -200,6 +206,10 @@ int AllreduceRobust::LoadCheckPoint(ISerializable *global_model, */ void AllreduceRobust::CheckPoint(const ISerializable *global_model, const ISerializable *local_model) { + // never do check point in single machine mode + if (world_size == 1) { + version_number += 1; return; + } if (num_local_replica == 0) { utils::Check(local_model == NULL, "need to set num_local_replica larger than 1 to checkpoint local_model"); }