show warning dialog at end of run, if I/O buffer usage was very high

This commit is contained in:
Axel Kohlmeyer
2025-07-06 03:07:35 -04:00
parent bd4641ac0f
commit 642e220bd2
3 changed files with 40 additions and 5 deletions

View File

@ -270,11 +270,19 @@ green in the line number display for the *Editor* Window.
running a simulation of a small system. In the *Preferences* dialog,
the polling interval for updating the the *Output* and *Charts*
windows can be set. The intervals may need to be lowered to not miss
data between updates or avoid stalling when the thermo output is not
transferred to the *Output* window fast enough, but that increases
the overhead. The utilization can also be lower, e.g. when the
simulation is slowed down by the GUI or other processes also running
on the host computer and competing with LAMMPS-GUI for GPU resources.
data between *Charts* data updates or to avoid stalling when the
thermo output is not transferred to the *Output* window fast enough.
It is also possible to reduce the amount of data by increasing the
:doc:`thermo interval <thermo>`. LAMMPS-GUI detects, if the
associated I/O buffer is by a significant percentage and will print a
warning after the run with suggested adjustments. The utilization
can also be lower, e.g. when the simulation is slowed down by the
GUI or other processes also running on the host computer and
competing with LAMMPS-GUI for GPU resources.
.. image:: JPG/lammps-gui-buffer-warn.png
:align: center
:scale: 75%
If an error occurs (in the example below the command :doc:`label
<label>` was incorrectly capitalized as "Label"), an error message

View File

@ -59,6 +59,7 @@
<description>
Address the issue of LAMMPS stalling on output by increasing
the buffersize for reading from the pipe to the maximum of 64k.
Add warning dialog at the end of a run if I/O buffer usage is high.
Apply fixes and code modernization suggested by clang-tidy
Make selection of accelerator and threads consistent
Add support for some common package command options

View File

@ -57,6 +57,7 @@
#include <QWizardPage>
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <cstring>
@ -1182,6 +1183,31 @@ void LammpsGui::run_done()
logwindow->insertPlainText(log.c_str());
logwindow->moveCursor(QTextCursor::End);
// check stdout capture buffer utilization and print warning message if large
double bufferuse = capturer->get_bufferuse();
if (bufferuse > 0.333) {
int thermo_val = lammps.extract_setting("thermo_every");
int thermo_suggest = 5 * (int)round(bufferuse * thermo_val);
int update_val = QSettings().value("updfreq", 100).toInt();
int update_suggest = std::max(1, update_val / 5);
QString mesg(
"<p align=\"justified\">The I/O buffer for capturing the LAMMPS screen output was used "
"by up to %1%.</p> <p align=\"justified\"><b>This can slow down the "
"simulation.</b></p> <p align=\"justified\">Please consider reducing the amount of "
"output to the screen, for example by increasing the thermo interval in the input "
"from %2 to %3, or reducing the data update interval in the preferences from %4 to %5, "
"or something similar.</p>");
QMessageBox::critical(this, " Warning: High I/O Buffer Usage",
mesg.arg((int)(100.0 * bufferuse))
.arg(thermo_val)
.arg(thermo_suggest)
.arg(update_val)
.arg(update_suggest));
}
if (chartwindow) {
void *ptr = lammps.last_thermo("step", 0);
if (ptr) {