|
ampsci
High-precision calculations for one- and two-valence atomic systems
|
Thread-safe progress bar for OpenMP parallel loops.
Displays a progress bar with percentage. The progress counter uses std::atomic for thread-safe updates. Each call to update() increments the counter and prints the bar. The output is serialised via critical section to prevent garbled output from simultaneous writes.
Length / 5 values, spaced evenly.The Length template parameter controls output width. For TTY mode: total bar width in characters. For non-TTY mode: determines how many percentage values are printed (~Length/5).
break;), then final the newline \n will not be printed. Output may be messy. Cannot break like this in OpenMP loop anyway.For non-parallel loops, the simpler qip::progbar() function should work fine.
Typical usage in a parallel loop:
| Length | Total character width of the output (default 60). |
#include <Widgets.hpp>
Public Member Functions | |
| ProgressBar (int max, bool print) | |
Construct progress bar for max iterations. | |
| void | update () |
| Atomically increment progress counter and print updated bar. | |
|
inline |
Construct progress bar for max iterations.
| max | Total number of iterations (denominator for percentage). |
| Runtime switch; if false, class does nothing. |
|
inline |
Atomically increment progress counter and print updated bar.