.. _xios3demo: ****************** XIOS3 demonstrator ****************** .. contents:: :local: Overview ======== NEMO version 5.0 includes a new configuration: ``cfgs/X3_ORCA2_ICE_PISCES`` which is a variation on the ``ORCA2_ICE_PISCES`` reference configuration designed to illustrate the XML changes required to utilise the new XIOS3 functionalities. This is in advance of any detailed documentation on XIOS3 and is based mainly on material presented by the XIOS developers at a coupling workshop in 2023. The slides from that presentation can be found `here `_ . The X3_ORCA2_ICE_PISCES demonstrator is based on the SETTE tests for ``ORCA2_ICE_PISCES``. Traditionally, this is run with 32 Ocean cores and 4 XIOS servers producing one-file output. This XIOS3 example has also been run with 32 ocean cores but has used 12 XIOS3 servers to produce one-file output via various pools and services. Whilst, in this case, not much has been gained, the ability to control exactly how the xios resources are deployed and employed should make for robust solutions in more demanding cases. This has already been successfully tested in an eORCA025 configuration where 1019 ocean cores have reliably produced one-file output via 52 xios servers. This latter example is illustrated on a XIOS ticket at: `XIOS forge ticket 190 `_ . For now, this simpler example will be used to explain the options and highlight the XML changes required to make it happen. First, here is a schematic of the example: .. figure:: _static/X3_O2IP_example.png :width: 100% :align: center .. The idea is that, instead of all fields going to all xios servers, subsets of xios servers are assigned to gather different groups of fields. These "gatherer" services then send the collated fields to dedicated "writer" services. In this example, separate gatherer services, with 2-cores each, are used for: T- and W-grid variables; ice fields; U- and V-grid variables and passive tracer fields. These services are named: tgatherer, igatherer, ugatherer and pgatherer. Larger configurations may elect to have separate services for different output frequencies too to spread the memory footprint. Each of these gatherer services has an associated writer service: twriter; iwriter; uwriter and pwriter. Each writer service has only one server process assigned to it, thus guaranteeing one-file output. With larger configurations, more writing processes may be required per writing service but it is expected that numbers can be kept low enough for the "one_file" activation of netcdf4 output to be suitably robust and efficient. Changes to ``iodef.xml`` ------------------------ All of this is set up via xml tags in the ``iodef.xml`` file, namely: .. code-block:: xml 400000 performance true 0 false false p2p false Much of this will be familiar and carries over from XIOS2. The new ``pool_definition`` tag and the syntax of its contents is also straight-forward. There are a couple of subtleties to point out: .. code-block:: xml p2p This is a new transport_protocol using point to point communication and has proven to be the most reliable in these tests. .. code-block:: xml New attributes added to the context tag which declare the default pool from which named gatherers and writers will be selected. Changes to ``file_defs`` ------------------------ Next, to make use of these services they have to be assigned at the file level. For example, here are the changes in the ``file_def_nemo-ice.xml``: .. code-block:: diff --- ../../ORCA2_ICE_PISCES/EXPREF/file_def_nemo-ice.xml 2023-09-15 16:57:00.039299000 +0100 +++ file_def_nemo-ice.xml 2023-09-21 13:10:36.750776000 +0100 @@ -9,10 +9,10 @@ ============================================================================================================ --> - + - + @@ -89,7 +89,7 @@ - + @@ -123,7 +123,7 @@ - + extract_axis in axis_def_nemo.xml and the change of all: .. code-block:: sh zoom_domain ---> extract_domain in domain_def_nemo.xml There are additional changes in the ``field_def*.xml`` files and the ``domain_def_nemo.xml`` and ``axis_def_nemo.xml`` files which are to do with the next stage of exercising control over dataset chunking and compression. Chunking and compression ------------------------ One goal of making one file output from XIOS more reliable is to eliminate the need for any further post-processing of the output. With this in mind, it may be necessary to exercise control over the chunk sizes used for the output files since the optimum choice will depend on future access requirements. XIOS3 has a selection of XML attributes that control the chunk sizes but achieving particular target chunk dimensions isn't straight-forward. These attributes are a range of domain, axis and field settings listed here: ========================= ============== ================ attribute name attribute type default setting ========================= ============== ================ chunking_weight_i domain 1.0 chunking_weight_j domain 1.0 chunking_weight axis 1.0 chunking_blocksize_target field 20.0 (MB) prec field 4 or 8 compression_level file 0 ========================= ============== ================ The last does not actually affect the chunk size but is included as a reminder that one major reason to activate chunking is to allow efficient dataset compression (which is off by default). `Ticket #191 `_ on the XIOS forge contains an explanation of the algorithm that is used. Based on this, a chunk size calculator has been added in ``tools/MISCELLANEOUS/calc_xios_chunks.py``: .. code-block:: sh python3 calc_xios_chunks.py --help usage: calc_xios_chunks.py [-h] [-i ISIZE] [-j JSIZE] [-k KSIZE] [-t TARGET] [-p PREC] [-wi WI] [-wj WJ] [-wk WK] Calculate netCDF4 chunks sizes that XIOS will use based on domain size and chunk_weight and chunk_blocksize_targets set as XML attributes, e.g.: python3 ./calc_xios_chunks.py -i isize -j jsize -k ksize -t target -p fp_precision -wi wgt_i -wj wgt_j -wk wgt_k All arguments are optional with default settings equivalent to XIOS defaults with a eORCA025-size domain optional arguments: -h, --help show this help message and exit -i ISIZE First dimension size of the domain (usually longitudinal) [1440] -j JSIZE Second dimension size of the domain (usually latitudinal) [1206] -k KSIZE Third dimension size of the domain (usually depth) [75] -t TARGET Target chunk blocksize in MB [20.0] -p PREC Floating-point byte-size of op variables, (usually 4 or 8) [4] -wi WI Weight applied to the first dimension [1.0] -wj WJ Weight applied to the second dimension [1.0] -wk WK Weight applied to the third dimension [1.0] So for ORCA2 with default settings we have: .. code-block:: sh python3 calc_xios_chunks.py -i 180 -j 148 -k 31 ----------------------------------------------------- XYZ domain size : 180 x 148 x 31 Target chunksize : 20 MB, FP precision: 4 i- j- and k- weights: 1.0 1.0 1.0 4D TZYX chunk sizes : 1 31 148 180 3D TYX chunk sizes : 1 148 180 ----------------------------------------------------- Thus, without any intervention, the default behaviour for ORCA2 is to have the entire model volume as a single chunk. With compression, this can be wasteful since any future access, even for a single datum, has to retrieve and uncompress the entire chunk. Adjusting the various weights and block size target will change this, for example: .. code-block:: sh python3 calc_xios_chunks.py -i 180 -j 148 -k 31 -wk 12. -t 3 ----------------------------------------------------- XYZ domain size : 180 x 148 x 31 Target chunksize : 3 MB, FP precision: 4 i- j- and k- weights: 1.0 1.0 12.0 4D TZYX chunk sizes : 1 6 148 180 3D TYX chunk sizes : 1 148 180 ----------------------------------------------------- which is the choice provided with the demonstrator. These settings can be seen in situ by examining the XML files provided with the demonstrator. I.e.: .. code-block:: xml grep -e chunking_ -e compression *.xml axis_def_nemo.xml: axis_def_nemo.xml: axis_def_nemo.xml: axis_def_nemo.xml: axis_def_nemo.xml: axis_def_nemo.xml: axis_def_nemo.xml: domain_def_nemo.xml: domain_def_nemo.xml: domain_def_nemo.xml: domain_def_nemo.xml: domain_def_nemo.xml: domain_def_nemo.xml: domain_def_nemo.xml: domain_def_nemo.xml: domain_def_nemo.xml: domain_def_nemo.xml: field_def_nemo-ice.xml: field_def_nemo-oce.xml: field_def_nemo-pisces.xml: file_def_nemo-ice.xml: file_def_nemo-ice.xml: file_def_nemo-ice.xml: file_def_nemo-oce.xml: file_def_nemo-oce.xml: file_def_nemo-pisces.xml: file_def_nemo-pisces.xml: With this small model it is difficult to force division of the primary axes but it can be done. Perhaps this is a reasonable choice if future access is likely to favour either Northern or Southern hemispheres: .. code-block:: sh python3 calc_xios_chunks.py -i 180 -j 148 -k 31 -wj 2 -wk 12. -t 1 ----------------------------------------------------- XYZ domain size : 180 x 148 x 31 Target chunksize : 1 MB, FP precision: 4 i- j- and k- weights: 1.0 2.0 12.0 4D TZYX chunk sizes : 1 8 74 180 3D TYX chunk sizes : 1 148 180 ----------------------------------------------------- Summary of changes ------------------ The contents of ``cfgs/X3_ORCA2_ICE_PISCES/EXPREF`` parallel those of the parent ``ORCA2_ICE_PISCES`` with local copies of any changed files. This includes some files that were originally symbolic links to files in the ``SHARED`` directory. Files which are symbolic links to files in the ``SHARED`` directory have @ appended to their name in the following table: =========================== ========== ==== ========================== =========== ==== ========== ORCA2_ICE_PISCES/EXPREF sum X3_ORCA2_ICE_PISCES/EXPREF sum changed? =========================== ========== ==== ========================== =========== ==== ========== axis_def_nemo.xml@ 53815 3 axis_def_nemo.xml 53184 3 yes context_nemo.xml 08199 2 context_nemo.xml 08199 2 no domain_def_nemo.xml@ 17199 13 domain_def_nemo.xml 46480 14 yes field_def_nemo-ice.xml@ 32328 64 field_def_nemo-ice.xml 31824 64 yes field_def_nemo-oce.xml@ 13274 140 field_def_nemo-oce.xml 10094 140 yes field_def_nemo-pisces.xml@ 18919 33 field_def_nemo-pisces.xml 62713 33 yes file_def_nemo-ice.xml 25184 9 file_def_nemo-ice.xml 28646 9 yes file_def_nemo-oce.xml 31630 11 file_def_nemo-oce.xml 45129 11 yes file_def_nemo-pisces.xml 53625 9 file_def_nemo-pisces.xml 16003 10 yes grid_def_nemo.xml@ 54429 11 grid_def_nemo.xml@ 54429 11 no iodef.xml 25161 2 iodef.xml 32297 3 yes namelist_cfg 06454 36 namelist_cfg 06454 36 no namelist_ice_cfg 00419 5 namelist_ice_cfg 00419 5 no namelist_ice_ref@ 49215 26 namelist_ice_ref@ 49215 26 no namelist_pisces_cfg 44377 6 namelist_pisces_cfg 44377 6 no namelist_pisces_ref@ 15677 30 namelist_pisces_ref@ 15677 30 no namelist_ref@ 14435 124 namelist_ref@ 14435 124 no namelist_top_cfg 40559 12 namelist_top_cfg 40559 12 no namelist_top_ref@ 20216 13 namelist_top_ref@ 20216 13 no =========================== ========== ==== ========================== =========== ==== ==========