Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 1926 gridstat openmp #1977

Merged
merged 30 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ed6934b
Feature 1926. Introduce OpenMP in GridStat.
mo-mglover Oct 18, 2021
86c1a50
Feature 1926. Add MET_OPENMP flag to automake setup.
mo-mglover Nov 4, 2021
b3a063a
Feature 1926. Indentation tweaks.
mo-mglover Nov 4, 2021
e0257c6
Feature 1926. Revert temporary C++17 temporary file code tweak.
mo-mglover Nov 5, 2021
7d81d41
Feature 1926. Add _OPENMP ifdef for omp.h.
mo-mglover Nov 18, 2021
3ff12fe
Feature 1926. Revert tweak to CXX optimisation level with MET_DEVELOP…
mo-mglover Nov 22, 2021
9a045e0
Per #1926, switch the OpenMP configuration option from being like MET…
JohnHalleyGotway Nov 22, 2021
4c176c4
Per #1926, just like --enable-grib2 and --enable-python, add a test p…
JohnHalleyGotway Nov 22, 2021
7043995
Feature #1926: Ensure OpenMP flag is passed to the linker. Revert to …
mo-mglover Nov 26, 2021
81c98b9
Feature #1926. Write thread count via logging, not cout.
mo-mglover Nov 30, 2021
1abb2be
Feature #1926: Add note about --enable-openmp in installation.rst
mo-mglover Nov 30, 2021
d6969c6
Per #1926, adding a call to Grid-Stat to run on 2 threads. This shoul…
JohnHalleyGotway Dec 2, 2021
2b37a69
Per #1926, updating GridStatConfig_rtma to switch width = 1 to 3. Thi…
JohnHalleyGotway Dec 2, 2021
4b2982f
Per #1926, tweak the openmp log message slightly.
JohnHalleyGotway Dec 3, 2021
3c1a5db
Per #1926, switch from manual --enable-openmp support in autoconf to …
JohnHalleyGotway Dec 3, 2021
b595de4
Per #1926, after switching to the AC_OPENMP() macro, these changes to…
JohnHalleyGotway Dec 3, 2021
359d823
Merge branch 'develop' into feature_1926_gridstat_openmp
JohnHalleyGotway Dec 3, 2021
ecaa653
Per #1926, since openmp support will now be compiled by default, swit…
JohnHalleyGotway Dec 3, 2021
9594505
Feature #1926. Use `default(none)` to force explicit `private` or `s…
mo-mglover Dec 6, 2021
e8d928b
Feature #1926: Default to single thread if OMP_NUM_THREADS is left un…
mo-mglover Dec 6, 2021
dd35aa4
Feature #1926: Add OpenMP initialisation to other tools calling fract…
mo-mglover Dec 6, 2021
e0d7840
Update met/src/basic/vx_util/handle_openmp.cc
mo-mglover Dec 16, 2021
78e4354
Update met/src/basic/vx_util/Makefile.am
mo-mglover Dec 16, 2021
b2a6c1e
Feature #1926: Lengthen OMP_NUM_THREADS debug message, plus user guid…
mo-mglover Dec 16, 2021
f39313d
Set up the Runtime Environment Variables Section and started adding i…
Dec 17, 2021
63b1fce
Updated documenation and fixed typos
Dec 21, 2021
3e89e56
removed openmp.rst in favor of having the information contained in a …
Dec 22, 2021
83688f5
Fixed typo
Dec 22, 2021
d73d537
Merge branch 'develop' into feature_1926_gridstat_openmp
JohnHalleyGotway Jan 12, 2022
821ca68
Merge branch 'develop' into feature_1926_gridstat_openmp
JohnHalleyGotway Jan 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions met/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ AC_CONFIG_HEADERS([config.h])

AM_INIT_AUTOMAKE([1.9 foreign])

# OpenMP

AC_OPENMP()

CPPFLAGS="${CPPFLAGS} ${OPENMP_CFLAGS}"
LDFLAGS="${LDFLAGS} ${OPENMP_CFLAGS}"

#
# Look for the NetCDF library
#
Expand Down
119 changes: 109 additions & 10 deletions met/docs/Users_Guide/config_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,22 @@ to use one configuration file rather than maintianing many very similar ones.
An error in the syntax of a configuration file will result in an error from the
MET tool stating the location of the parsing error.

Runtime Environment Variables
-----------------------------

MET_BASE
^^^^^^^^

The MET_BASE variable is defined in the code at compilation time as the path
to the MET shared data. These are things like the default configuration files,
common polygons and color scales. MET_BASE may be used in the MET configuration
files when specifying paths and the appropriate path will be substituted in.
If MET_BASE is defined as an environment variable, its value will be used
instead of the one defined at compilation time.

MET_OBS_ERROR_TABLE
^^^^^^^^^^^^^^^^^^^

The MET_OBS_ERROR_TABLE environment variable can be set to specify the location
of an ASCII file defining observation error information. The default table can
be found in the installed *share/met/table_files/obs_error_table.txt*. This
Expand Down Expand Up @@ -236,6 +245,9 @@ values and randomly perturbed ensemble member values. Values less than MIN are
reset to the mimimum value and values greater than MAX are reset to the maximum
value. A value of NA indicates that the variable is unbounded.

MET_GRIB_TABLES
^^^^^^^^^^^^^^^

The MET_GRIB_TABLES environment variable can be set to specify the location of
custom GRIB tables. It can either be set to a specific file name or to a
directory containing custom GRIB tables files. These file names must begin with
Expand Down Expand Up @@ -289,9 +301,96 @@ References:
| `NCEP WMO GRIB2 Documentation <http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc>`_
|

OMP_NUM_THREADS
^^^^^^^^^^^^^^^

**Introduction**

There are a number of different ways of parallelizing code. OpenMP offers
parallelism within a single shared-memory workstation or supercomputer node.
The programmer writes OpenMP directives into the code to parallelize
particular code regions.

When a parallelized code region is reached, which we shall hereafter call a
parallel region, a number of threads are spawned and work is shared among them.
Running on different cores, this reduces the execution time. At the end of the
parallel region, the code returns to single-thread execution.

A limited number of code regions are parallelized in MET. As a consequence,
there are limits to the overall speed gains acheivable. Only the parallel
regions of code will get faster with more threads, leaving the remaining
serial portions to dominate the runtime.

Not all top-level executables use parallelized code. If OpenMP is available,
a log message will appear inviting the user to increase the number of threads
for faster runtimes.

**Setting the number of threads**

The number of threads is controlled by the environment variable
*OMP_NUM_THREADS* . For example, on a quad core machine, the user might choose
to run on 4 threads:

.. code :: bash

export OMP_NUM_THREADS=4

Alternatively, the variable may be specified as a prefix to the executable
itself. For example:

.. code :: bash

OMP_NUM_THREADS=4 <exec>

The case where this variable remains unset is handled inside the code, which
defaults to a single thread.

There are choices when deciding how many threads to use. To perform a single run
as fast as possible, it would likely be appropriate to use as many threads as
there are (physical) cores available on the specific system. However, it is not
a cast-iron guarantee that more threads will always translate into more speed.
In theory, there is a chance that running across multiple non-uniform memory
access (NUMA) regions may carry negative performance impacts. This has not been
observed in practice, however.

A lower thread count is appropriate when time-to-solution is not so critical,
because cores remain idle when the code is not inside a parallel region. Fewer
threads typically means better resource utilization.

**Which code is parallelized?**

Regions of parallelized code are:

* :code:`fractional_coverage (data_plane_util.cc)`

Only the following top-level executables can presently benefit from OpenMP
parallelization:

* :code:`grid_stat`
* :code:`ensemble_stat`
* :code:`grid_ens_prod`

**Thread Binding**

It is normally beneficial to bind threads to particular cores, sometimes called
*affinitization*. There are a few reasons for this, but at the very least it
guarantees that threads remain evenly distributed across the available cores.
Otherwise, the operating system may migrate threads between cores during a run.

OpenMP provides some environment variables to handle this: :code:`OMP_PLACES`
and :code:`OMP_PROC_BIND`. We anticipate that the effect of setting only
:code:`OMP_PROC_BIND=true` would be neutral-to-positive.

However, there are sometimes compiler-specific environment variables. Instead,
thread affinitization is sometimes handled by MPI launchers, since OpenMP is
often used in MPI codes to reduce intra-node communications.

Where code is running in a production context, it is worth being familiar with
the binding / affinitization method on the particular system and building it
into any relevant scripting.

Settings common to multiple tools
_________________________________
---------------------------------

.. _exit_on_warning:

Expand Down Expand Up @@ -2190,10 +2289,10 @@ are empty. Note: grib_code 11 is equivalent to obs_var "TMP".
}

Settings specific to individual tools
_____________________________________
-------------------------------------

EnsembleStatConfig_default
~~~~~~~~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^^^^^^^^

.. _ens:

Expand Down Expand Up @@ -2505,7 +2604,7 @@ used for random assignment of ranks when they are tied.
}

MODEAnalysisConfig_default
~~~~~~~~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^^^^^^^^

MODE line options are used to create filters that determine which MODE output
lines are read in and processed. The MODE line options are numerous. They
Expand Down Expand Up @@ -2843,7 +2942,7 @@ MET User's Guide for a description of these attributes.


MODEConfig_default
~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^

.. _quilt:

Expand Down Expand Up @@ -3158,7 +3257,7 @@ much more flexible "regrid" option may be used instead.
shift_right = 0;

PB2NCConfig_default
~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^

The PB2NC tool filters out observations from PREPBUFR or BUFR files using the
following criteria:
Expand Down Expand Up @@ -3484,7 +3583,7 @@ stack (most quality controlled) or the bottom of the event stack (most raw).
event_stack_flag = TOP;

SeriesAnalysisConfig_default
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. _block_size:

Expand Down Expand Up @@ -3539,7 +3638,7 @@ grid is large.
}

STATAnalysisConfig_default
~~~~~~~~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^^^^^^^^

.. _jobs:

Expand Down Expand Up @@ -4008,7 +4107,7 @@ confidence intervals computed for the aggregated statistics.
vif_flag = FALSE;

WaveletStatConfig_default
~~~~~~~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^^^^^^^

.. _grid_decomp_flag:

Expand Down Expand Up @@ -4099,7 +4198,7 @@ similar to the "fcst_raw_plot" described in the "Settings common to multiple
tools" section.

WWMCARegridConfig_default
~~~~~~~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^^^^^^^

.. _to_grid:

Expand Down
8 changes: 8 additions & 0 deletions met/docs/Users_Guide/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,14 @@ Enable compilation of the MODE-Graphics tool. Requires $MET_CAIRO and $MET_FREET

Disable use of BLOCK4 in the compilation. Use this if you have trouble using PrepBUFR files.

.. code-block:: none

--disable-openmp

Disable compilation of OpenMP directives within the code which allows some code
regions to benefit from thread-parallel execution. Runtime environment variable
:code:`OMP_NUM_THREADS` controls the number of threads.

Run the configure script with the **-help** argument to see the full list of configuration options.

Make Targets
Expand Down
1 change: 1 addition & 0 deletions met/src/basic/vx_util/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ libvx_util_a_SOURCES = ascii_table.cc ascii_table.h \
GridOffset.h GridOffset.cc \
observation.h observation.cc \
stat_column_defs.h \
handle_openmp.h handle_openmp.cc \
RectangularTemplate.h RectangularTemplate.cc $(OPT_PYTHON_SOURCES)

libvx_util_a_CPPFLAGS = ${MET_CPPFLAGS}
Expand Down
Loading