From a5bc91e69e5cd1e2bc3c8079b5bbcb7199f0cf7e Mon Sep 17 00:00:00 2001
From: Danny Auble <da@schedmd.com>
Date: Thu, 11 Apr 2013 12:06:59 -0700
Subject: [PATCH] CRAY - fix issue with --mem option not giving correct amount
 of memory per cpu.

---
 NEWS                                      |  2 ++
 src/plugins/select/cray/basil_interface.c | 10 ++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index c463eecfeea..c3e979e5a14 100644
--- a/NEWS
+++ b/NEWS
@@ -64,6 +64,8 @@ documents those changes that are of interest to users and admins.
     as the hosts given.
  -- CRAY - If task count specified, but no tasks-per-node, then set the tasks
     per node in the BASIL reservation request.
+ -- CRAY - fix issue with --mem option not giving correct amount of memory
+    per cpu.
 
 * Changes in Slurm 2.5.4
 ========================
diff --git a/src/plugins/select/cray/basil_interface.c b/src/plugins/select/cray/basil_interface.c
index dd1d3408691..cd2410016c4 100644
--- a/src/plugins/select/cray/basil_interface.c
+++ b/src/plugins/select/cray/basil_interface.c
@@ -793,6 +793,12 @@ extern int do_basil_reserve(struct job_record *job_ptr)
 				node_cpus = node_ptr->cpus;
 				node_mem  = node_ptr->real_memory;
 			}
+
+			/* If the job has requested memory use it (if
+			   lesser) for calculations.
+			*/
+			tmp_mppmem = MIN(node_mem, node_min_mem);
+
 			/*
 			 * ALPS 'Processing Elements per Node' value (aprun -N),
 			 * which in slurm is --ntasks-per-node and 'mppnppn' in
@@ -803,8 +809,8 @@ extern int do_basil_reserve(struct job_record *job_ptr)
 			 * mppmem and use it as the level for all
 			 * nodes (mppmem is 0 when coming in).
 			 */
-			node_mem /= mppnppn ? mppnppn : node_cpus;
-			tmp_mppmem = node_min_mem = MIN(node_mem, node_min_mem);
+			tmp_mppmem /= mppnppn ? mppnppn : node_cpus;
+
 			/* Minimum memory per processing element should be 1,
 			 * since 0 means give all the memory to the job. */
 			if (tmp_mppmem <= 0)
-- 
GitLab