mcexec: limit nr. of threads for non-OpenMP partitioned execution

This commit is contained in:
Balazs Gerofi
2017-09-21 15:30:37 +09:00
parent 973d8ddd2c
commit 203bfc2492

View File

@@ -2157,9 +2157,22 @@ int main(int argc, char **argv)
/* Leave some headroom for helper threads.. */ /* Leave some headroom for helper threads.. */
n_threads = atoi(getenv("OMP_NUM_THREADS")) + 4; n_threads = atoi(getenv("OMP_NUM_THREADS")) + 4;
} }
else {
/*
* When running with partitioned execution, do not allow
* more threads then the corresponding number of CPUs.
*/
if (nr_processes > 0) {
n_threads = (ncpu / nr_processes) + 4;
if (n_threads == 0) {
n_threads = 2;
}
}
else { else {
n_threads = ncpu; n_threads = ncpu;
} }
}
/* /*
* XXX: keep thread_data ncpu sized despite that there are only * XXX: keep thread_data ncpu sized despite that there are only