Skip to content

Add clear-sky fast paths and inline column KISS PRNG draws in RRTMG-SW - #2476

Open
g8j39 wants to merge 2 commits into
wrf-model:developfrom
g8j39:perf/rrtmg-sw-clearsky-skips
Open

g8j39 wants to merge 2 commits into
wrf-model:developfrom
g8j39:perf/rrtmg-sw-clearsky-skips

Conversation

@g8j39

@g8j39 g8j39 commented Nov 17, 2026

Copy link
Copy Markdown

Add clear-sky fast paths and inline column KISS PRNG draws in RRTMG-SW.

TYPE: enhancement

KEYWORDS: radiation, RRTMG-SW, shortwave, McICA, clear-sky, two-stream

SOURCE: Yoel Sevi (Google)

DESCRIPTION OF CHANGES:
Problem:
In RRTMG shortwave radiation (phys/module_ra_rrtmg_sw.F):

  • generate_stochastic_clouds_sw runs McICA sub-column generation on clear
    columns and layers, calls kissvec per g-point, and allocates 3D
    spread/isCloudy temporaries on cloudy columns.
  • cldprmc_sw sweeps cloud-free layers across all 112 g-points.
  • spcvmc_sw runs the second cloudy reftra_sw and vrtqdr_sw two-stream pass even
    on clear g-points (pcldfmc(1:klev,iw) == 0).

Solution:

  • Return early on clear columns and skip clear layers in
    generate_stochastic_clouds_sw when irng == 0.
  • Compute irng == 0 KISS PRNG draws per column in register via module-private
    kiss_cdf_col (leaving upstream kissvec unmodified) and replace 3D
    spread/isCloudy temporaries with scalar comparisons.
  • Skip cloud-free layers in cldprmc_sw.
  • Guard the cloudy two-stream pass in spcvmc_sw with
    lhas_cld = any(pcldfmc(1:klev,iw) > 0.0_rb) without re-indenting the existing
    cloudy block. All public shared_physics interfaces remain unchanged.

License: Notwithstanding anything else to the contrary set out in https://github.com/wrf-model/WRF, the material here is being released under the Apache 2.0 licence at https://www.apache.org/licenses/LICENSE-2.0 (see doc/licenses/google_license.txt).

LIST OF MODIFIED FILES:
A doc/licenses/google_license.txt
M phys/module_ra_rrtmg_sw.F

TESTS CONDUCTED:

  1. On gfortran 15.2.0 (x86-64 Linux), verified 0 _gfortran_spread calls and
    clean -DWRF_CHEM=1 (r4 and -r8) builds, and passed r4 and -r8 standalone
    tests under -fcheck=all and sNaN FPE traps across clear, fractional,
    overcast, overlap (icld = 0..5), irng = 0/1, and aer_opt = 0/2 profiles with
    max_abs_diff = 0.0. Earlier 16-rank x86-64 isolated runs measured ~14.6%
    less standalone rrtmg_sw kernel time and ~5.1% solo solver time saved on a
    smaller regional CONUS proxy domain.
    Built and verified as part of the full optimization series on x86-64 Linux
    (gfortran 15.2.0, MPICH, 4-core VMs, 5 interleaved repeats across 5 em_real
    workflows) across Make (serial, dmpar r4 and -r8, dm+sm), CMake (dmpar),
    and -DWRF_CHEM=1 with 0 new compiler warnings and bit-for-bit identical
    wrf.exe outputs (diffwrf = 0 with gfortran on x86-64 without fused
    multiply-add).
  2. Pending upstream Jenkins CI (including Intel and non-x86 compilers).

RELEASE NOTE: Add exact clear-sky fast paths and eliminate per-g-point kissvec/spread overhead in RRTMG-SW (phys/module_ra_rrtmg_sw.F).

Part of the modular CPU performance series; combined multi-workflow benchmarks, hardware/compiler setup, and per-PR summary table are in the Series Overview comment on PR 01 (#2470).

Prepared with AI assistance (Google Gemini).

TYPE: text only

KEYWORDS: license, Apache-2.0, contributor license, doc/licenses

SOURCE: Yoel Sevi (Google)

DESCRIPTION OF CHANGES:
Problem:
Following the contributor-license mechanism established in PR wrf-model#2242
(doc/licenses/fraunhofer_license.txt), Google-authored code blocks in
subsequent performance pull requests need a standalone permissive license file
under doc/licenses/ while leaving WRF's root LICENSE.txt unmodified.

Solution:
Add doc/licenses/google_license.txt containing the Apache License, Version 2.0
(Copyright 2026 Google LLC), referenced by
`! THE FOLLOWING LINES OF CODE ARE LICENSED UNDER doc/licenses/google_license.txt`
and `! END LICENSE` comment markers around Google-authored code blocks. If
maintainers prefer lower inline marker density on PRs with interleaved edits,
I am happy to explore a lighter per-routine notice option.

License: Notwithstanding anything else to the contrary set out in https://github.com/wrf-model/WRF, the material here is being released under the Apache 2.0 licence at https://www.apache.org/licenses/LICENSE-2.0 (see doc/licenses/google_license.txt).

ISSUE:
None

LIST OF MODIFIED FILES:
A       doc/licenses/google_license.txt

TESTS CONDUCTED:
1. Documentation-only addition under doc/licenses/; zero source, build, or
   runtime changes.
2. Pending upstream Jenkins CI.

RELEASE NOTE: Add doc/licenses/google_license.txt (Apache-2.0) for Google-contributed performance patches.
TYPE: enhancement

KEYWORDS: radiation, RRTMG-SW, shortwave, McICA, clear-sky, two-stream

SOURCE: Yoel Sevi (Google)

DESCRIPTION OF CHANGES:
Problem:
In RRTMG shortwave radiation (phys/module_ra_rrtmg_sw.F):
- generate_stochastic_clouds_sw runs McICA sub-column generation on clear
  columns and layers, calls kissvec per g-point, and allocates 3D
  spread/isCloudy temporaries on cloudy columns.
- cldprmc_sw sweeps cloud-free layers across all 112 g-points.
- spcvmc_sw runs the second cloudy reftra_sw and vrtqdr_sw two-stream pass even
  on clear g-points (pcldfmc(1:klev,iw) == 0).

Solution:
- Return early on clear columns and skip clear layers in
  generate_stochastic_clouds_sw when irng == 0.
- Compute irng == 0 KISS PRNG draws per column in register via module-private
  kiss_cdf_col (leaving upstream kissvec unmodified) and replace 3D
  spread/isCloudy temporaries with scalar comparisons.
- Skip cloud-free layers in cldprmc_sw.
- Guard the cloudy two-stream pass in spcvmc_sw with
  lhas_cld = any(pcldfmc(1:klev,iw) > 0.0_rb) without re-indenting the existing
  cloudy block. All public shared_physics interfaces remain unchanged.

License: Notwithstanding anything else to the contrary set out in https://github.com/wrf-model/WRF, the material here is being released under the Apache 2.0 licence at https://www.apache.org/licenses/LICENSE-2.0 (see doc/licenses/google_license.txt).

ISSUE:
None

LIST OF MODIFIED FILES:
M       phys/module_ra_rrtmg_sw.F

TESTS CONDUCTED:
1. On gfortran 15.2.0 (x86-64 Linux), verified 0 _gfortran_spread calls and
   clean -DWRF_CHEM=1 (r4 and -r8) builds, and passed r4 and -r8 standalone
   tests under -fcheck=all and sNaN FPE traps across clear, fractional,
   overcast, overlap (icld = 0..5), irng = 0/1, and aer_opt = 0/2 profiles with
   max_abs_diff = 0.0. Earlier 16-rank x86-64 isolated runs measured ~14.6%
   less standalone rrtmg_sw kernel time and ~5.1% solo solver time saved on a
   smaller regional CONUS proxy domain.
   Built and verified as part of the full optimization series on x86-64 Linux
   (gfortran 15.2.0, MPICH, 4-core VMs, 5 interleaved repeats across 5 em_real
   workflows) across Make (serial, dmpar r4 and -r8, dm+sm), CMake (dmpar),
   and -DWRF_CHEM=1 with 0 new compiler warnings and bit-for-bit identical
   wrf.exe outputs (diffwrf = 0 with gfortran on x86-64 without fused
   multiply-add).
2. Pending upstream Jenkins CI (including Intel and non-x86 compilers).

RELEASE NOTE: Add exact clear-sky fast paths and eliminate per-g-point kissvec/spread overhead in RRTMG-SW (phys/module_ra_rrtmg_sw.F).
@weiwangncar

Copy link
Copy Markdown
Collaborator

The regression test results:

Test Type              | Expected  | Received |  Failed
= = = = = = = = = = = = = = = = = = = = = = = =  = = = =
Number of Tests        : 23           24
Number of Builds       : 60           57
Number of Simulations  : 158           150        0
Number of Comparisons  : 95           86        0

Failed Simulations are: 
None
Which comparisons are not bit-for-bit: 
None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants