From 02e22b3a3e042cef981b7d1cfc689824edd82eeb Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Fri, 20 Feb 2009 21:04:48 +0000
Subject: [PATCH] Add configuration parameter MpiParams for (future) OpenMPI
 port     management.

---
 NEWS                             |  2 ++
 doc/html/configurator.html.in    |  1 +
 doc/man/man5/slurm.conf.5        |  6 ++++++
 slurm/slurm.h.in                 |  1 +
 src/api/config_info.c            |  2 ++
 src/common/read_config.c         |  5 +++++
 src/common/slurm_protocol_api.c  | 20 +++++++++++++++++++-
 src/common/slurm_protocol_api.h  |  6 ++++++
 src/common/slurm_protocol_defs.c |  1 +
 src/common/slurm_protocol_pack.c |  2 ++
 src/slurmctld/proc_req.c         |  1 +
 src/sview/popups.c               |  5 ++++-
 12 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 405947e461f..45d17be6c8d 100644
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,8 @@ documents those changes that are of interest to users and admins.
  -- Fix bug in backfill logic for select/cons_res plugin, resulted in 
     error "cons_res:_rm_job_from_res: node_state mis-count".
  -- Add logic go bind a batch job to the resources allocated to that job.
+ -- Add configuration parameter MpiParams for (future) OpenMPI port 
+    management.
 
 * Changes in SLURM 1.4.0-pre7
 =============================
diff --git a/doc/html/configurator.html.in b/doc/html/configurator.html.in
index 2988d9c4b6d..84d00feb6a2 100644
--- a/doc/html/configurator.html.in
+++ b/doc/html/configurator.html.in
@@ -159,6 +159,7 @@ function displayfile()
    "#MailProg=/bin/mail <br>" +
    "#MaxJobCount=5000 <br>" +
    "MpiDefault=" + get_radio_value(document.config.mpi_default) + "<br>" +
+   "#MpiParams=ports:#-# <br>" +
    "#PluginDir= <br>" +
    "#PlugStackConfig= <br>" +
    "#PrivateData=jobs <br>" +
diff --git a/doc/man/man5/slurm.conf.5 b/doc/man/man5/slurm.conf.5
index 45899a67267..5608d04e0b7 100644
--- a/doc/man/man5/slurm.conf.5
+++ b/doc/man/man5/slurm.conf.5
@@ -650,6 +650,12 @@ Currently supported versions include:
 \fBnone\fR (default, which works for many other versions of MPI including 
 LAM MPI and Open MPI).
 
+.TP
+\fBMpiParams\fR
+MPI parameters. 
+Used to identify ports used by OpenMPI only and the input format is
+"ports:1000-1234" to identify a range of communcation ports to be used.
+
 .TP
 \fBOverTimeLimit\fR
 Number of minutes by which a job can exceed its time limit before 
diff --git a/slurm/slurm.h.in b/slurm/slurm.h.in
index 522ec575751..4933b00f36c 100644
--- a/slurm/slurm.h.in
+++ b/slurm/slurm.h.in
@@ -1092,6 +1092,7 @@ typedef struct slurm_ctl_conf {
 	uint16_t min_job_age;	/* COMPLETED jobs over this age (secs) 
 	                         * purged from in memory records */
 	char *mpi_default;	/* Default version of MPI in use */
+	char *mpi_params;	/* MPI parameters */
 	uint16_t msg_timeout;	/* message timeout */
 	char *node_prefix;      /* prefix of nodes in partition, only set in 
 				   bluegene clusters NULL otherwise */
diff --git a/src/api/config_info.c b/src/api/config_info.c
index fbf2bc7a987..1df62496a29 100644
--- a/src/api/config_info.c
+++ b/src/api/config_info.c
@@ -238,6 +238,8 @@ void slurm_print_ctl_conf ( FILE* out,
 		slurm_ctl_conf_ptr->min_job_age);
 	fprintf(out, "MpiDefault              = %s\n",
 		slurm_ctl_conf_ptr->mpi_default);
+	fprintf(out, "MpiParams               = %s\n",
+		slurm_ctl_conf_ptr->mpi_params);
 #ifdef MULTIPLE_SLURMD
 	fprintf(out, "MULTIPLE_SLURMD         = %d\n", MULTIPLE_SLURMD);
 #endif
diff --git a/src/common/read_config.c b/src/common/read_config.c
index 443f0d79742..d116923c53c 100644
--- a/src/common/read_config.c
+++ b/src/common/read_config.c
@@ -192,6 +192,7 @@ s_p_options_t slurm_conf_options[] = {
 	{"MinJobAge", S_P_UINT16},
 	{"MpichGmDirectSupport", S_P_LONG, defunct_option},
 	{"MpiDefault", S_P_STRING},
+	{"MpiParams", S_P_STRING},
 	{"OverTimeLimit", S_P_UINT16},
 	{"PluginDir", S_P_STRING},
 	{"PlugStackConfig", S_P_STRING},
@@ -1208,6 +1209,7 @@ free_slurm_conf (slurm_ctl_conf_t *ctl_conf_ptr, bool purge_node_hash)
 	xfree (ctl_conf_ptr->licenses);
 	xfree (ctl_conf_ptr->mail_prog);
 	xfree (ctl_conf_ptr->mpi_default);
+	xfree (ctl_conf_ptr->mpi_params);
 	xfree (ctl_conf_ptr->node_prefix);
 	xfree (ctl_conf_ptr->plugindir);
 	xfree (ctl_conf_ptr->plugstack);
@@ -1303,6 +1305,7 @@ init_slurm_conf (slurm_ctl_conf_t *ctl_conf_ptr)
 	ctl_conf_ptr->max_mem_per_task          = 0;
 	ctl_conf_ptr->min_job_age		= (uint16_t) NO_VAL;
 	xfree (ctl_conf_ptr->mpi_default);
+	xfree (ctl_conf_ptr->mpi_params);
 	ctl_conf_ptr->msg_timeout		= (uint16_t) NO_VAL;
 	ctl_conf_ptr->next_job_id		= (uint32_t) NO_VAL;
 	xfree (ctl_conf_ptr->node_prefix);
@@ -1823,6 +1826,8 @@ validate_and_set_defaults(slurm_ctl_conf_t *conf, s_p_hashtbl_t *hashtbl)
 	if (!s_p_get_string(&conf->mpi_default, "MpiDefault", hashtbl))
 		conf->mpi_default = xstrdup(DEFAULT_MPI_DEFAULT);
 
+	s_p_get_string(&conf->mpi_params, "MpiParams", hashtbl);
+
 	if(!s_p_get_boolean((bool *)&conf->track_wckey, 
 			    "TrackWCKey", hashtbl))
 		conf->track_wckey = false;
diff --git a/src/common/slurm_protocol_api.c b/src/common/slurm_protocol_api.c
index 763e05a7f93..633fa0f3bb8 100644
--- a/src/common/slurm_protocol_api.c
+++ b/src/common/slurm_protocol_api.c
@@ -2,7 +2,7 @@
  *  slurm_protocol_api.c - high-level slurm communication functions
  *****************************************************************************
  *  Copyright (C) 2002-2007 The Regents of the University of California.
- *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Copyright (C) 2008-2009 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov>, et. al.
  *  CODE-OCEC-09-009. All rights reserved.
@@ -327,6 +327,24 @@ char *slurm_get_mpi_default(void)
 	return mpi_default;
 }
 
+/* slurm_get_mpi_params
+ * get mpi parameters value from slurmctld_conf object
+ * RET char *   - mpi default value from slurm.conf,  MUST be xfreed by caller
+ */
+char *slurm_get_mpi_params(void)
+{
+	char *mpi_params = NULL;
+	slurm_ctl_conf_t *conf;
+
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		mpi_params = xstrdup(conf->mpi_params);
+		slurm_conf_unlock();
+	}
+	return mpi_params;
+}
+
 /* slurm_get_msg_timeout
  * get default message timeout value from slurmctld_conf object
  */
diff --git a/src/common/slurm_protocol_api.h b/src/common/slurm_protocol_api.h
index 5e758e2dcd4..13df3a70137 100644
--- a/src/common/slurm_protocol_api.h
+++ b/src/common/slurm_protocol_api.h
@@ -139,6 +139,12 @@ int inline slurm_get_env_timeout(void);
  */
 char *slurm_get_mpi_default(void);
 
+/* slurm_get_mpi_params
+ * get mpi parameters value from slurmctld_conf object
+ * RET char *   - mpi default value from slurm.conf,  MUST be xfreed by caller
+ */
+char *slurm_get_mpi_params(void);
+
 /* slurm_get_msg_timeout
  * get default message timeout value from slurmctld_conf object
  */
diff --git a/src/common/slurm_protocol_defs.c b/src/common/slurm_protocol_defs.c
index ded21a2a80f..1ae79ff05fd 100644
--- a/src/common/slurm_protocol_defs.c
+++ b/src/common/slurm_protocol_defs.c
@@ -1178,6 +1178,7 @@ void slurm_free_ctl_conf(slurm_ctl_conf_info_msg_t * config_ptr)
 		xfree(config_ptr->licenses);
 		xfree(config_ptr->mail_prog);
 		xfree(config_ptr->mpi_default);
+		xfree(config_ptr->mpi_params);
 		xfree(config_ptr->node_prefix);
 		xfree(config_ptr->plugindir);
 		xfree(config_ptr->plugstack);
diff --git a/src/common/slurm_protocol_pack.c b/src/common/slurm_protocol_pack.c
index 04aa74dca39..e3365e2d97c 100644
--- a/src/common/slurm_protocol_pack.c
+++ b/src/common/slurm_protocol_pack.c
@@ -2605,6 +2605,7 @@ _pack_slurm_ctl_conf_msg(slurm_ctl_conf_info_msg_t * build_ptr, Buf buffer)
 	pack32(build_ptr->max_mem_per_task, buffer);
 	pack16(build_ptr->min_job_age, buffer);
 	packstr(build_ptr->mpi_default, buffer);
+	packstr(build_ptr->mpi_params, buffer);
 	pack16(build_ptr->msg_timeout, buffer);
 
 	pack32(build_ptr->next_job_id, buffer);
@@ -2784,6 +2785,7 @@ _unpack_slurm_ctl_conf_msg(slurm_ctl_conf_info_msg_t **
 	safe_unpack32(&build_ptr->max_mem_per_task, buffer);
 	safe_unpack16(&build_ptr->min_job_age, buffer);
 	safe_unpackstr_xmalloc(&build_ptr->mpi_default, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->mpi_params, &uint32_tmp, buffer);
 	safe_unpack16(&build_ptr->msg_timeout, buffer);
 
 	safe_unpack32(&build_ptr->next_job_id, buffer);
diff --git a/src/slurmctld/proc_req.c b/src/slurmctld/proc_req.c
index dec2e8b6ecf..72bbfcc48f6 100644
--- a/src/slurmctld/proc_req.c
+++ b/src/slurmctld/proc_req.c
@@ -445,6 +445,7 @@ void _fill_ctld_conf(slurm_ctl_conf_t * conf_ptr)
 	conf_ptr->max_mem_per_task    = conf->max_mem_per_task;
 	conf_ptr->min_job_age         = conf->min_job_age;
 	conf_ptr->mpi_default         = xstrdup(conf->mpi_default);
+	conf_ptr->mpi_params          = xstrdup(conf->mpi_params);
 	conf_ptr->msg_timeout         = conf->msg_timeout;
 
 	conf_ptr->next_job_id         = get_next_job_id();
diff --git a/src/sview/popups.c b/src/sview/popups.c
index 26e2bbf2a5e..3a7d457b340 100644
--- a/src/sview/popups.c
+++ b/src/sview/popups.c
@@ -2,7 +2,7 @@
  *  popups.c - put different popup displays here
  *****************************************************************************
  *  Copyright (C) 2002-2007 The Regents of the University of California.
- *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Copyright (C) 2008-2009 Lawrence Livermore National Security.
  *  Portions Copyright (C) 2008 Vijay Ramasubramanian
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>, et. al.
@@ -383,6 +383,9 @@ static void _layout_ctl_conf(GtkTreeStore *treestore,
 	add_display_treestore_line(update, treestore, &iter, 
 				   "MpiDefault",
 				   slurm_ctl_conf_ptr->mpi_default);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "MpiParams",
+				   slurm_ctl_conf_ptr->mpi_params);
 #ifdef MULTIPLE_SLURMD
 	add_display_treestore_line(update, treestore, &iter, 
 				   "MULTIPLE_SLURMD", "1");
-- 
GitLab