enforce that the number of threads is properly reset for /omp styles

This commit is contained in:
Axel Kohlmeyer
2023-10-03 19:38:22 -04:00
parent 02b9bdd639
commit 6ff7050d2d
2 changed files with 13 additions and 2 deletions

View File

@ -1329,9 +1329,9 @@ void LammpsGui::preferences()
// must delete LAMMPS instance after preferences have changed that require
// using different command line flags when creating the LAMMPS instance like
// suffixes or package commands
int newthreads = settings.value("nthreads", 1).toInt();
if ((oldaccel != settings.value("accelerator", AcceleratorTab::None).toInt()) ||
(oldthreads != settings.value("nthreads", 1).toInt()) ||
(oldecho != settings.value("echo", false).toBool()) ||
(oldthreads != newthreads) || (oldecho != settings.value("echo", false).toBool()) ||
(oldcite != settings.value("cite", false).toBool())) {
if (lammps.is_running()) {
stop_run();
@ -1340,6 +1340,10 @@ void LammpsGui::preferences()
}
lammps.close();
lammpsstatus->hide();
#if defined(_OPENMP)
qputenv("OMP_NUM_THREADS", std::to_string(newthreads).c_str());
omp_set_num_threads(newthreads);
#endif
}
if (imagewindow) imagewindow->createImage();
settings.beginGroup("reformat");