Skip to contentSkip to conversation

pi_stress: limit the number of inversion groups to the number of online cores

PATCH In review Clark Williams 2 participants 2 messages Jul 21, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pi_stress: limit the number of inversion groups to the number of online cores

Each inversion group is three SCHED_FIFO threads, so the chances of more groups than online cores actually getting to run is very slim. Limit the number of groups requested to be <= the number of online cpus.

---
 src/pi_tests/pi_stress.c | 6 ++++++
 1 file changed, 6 insertions(+)
src/pi_tests/pi_stress.c +6 -0
index 0ed844c636cd..ce446d4ea037 100644
@@ -1327,6 +1327,12 @@ void process_command_line(int argc, char **argv)
 			break;
 		case 'g':
 			ngroups = strtol(optarg, NULL, 10);
+			if (ngroups > num_processors) {
+				pi_error("the number of groups cannot exceed "
+					 "the number of online processors (%d)\n",
+					 num_processors);
+				exit(-1);
+			}
 			pi_info("number of groups set to %d\n", ngroups);
 			break;
 		case 'r':
Signature · 1 line
2.26.2
#1 lore raw
Quoted 30 lines · Clark Williams

Each inversion group is three SCHED_FIFO threads, so the chances of more groups than online cores actually getting to run is very slim. Limit the number of groups requested to be <= the number of online cpus.

---
 src/pi_tests/pi_stress.c | 6 ++++++
 1 file changed, 6 insertions(+)
src/pi_tests/pi_stress.c +6 -0
index 0ed844c636cd..ce446d4ea037 100644
@@ -1327,6 +1327,12 @@ void process_command_line(int argc, char **argv)
 			break;
 		case 'g':
 			ngroups = strtol(optarg, NULL, 10);
+			if (ngroups > num_processors) {
+				pi_error("the number of groups cannot exceed "
+					 "the number of online processors (%d)\n",
+					 num_processors);
+				exit(-1);
+			}
 			pi_info("number of groups set to %d\n", ngroups);
 			break;
 		case 'r':
Signature · 1 line
2.26.2