From 512a1dcba425ae3f394771b2a274ef336be4e6df Mon Sep 17 00:00:00 2001
From: Morris Jette <jette@schedmd.com>
Date: Fri, 7 Jul 2017 14:50:20 -0600
Subject: [PATCH] Disable multiple steps per pack job component with single
 srun command

---
 doc/html/heterogeneous_jobs.shtml |  4 ++++
 src/srun/libsrun/srun_job.c       | 12 ++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/doc/html/heterogeneous_jobs.shtml b/doc/html/heterogeneous_jobs.shtml
index c8ab10f47e8..ec6dcc4deb8 100644
--- a/doc/html/heterogeneous_jobs.shtml
+++ b/doc/html/heterogeneous_jobs.shtml
@@ -319,6 +319,10 @@ the job execute on different clusters in the federation.</p>
 <p>The srun command's --no-allocate option is not supported
 for heterogeneous jobs.</p>
 
+<p>Only one job step per heterogeneous job component can be launched by a
+single srun command (e.g.
+"srun --pack-group=0 alpha : --pack-group=0 beta" is not supported).</p>
+
 <p>The sattach command can only be used to attach to a single component of
 a heterogeneous job at a time.</p>
 
diff --git a/src/srun/libsrun/srun_job.c b/src/srun/libsrun/srun_job.c
index 4026bd66728..da54fbac8db 100644
--- a/src/srun/libsrun/srun_job.c
+++ b/src/srun/libsrun/srun_job.c
@@ -458,6 +458,7 @@ static void _pack_grp_test(List opt_list)
 	ListIterator iter;
 	opt_t *opt_local;
 	int pack_offset;
+	bitstr_t *master_map = NULL;
 
 	if (opt_list) {
 		iter = list_iterator_create(opt_list);
@@ -469,7 +470,18 @@ static void _pack_grp_test(List opt_list)
 				xstrfmtcat(opt_local->pack_group, "%d",
 					   pack_offset);
 			}
+			if (!master_map) {
+				master_map = bit_copy(opt_local->pack_grp_bits);
+			} else {
+				if (bit_overlap(master_map,
+						opt_local->pack_grp_bits)) {
+					error("Duplicate pack groups in single srun not supported");
+					exit(error_exit);
+				}
+				bit_or(master_map, opt_local->pack_grp_bits);
+			}
 		}
+		FREE_NULL_BITMAP(master_map);
 		list_iterator_destroy(iter);
 	} else if (!opt.pack_group && !getenv("SLURM_PACK_SIZE")) {
 		FREE_NULL_BITMAP(opt.pack_grp_bits);
-- 
GitLab