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

range_check_3d optimization #649

Merged
merged 7 commits into from
Jun 6, 2023
Merged

Conversation

dkokron
Copy link
Contributor

@dkokron dkokron commented Apr 24, 2023

Description

Performance profiling of a HAFS case on NOAA systems revealed significant of time was spent in subroutine range_check_3d(). This commit effectively reverts a commit from Oct 2021 (see below). This commit also changes the code to use the minval() and maxval() fortran intrinsics.

commit 2c8363e
Author: Xiaqiong Zhou Xiaqiong.Zhou@noaa.gov
Date: Thu Oct 21 17:51:10 2021 +0000
Revise back the range definition form. The compiling issue on DELL can be fixed by using -O0 instead of -O2 to compile fv_diagnostics.F90

I requested more details from Xiaqiong Zhou and got the following responses.

It is a very strange error when compiling fv_diagostics.F90 on DELL (OK on HERA, Orion et al).
vsrange = (/ -200., 200. /) was not accepted but it is OK to use
vsrange(1) = -200. ; vsrange(2) = 200.
In order to keep the original form as vsrange = (/ -200., 200. /), -O0 instead of -O2 to compile fv_diagnostics.F90 in dynamics.

DELL was retired. It should be an Intel compiler but I do not remember the version.

I don't see any compile time issues using ifort-19.1.3.304 at -O2 on the WCOSS2 systems.

How Has This Been Tested?
The modifications have been tested on WCOSS2 systems Acorn and Dogwood using a HAFS case as well as on Cactus and Dogwood by running the UFS (develop branch cloned on 17 April) regression suite.

Scenarios:

  1. Unmodified code and compiler flags (Baseline)
  2. Delete the line in FV3/atmos_cubed_sphere/CMakeLists.txt that adds "-O0" to the compile flags. Thus, this file gets compiled with the global defaults
  3. Replace the nested loop calculation in range_check_3d() (not in range_check_2d) with calls to the minval() and maxval() intrinsic functions.
  4. Same as scenario three with the addition of minval and maxval intrinsics in range_check_2d.

HAFS case regional simulation with one nest
The case was run on 26 nodes of the Acorn system for a 126 hour simulation.

Parent grid:
  layout = 24,20
  npx = 1321
  npy = 1201
  ntiles = 1
  npz = 81

Nest grid:
  layout = 20,12
  npx = 601
  npy = 601
  ntiles = 1
  npz = 81

The 26 nodes are allocated as follows.
ATM_petlist_bounds: 000 735
OCN_petlist_bounds: 736 855
MED_petlist_bounds: 736 855

Performance metric:
Add up the phase1 and phase2 timings printed in the output listing
grep PASS stdout | awk '{t+=$10;print t}' | tail -1
The units are seconds.

Scenario Trial1 Trial2
1 7881 7866.69
2 7206.2 7200.81
3 7179.37 Not run
4 7180.67 7163.4

Validation:
Using scenario four, the UFS regression suite revealed numerous diagnostic variables changed numerically. A review of all files declared as "NOT OK" by the pass/fail comparison revealed that all of those variables are calculated using routines found in fv_diagnostics.F90 (see attached file variables.txt)
variables.txt

Some of these variables show up in files that are part of the UFS regression suite pass/fail comparisons so a new baseline will be needed.

Comparison between stdout from scenario1 and scenario4 revealed certain variables related to tropical cyclone (TC) tracking changed at the 7th significant digit. A code review revealed that those variables are also calculated using routines from fv_diagnostics.F90

E.g. from time step 6299
u700 g2 max = 14.35157 min = -9.423827 | u700 g2 max = 14.35157 min = -9.423828
u850 g2 max = 7.198199 min = -18.35876 | u850 g2 max = 7.198200 min = -18.35876
v700 g2 max = 8.673572 min = -15.10008 | v700 g2 max = 8.673571 min = -15.10008

Comparing output from the TC tracker printed to stdout revealed no differences between scenario1 and scenario4.

E.g. the last output from a 126 hour simulation.
==> Baseline_5Day_736p/tracker.txt <==
tracker fixlon= 350.647 fixlat= 30.150 ifix= 302 jfix= 302 pmin= 100795.047 vmax= 16.500 rmw= 119.294

==> RANGECHECKnD-GlobalminvalmaxvalOnly_736p/tracker.txt <==
tracker fixlon= 350.647 fixlat= 30.150 ifix= 302 jfix= 302 pmin= 100795.047 vmax= 16.500 rmw= 119.294

Issue(s) addressed

This PR does not fix any open issues

Testing

How were these changes tested? HAFS case and UFS regression suite
What compilers / HPCs was it tested with? ifort-19.1.3.304
Are the changes covered by regression tests? (If not, why? Do new tests need to be added?) No tests need to be added
Have the ufs-weather-model regression test been run? On what platform? Yes. Dogwood and Cactus.

  • Will the code updates change regression test baseline? If yes, why? Please show the baseline directory below.
  • Please commit the regression test log files in your ufs-weather-model branch Done. tests/RegressionTests_wcoss2.intel.log
    The baseline directory for these test was dogwood:/lfs/h2/emc/nems/noscrub/emc.nems/RT/NEMSfv3gfs/develop-20230418/INTEL

Dependencies

If testing this branch requires non-default branches in other repositories, list them.
Those branches should have matching names (ideally)

Do PRs in upstream repositories need to be merged first? No
If so add the "waiting for other repos" label and list the upstream PRs

@dkokron
Copy link
Contributor Author

dkokron commented May 4, 2023

The upstream PR (NOAA-GFDL/GFDL_atmos_cubed_sphere#267) has been approved. Please proceed with review.

@dkokron
Copy link
Contributor Author

dkokron commented May 9, 2023

Is there anything I need to do to move this PR along?

@FernandoAndrade-NOAA
Copy link

Testing on PR #1743 has finished successfully, this PR is ready

@FernandoAndrade-NOAA
Copy link

Testing on PR #1743 has finished successfully, this PR is ready

After sub PR #267 is merged in, to clarify.

@jkbk2004
Copy link
Collaborator

jkbk2004 commented Jun 6, 2023

@dkokron cubed sphere pr was merged. can you update hash and revert change in gitmodules? correct hash is NOAA-GFDL/GFDL_atmos_cubed_sphere@49f15ec

@dkokron
Copy link
Contributor Author

dkokron commented Jun 6, 2023 via email

@zach1221
Copy link
Collaborator

zach1221 commented Jun 6, 2023

@dkokron You have to use git submodule sync to point to cubed sphere dev/emc URL and git checkout correct hash and commit. So, first revert the gitmodules to the original, then git submodule sync, then checkout correct hash and commit.

@dkokron
Copy link
Contributor Author

dkokron commented Jun 6, 2023 via email

@zach1221
Copy link
Collaborator

zach1221 commented Jun 6, 2023

Hi, @dkokron. Here's a screen shot of a previously reverted .gitmodules and update to atmos_cubed_sphere url in a fv3atm PR. As an example.
image

To update a hash in the .gitmodules file, you would open it with the text editor of your choice, then make the necessary change. Once the change is made, I think you would run git submodule update to bring in the new hash. To revert a change to the .gitmodules file, you would either use git checkout -- .gitmodules or git restore .gitmodules, depending on the machine you are on.

@dkokron
Copy link
Contributor Author

dkokron commented Jun 6, 2023 via email

@zach1221
Copy link
Collaborator

zach1221 commented Jun 6, 2023

I think we've reverted the changes in gitmodules and updated the hash correctly to NOAA-GFDL/GFDL_atmos_cubed_sphere@49f15ec (Thanks for the help @DeniseWorthen)

@DusanJovic-NOAA and @junwang-noaa could you confirm these updates look correct?

@BrianCurtis-NOAA
Copy link
Collaborator

It looks OK to me. Hash is updated and .gitmodules was reverted.

@DusanJovic-NOAA
Copy link
Collaborator

I think we've reverted the changes in gitmodules and updated the hash correctly to NOAA-GFDL/GFDL_atmos_cubed_sphere@49f15ec (Thanks for the help @DeniseWorthen)

@DusanJovic-NOAA and @junwang-noaa could you confirm these updates look correct?

Yes, ready for merge.

@zach1221
Copy link
Collaborator

zach1221 commented Jun 6, 2023

Thanks! @jkbk2004 I'm not authorized to merge fv3atm. Are you able/available to merge?

@jkbk2004 jkbk2004 merged commit 86ba901 into NOAA-EMC:develop Jun 6, 2023
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.

8 participants