mcexec: verify number of processes for partitioned execution

This commit is contained in:
Balazs Gerofi
2017-09-21 16:11:56 +09:00
parent 203bfc2492
commit 5664125e57

View File

@ -2150,6 +2150,11 @@ int main(int argc, char **argv)
return 1;
}
if (nr_processes > ncpu) {
fprintf(stderr, "error: nr_processes can't exceed nr. of CPUs\n");
return EINVAL;
}
if (nr_threads > 0) {
n_threads = nr_threads;
}
@ -2162,13 +2167,16 @@ int main(int argc, char **argv)
* When running with partitioned execution, do not allow
* more threads then the corresponding number of CPUs.
*/
if (nr_processes > 0) {
if (nr_processes > 0 && nr_processes < ncpu) {
n_threads = (ncpu / nr_processes) + 4;
if (n_threads == 0) {
n_threads = 2;
}
}
else if (nr_processes == ncpu) {
n_threads = 1;
}
else {
n_threads = ncpu;
}