From dba8a3ced405796ca1629916a613fe08f0a19e58 Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Fri, 5 May 2006 15:49:31 +0000
Subject: [PATCH] Set job's num_proc correctly for jobs that do not have
 exclusive use of it's allocated nodes.

---
 NEWS                                          | 2 ++
 src/plugins/select/cons_res/select_cons_res.c | 9 ++++++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 29656be9695..3376d266016 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,8 @@ documents those changes that are of interest to users and admins.
  -- added $float to globals.example in the testsuite
  -- Limit attempted BGL jobs scheduled at once to 100 (too slow with
     dynamic scheduling to handle hundreds of jobs at once).
+ -- Set job's num_proc correctly for jobs that do not have exclusive use 
+    of it's allocated nodes.
 
 * Changes in SLURM 1.1.0-pre6
 =============================
diff --git a/src/plugins/select/cons_res/select_cons_res.c b/src/plugins/select/cons_res/select_cons_res.c
index 54843a64339..4b696862ae7 100644
--- a/src/plugins/select/cons_res/select_cons_res.c
+++ b/src/plugins/select/cons_res/select_cons_res.c
@@ -996,10 +996,13 @@ extern int select_p_job_begin(struct job_record *job_ptr)
 		if (job->job_id != job_ptr->job_id)
 			continue;
 		for (i=0; i<job->nhosts; i++)
-			cnt += job->cpus[i];
-		debug2("cons_res: reset num_procs for %u from %u to %u",
+			cnt += MIN(job->cpus[i], job->ntask[i]);
+		if (job_ptr->num_procs != cnt) {
+			debug2("cons_res: reset num_procs for %u from "
+				"%u to %u", 
 				job_ptr->job_id, job_ptr->num_procs, cnt);
-		job_ptr->num_procs = cnt;
+			job_ptr->num_procs = cnt;
+		}
 		break; 
 	}
 	list_iterator_destroy(job_iterator);
-- 
GitLab