Hi everybody!

Here attached is a patch that enables partition based SelectType (currently CR_Socket/CR_Core) in select/cons_res.

The patch requires that CR_ALLOCATE_FULL_SOCKET is enabled to work and also this patch from master branch: https://github.com/SchedMD/slurm/commit/cdf679d0158a246e7389a15b62f127e5142003fe

It should however be easy to change it to use the old #define if you want to.

We are currently testing this in our development system but will go into production later this spring based on needs from some of our users.

One thing that I noticed during the development of this is that if a new option is added to the slurm.conf that is not supported with an earlier version of slurm programs/libs that are compiled with the earlier version stops working due to complaining of errors in slurm.conf.

We have the CR_ALLOCATE_FULL_SOCKET patch in our production system and some programs linked with openmpi stop working for some of our users.

It might we wise to try require less reading of the slurm.conf from the core parts of slurm and try to put more reading/parsing of the config file from the plugins (and other modular parts of slurm).

Best regards,
Magnus

--
Magnus Jonsson, Developer, HPC2N, UmeƄ Universitet
diff --git a/src/common/read_config.c b/src/common/read_config.c
index 2a54f69..b8d981b 100644
--- a/src/common/read_config.c
+++ b/src/common/read_config.c
@@ -903,6 +903,7 @@ static int _parse_partitionname(void **dest, slurm_parser_enum_t type,
 		{"ReqResv", S_P_BOOLEAN}, /* YES or NO */
 		{"Shared", S_P_STRING}, /* YES, NO, or FORCE */
 		{"State", S_P_STRING}, /* UP, DOWN, INACTIVE or DRAIN */
+		{"SelectType", S_P_STRING}, /* CR_Socket, CR_Core */
 		{NULL}
 	};
 
@@ -1125,6 +1126,22 @@ static int _parse_partitionname(void **dest, slurm_parser_enum_t type,
 		} else
 			p->state_up = PARTITION_UP;
 
+		if (s_p_get_string(&tmp, "SelectType", tbl)) {
+			if (strncasecmp(tmp, "CR_Socket", 9) == 0)
+				p->cr_type = CR_SOCKET;
+			else if (strncasecmp(tmp, "CR_Core", 7) == 0)
+				p->cr_type = CR_CORE;
+			else {
+				error("Bad value \"%s\" for SelectType", tmp);
+				_destroy_partitionname(p);
+				s_p_hashtbl_destroy(tbl);
+				xfree(tmp);
+				return -1;
+			}
+			xfree(tmp);
+		} else
+			p->cr_type = 0;
+
 		s_p_hashtbl_destroy(tbl);
 
 		*dest = (void *)p;
diff --git a/src/common/read_config.h b/src/common/read_config.h
index 7d017dc..a39a3c9 100644
--- a/src/common/read_config.h
+++ b/src/common/read_config.h
@@ -227,6 +227,7 @@ typedef struct slurm_conf_partition {
 	uint16_t state_up;	/* for states see PARTITION_* in slurm.h */
 	uint32_t total_nodes;	/* total number of nodes in the partition */
 	uint32_t total_cpus;	/* total number of cpus in the partition */
+	uint16_t cr_type;	/* Custom CR values for partition (if supported by select plugin) */
 } slurm_conf_partition_t;
 
 typedef struct slurm_conf_downnodes {
diff --git a/src/plugins/select/cons_res/select_cons_res.c b/src/plugins/select/cons_res/select_cons_res.c
index 364a683..142f252 100644
--- a/src/plugins/select/cons_res/select_cons_res.c
+++ b/src/plugins/select/cons_res/select_cons_res.c
@@ -1451,8 +1451,18 @@ static int _test_only(struct job_record *job_ptr, bitstr_t *bitmap,
 {
 	int rc;
 
+	uint16_t tmp_cr_type = cr_type;
+	if(job_ptr->part_ptr->cr_type) {
+		if( ( (cr_type & CR_SOCKET) || (cr_type & CR_CORE) ) && (cr_type & CR_ALLOCATE_FULL_SOCKET) ) {
+			tmp_cr_type &= ~(CR_SOCKET|CR_CORE);
+			tmp_cr_type |= job_ptr->part_ptr->cr_type;
+		} else {
+			info("cons_res: Can't use Partition SelectType unless using CR_Socket or CR_Core and CR_ALLOCATE_FULL_SOCKET");
+		}
+	}
+
 	rc = cr_job_test(job_ptr, bitmap, min_nodes, max_nodes, req_nodes,
-			 SELECT_MODE_TEST_ONLY, cr_type, job_node_req,
+			 SELECT_MODE_TEST_ONLY, tmp_cr_type, job_node_req,
 			 select_node_cnt, select_part_record,
 			 select_node_usage, NULL);
 	return rc;
@@ -1489,14 +1499,24 @@ static int _run_now(struct job_record *job_ptr, bitstr_t *bitmap,
 	bool remove_some_jobs = false;
 	uint16_t pass_count = 0;
 	uint16_t mode;
+	uint16_t tmp_cr_type = cr_type;
 
 	save_bitmap = bit_copy(bitmap);
 top:	orig_map = bit_copy(save_bitmap);
 	if (!orig_map)
 		fatal("bit_copy: malloc failure");
 
+	if(job_ptr->part_ptr->cr_type) {
+		if( ( (cr_type & CR_SOCKET) || (cr_type & CR_CORE) ) && (cr_type & CR_ALLOCATE_FULL_SOCKET) ) {
+			tmp_cr_type &= ~(CR_SOCKET|CR_CORE);
+			tmp_cr_type |= job_ptr->part_ptr->cr_type;
+		} else {
+			info("cons_res: Can't use Partition SelectType unless using CR_Socket or CR_Core and CR_ALLOCATE_FULL_SOCKET");
+		}
+	}
+
 	rc = cr_job_test(job_ptr, bitmap, min_nodes, max_nodes, req_nodes,
-			 SELECT_MODE_RUN_NOW, cr_type, job_node_req,
+			 SELECT_MODE_RUN_NOW, tmp_cr_type, job_node_req,
 			 select_node_cnt, select_part_record,
 			 select_node_usage, exc_core_bitmap);
 
@@ -1536,7 +1556,7 @@ top:	orig_map = bit_copy(save_bitmap);
 			rc = cr_job_test(job_ptr, bitmap, min_nodes,
 					 max_nodes, req_nodes,
 					 SELECT_MODE_WILL_RUN,
-					 cr_type, job_node_req,
+					 tmp_cr_type, job_node_req,
 					 select_node_cnt,
 					 future_part, future_usage,
 					 exc_core_bitmap);
@@ -1636,14 +1656,24 @@ static int _will_run_test(struct job_record *job_ptr, bitstr_t *bitmap,
 	bitstr_t *orig_map;
 	int action, rc = SLURM_ERROR;
 	time_t now = time(NULL);
+	uint16_t tmp_cr_type = cr_type;
 
 	orig_map = bit_copy(bitmap);
 	if (!orig_map)
 		fatal("bit_copy: malloc failure");
 
+	if(job_ptr->part_ptr->cr_type) {
+		if( ( (cr_type & CR_SOCKET) || (cr_type & CR_CORE) ) && (cr_type & CR_ALLOCATE_FULL_SOCKET) ) {
+			tmp_cr_type &= ~(CR_SOCKET|CR_CORE);
+			tmp_cr_type |= job_ptr->part_ptr->cr_type;
+		} else {
+			info("cons_res: Can't use Partition SelectType unless using CR_Socket or CR_Core and CR_ALLOCATE_FULL_SOCKET");
+		}
+	}
+
 	/* Try to run with currently available nodes */
 	rc = cr_job_test(job_ptr, bitmap, min_nodes, max_nodes, req_nodes,
-			 SELECT_MODE_WILL_RUN, cr_type, job_node_req,
+			 SELECT_MODE_WILL_RUN, tmp_cr_type, job_node_req,
 			 select_node_cnt, select_part_record,
 			 select_node_usage, exc_core_bitmap);
 	if (rc == SLURM_SUCCESS) {
@@ -1701,7 +1731,7 @@ static int _will_run_test(struct job_record *job_ptr, bitstr_t *bitmap,
 	if (preemptee_candidates) {
 		bit_or(bitmap, orig_map);
 		rc = cr_job_test(job_ptr, bitmap, min_nodes, max_nodes,
-				 req_nodes, SELECT_MODE_WILL_RUN, cr_type,
+				 req_nodes, SELECT_MODE_WILL_RUN, tmp_cr_type,
 				 job_node_req, select_node_cnt, future_part,
 				 future_usage, exc_core_bitmap);
 		if (rc == SLURM_SUCCESS)
@@ -1727,7 +1757,7 @@ static int _will_run_test(struct job_record *job_ptr, bitstr_t *bitmap,
 					 tmp_job_ptr, 0);
 			rc = cr_job_test(job_ptr, bitmap, min_nodes,
 					 max_nodes, req_nodes,
-					 SELECT_MODE_WILL_RUN, cr_type,
+					 SELECT_MODE_WILL_RUN, tmp_cr_type,
 					 job_node_req, select_node_cnt,
 					 future_part, future_usage,
 					 exc_core_bitmap);
diff --git a/src/slurmctld/partition_mgr.c b/src/slurmctld/partition_mgr.c
index 40ef2cd..15622c6 100644
--- a/src/slurmctld/partition_mgr.c
+++ b/src/slurmctld/partition_mgr.c
@@ -237,6 +237,7 @@ struct part_record *create_part_record(void)
 	part_ptr->preempt_mode      = default_part.preempt_mode;
 	part_ptr->priority          = default_part.priority;
 	part_ptr->grace_time 	    = default_part.grace_time;
+	part_ptr->cr_type	    = default_part.cr_type;
 	if(part_max_priority)
 		part_ptr->norm_priority = (double)default_part.priority
 			/ (double)part_max_priority;
@@ -458,7 +459,7 @@ int load_all_part_state(void)
 	uint32_t grace_time = 0;
 	time_t time;
 	uint16_t flags;
-	uint16_t max_share, preempt_mode, priority, state_up;
+	uint16_t max_share, preempt_mode, priority, state_up, cr_type;
 	struct part_record *part_ptr;
 	uint32_t data_size = 0, name_len;
 	int data_allocated, data_read = 0, error_code = 0, part_cnt = 0;
@@ -540,6 +541,7 @@ int load_all_part_state(void)
 				part_max_priority = priority;
 
 			safe_unpack16(&state_up, buffer);
+			safe_unpack16(&cr_type, buffer);
 			safe_unpackstr_xmalloc(&allow_groups,
 					       &name_len, buffer);
 			safe_unpackstr_xmalloc(&allow_alloc_nodes,
@@ -607,6 +609,7 @@ int load_all_part_state(void)
 			part_ptr->preempt_mode   = preempt_mode;
 		part_ptr->priority       = priority;
 		part_ptr->state_up       = state_up;
+		part_ptr->cr_type	 = cr_type;
 		xfree(part_ptr->allow_groups);
 		part_ptr->allow_groups   = allow_groups;
 		xfree(part_ptr->allow_alloc_nodes);
@@ -707,6 +710,7 @@ int init_part_conf(void)
 	default_part.total_nodes    = 0;
 	default_part.total_cpus     = 0;
 	default_part.grace_time     = 0;
+	default_part.cr_type	    = 0;
 	xfree(default_part.nodes);
 	xfree(default_part.allow_groups);
 	xfree(default_part.allow_uids);
diff --git a/src/slurmctld/read_config.c b/src/slurmctld/read_config.c
index 82ccd33..0bc513a 100644
--- a/src/slurmctld/read_config.c
+++ b/src/slurmctld/read_config.c
@@ -593,6 +593,7 @@ static int _build_single_partitionline_info(slurm_conf_partition_t *part)
 	part_ptr->priority       = part->priority;
 	part_ptr->state_up       = part->state_up;
 	part_ptr->grace_time     = part->grace_time;
+	part_ptr->cr_type        = part->cr_type;
 
 	if (part->allow_groups) {
 		xfree(part_ptr->allow_groups);
diff --git a/src/slurmctld/slurmctld.h b/src/slurmctld/slurmctld.h
index 7546548..6440ff8 100644
--- a/src/slurmctld/slurmctld.h
+++ b/src/slurmctld/slurmctld.h
@@ -313,6 +313,7 @@ struct part_record {
 	uint16_t state_up;	/* See PARTITION_* states in slurm.h */
 	uint32_t total_nodes;	/* total number of nodes in the partition */
 	uint32_t total_cpus;	/* total number of cpus in the partition */
+	uint16_t cr_type;	/* Custom CR values for partition (if supported by select plugin) */
 };
 
 extern List part_list;			/* list of part_record entries */

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to