From ff15e1b09931e5cb463668e9bd119f05f2c43ef6 Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Mon, 21 Mar 2011 22:24:39 +0000
Subject: [PATCH] minor tweaks to exclusive and plane option support, insure
 that each node has a CPU count that is a multiple of the plane size

---
 NEWS                      | 2 +-
 src/slurmctld/slurmctld.h | 2 +-
 src/slurmctld/step_mgr.c  | 8 +++++++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 3efe9ff9580..1695f3d27f4 100644
--- a/NEWS
+++ b/NEWS
@@ -32,7 +32,7 @@ documents those changes that are of interest to users and admins.
  -- Fix squeue/scancel to query correctly against accounts of different case.
  -- Abort an srun command when it's associated job gets aborted due to a
     dependency that can not be satisfied.
- -- When srun is used with the --exclusive and --m plane=# options, insure
+ -- When srun is used with the --exclusive and --m plane=# options, always
     allocate tasks in blocks of the plane size.
  -- In jobcomp plugins, report start time of zeroif pending job is cancelled.
     Previously may report expected start time.
diff --git a/src/slurmctld/slurmctld.h b/src/slurmctld/slurmctld.h
index 588b10452a3..96afd1db700 100644
--- a/src/slurmctld/slurmctld.h
+++ b/src/slurmctld/slurmctld.h
@@ -1527,7 +1527,7 @@ extern slurm_step_layout_t *step_layout_create(struct step_record *step_ptr,
 					       uint32_t num_tasks,
 					       uint16_t cpus_per_task,
 					       uint16_t task_dist,
-					       uint32_t plane_size);
+					       uint16_t plane_size);
 
 /* start_power_mgr - Start power management thread as needed. The thread
  *	terminates automatically at slurmctld shutdown time.
diff --git a/src/slurmctld/step_mgr.c b/src/slurmctld/step_mgr.c
index 75b65bad9d8..b4c79faeb4f 100644
--- a/src/slurmctld/step_mgr.c
+++ b/src/slurmctld/step_mgr.c
@@ -1727,7 +1727,7 @@ extern slurm_step_layout_t *step_layout_create(struct step_record *step_ptr,
 					       uint32_t num_tasks,
 					       uint16_t cpus_per_task,
 					       uint16_t task_dist,
-					       uint32_t plane_size)
+					       uint16_t plane_size)
 {
 	uint16_t cpus_per_node[node_count];
 	uint32_t cpu_count_reps[node_count], gres_cpus;
@@ -1769,6 +1769,12 @@ extern slurm_step_layout_t *step_layout_create(struct step_record *step_ptr,
 			if (step_ptr->exclusive) {
 				usable_cpus = job_resrcs_ptr->cpus[pos] -
 					      job_resrcs_ptr->cpus_used[pos];
+				if (plane_size &&
+				   (plane_size != (uint16_t)NO_VAL)) {
+					/* Round count down */
+					usable_cpus /= plane_size;
+					usable_cpus *= plane_size;
+				}
 			} else
 				usable_cpus = job_resrcs_ptr->cpus[pos];
 			if (step_ptr->mem_per_cpu && _is_mem_resv()) {
-- 
GitLab