enforce that the number of threads is properly reset for /omp styles
This commit is contained in:
@ -34,6 +34,10 @@
|
|||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
#if defined(_OPENMP)
|
||||||
|
#include <omp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using MathConst::THIRD;
|
using MathConst::THIRD;
|
||||||
|
|
||||||
@ -44,6 +48,9 @@ ThrOMP::ThrOMP(LAMMPS *ptr, int style) : lmp(ptr), fix(nullptr), thr_style(style
|
|||||||
// register fix omp with this class
|
// register fix omp with this class
|
||||||
fix = static_cast<FixOMP *>(lmp->modify->get_fix_by_id("package_omp"));
|
fix = static_cast<FixOMP *>(lmp->modify->get_fix_by_id("package_omp"));
|
||||||
if (!fix) lmp->error->all(FLERR, "The 'package omp' command is required for /omp styles");
|
if (!fix) lmp->error->all(FLERR, "The 'package omp' command is required for /omp styles");
|
||||||
|
#if defined(_OPENMP)
|
||||||
|
omp_set_num_threads(lmp->comm->nthreads);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|||||||
@ -1329,9 +1329,9 @@ void LammpsGui::preferences()
|
|||||||
// must delete LAMMPS instance after preferences have changed that require
|
// must delete LAMMPS instance after preferences have changed that require
|
||||||
// using different command line flags when creating the LAMMPS instance like
|
// using different command line flags when creating the LAMMPS instance like
|
||||||
// suffixes or package commands
|
// suffixes or package commands
|
||||||
|
int newthreads = settings.value("nthreads", 1).toInt();
|
||||||
if ((oldaccel != settings.value("accelerator", AcceleratorTab::None).toInt()) ||
|
if ((oldaccel != settings.value("accelerator", AcceleratorTab::None).toInt()) ||
|
||||||
(oldthreads != settings.value("nthreads", 1).toInt()) ||
|
(oldthreads != newthreads) || (oldecho != settings.value("echo", false).toBool()) ||
|
||||||
(oldecho != settings.value("echo", false).toBool()) ||
|
|
||||||
(oldcite != settings.value("cite", false).toBool())) {
|
(oldcite != settings.value("cite", false).toBool())) {
|
||||||
if (lammps.is_running()) {
|
if (lammps.is_running()) {
|
||||||
stop_run();
|
stop_run();
|
||||||
@ -1340,6 +1340,10 @@ void LammpsGui::preferences()
|
|||||||
}
|
}
|
||||||
lammps.close();
|
lammps.close();
|
||||||
lammpsstatus->hide();
|
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();
|
if (imagewindow) imagewindow->createImage();
|
||||||
settings.beginGroup("reformat");
|
settings.beginGroup("reformat");
|
||||||
|
|||||||
Reference in New Issue
Block a user