From 58c211406d5182c6f188adcb57758b09d7265d5f Mon Sep 17 00:00:00 2001
From: jette <jette@schedmd.com>
Date: Tue, 4 Jun 2013 09:58:43 -0700
Subject: [PATCH] launch/poe - Fix for hostlist file support with repeated host
 names.

Without this change, it appears that POE ignores the -procs argument
resulting in a job step request with multiple host names, but only
one ntask required
---
 NEWS                                       | 1 +
 src/plugins/switch/nrt/libpermapi/shr_64.c | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/NEWS b/NEWS
index dc5fc0b0de5..f509c95c0c2 100644
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,7 @@ documents those changes that are of interest to users and admins.
  -- Select/cons_res - Fix bug resulting in error of "cons_res: sync loop not
     progressing, holding job #"
  -- checkpoint/blcr - Reset max_nodes from zero to NO_VAL on job restart.
+ -- launch/poe - Fix for hostlist file support with repeated host names.
 
 * Changes in Slurm 2.5.6
 ========================
diff --git a/src/plugins/switch/nrt/libpermapi/shr_64.c b/src/plugins/switch/nrt/libpermapi/shr_64.c
index f4cc258351f..9d25cc13b2b 100644
--- a/src/plugins/switch/nrt/libpermapi/shr_64.c
+++ b/src/plugins/switch/nrt/libpermapi/shr_64.c
@@ -1844,6 +1844,7 @@ int pe_rm_submit_job(rmhandle_t resource_mgr, job_command_t job_cmd,
 	    && pe_job_req->host_names && *pe_job_req->host_names) {
 		/* This means there was a hostfile used for this job.
 		 * So we need to set up the arbitrary distribution of it. */
+		int hostfile_count = 0;
 		char **names = pe_job_req->host_names;
 		opt.distribution = SLURM_DIST_ARBITRARY;
 		while (names && *names) {
@@ -1853,7 +1854,10 @@ int pe_rm_submit_job(rmhandle_t resource_mgr, job_command_t job_cmd,
 			else
 				opt.nodelist = xstrdup(strtok(*names, "."));
 			names++;
+			hostfile_count++;
 		}
+		if (pe_job_req->total_tasks == -1)
+			pe_job_req->total_tasks = hostfile_count;
 	}
 
 	if (pe_job_req->num_nodes != -1)
-- 
GitLab