From 0dd51d5dd07a97f9cd5d0eacf7678035234d1b8a Mon Sep 17 00:00:00 2001 From: tqchen Date: Mon, 22 Dec 2014 04:12:38 -0800 Subject: [PATCH] add attempt id for hadoop --- src/allreduce_base.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/allreduce_base.cc b/src/allreduce_base.cc index 30fcfa49f..859d0b5f3 100644 --- a/src/allreduce_base.cc +++ b/src/allreduce_base.cc @@ -33,7 +33,7 @@ AllreduceBase::AllreduceBase(void) { void AllreduceBase::Init(void) { // setup from enviroment variables {// handling for hadoop - const char *task_id = getenv("mapred_task_id"); + const char *task_id = getenv("mapred_tip_id"); if (hadoop_mode != 0) { utils::Check(task_id != NULL, "hadoop_mode is set but cannot find mapred_task_id"); } @@ -41,6 +41,14 @@ void AllreduceBase::Init(void) { this->SetParam("rabit_task_id", task_id); this->SetParam("rabit_hadoop_mode", "1"); } + const char *attempt_id = getenv("mapred_task_id"); + if (attempt_id != 0) { + const char *att = strrchr(attempt_id, '_'); + int num_trial; + if (att != NULL && sscanf(att+1, "%d", &num_trial) == 1) { + this->SetParam("rabit_num_trial", att + 1); + } + } // handling for hadoop const char *num_task = getenv("mapred_map_tasks"); if (num_task == NULL) {