Skip to content

Fix OMP Directives and Loop Bounds in Ocean - #698

Merged
mark-petersen merged 3 commits into
MPAS-Dev:ocean/developfrom
mattdturner:ocean/lisio_test_bugfix
Sep 22, 2020
Merged

mark-petersen merged 3 commits into
MPAS-Dev:ocean/developfrom
mattdturner:ocean/lisio_test_bugfix

Conversation

@mattdturner

Copy link
Copy Markdown
Collaborator

This PR is a bugfix that corrects errors in a few OpenMP private clauses, and fixes loop bounds in an ALE thickness routine.

For additional details of the errors that this PR resolves, see E3SM-Project/E3SM#3826

This also potentially fixes #685 , but I will need to test to confirm.

Update mixed_layer_depth file to include changes necessary
for the localized OpenMP threading (PR MPAS-Dev#513).  Also remove
interp_local from private clause.
The ALE thickness routine looped over nCellsAll, instead of looping
over a subset of the cells.  This caused the code to do calculations
w/ unititialized values.  This commit corrects the loop bounds.
@mattdturner

Copy link
Copy Markdown
Collaborator Author

This branch PASSes the nightly regression suite, as well as the following E3SM tests:

SMS.T62_oQU120_ais20.MPAS_LISIO_TEST.cori-knl_intel
SMS.T62_oQU120_ais20.MPAS_LISIO_TEST.cori-knl_gnu
SMS_D.T62_oQU120_ais20.MPAS_LISIO_TEST.cori-knl_intel
SMS_D.T62_oQU120_ais20.MPAS_LISIO_TEST.cori-knl_gnu

Prior to this PR, the SMS_D tests listed above all failed.

This is non-bfb in the analysis_test when comparing to a baseline. This is because the baseline data that is generated is incorrect due to the baseline being generated with a variable in a private clause that should not be private (interp_local). Even when running single-threaded (as the baseline is), if the executable is compiled w/ OpenMP then the private clause still applies. This resulted in interp_local being uninitialized in the loop, resulting in all interpolation coefficients having a value of 0.0. This also means that comparing a single-threaded run that is compiled with OpenMP against one without OpenMP should also be non-bfb.

@philipwjones Continuing on our previous discussion, Valgrind likely would have pointed out these issues even though all of our tests were PASSing.

@mattdturner

Copy link
Copy Markdown
Collaborator Author

This PR does indeed appear to fix #685 when running on Badger (I first confirmed that the code fails in the EC60to30 prep_spin_up1 test without these changes).

@mark-petersen mark-petersen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattdturner, this is perfect. I was able to test the PR in the way that we discussed. These are all nightly regression suites with gnu 6 on badger:

  1. current ocean/develop, OPENMP=false versus multi-threaded: Global ocean cases FAIL to match
  2. This PR, OPENMP=false versus multithreaded: PASS match bfb
  3. This PR OPENMP=false versus ocean/develop OPENMP=false: PASS match bfb

This is excellent! Thanks for testing the EC60to30 spinup as well.

@mark-petersen

Copy link
Copy Markdown
Contributor

Also just did this same comparison but with Intel19:

  1. current ocean/develop, OPENMP=false versus multi-threaded: PASS match bfb
  2. This PR versus ocean/develop, both OPENMP=false: PASS match bfb

That is good to check, but it wasn't a problem to begin with.

@mark-petersen mark-petersen self-assigned this Sep 22, 2020
@mark-petersen
mark-petersen merged commit 9a56f22 into MPAS-Dev:ocean/develop Sep 22, 2020
mark-petersen added a commit that referenced this pull request Sep 22, 2020
Fix OMP Directives and Loop Bounds in Ocean #698
jonbob added a commit to E3SM-Project/E3SM that referenced this pull request Sep 22, 2020
Update mpas-source: Fix OMP Directives and Loop Bounds in Ocean

This PR is a bugfix that corrects errors in a few OpenMP private
clauses, and fixes loop bounds in an ALE thickness routine.

For additional details of the errors that this PR resolves, see #3826
and testing at MPAS-Dev/MPAS-Model#698.

This PR may be non-BFB with threading on some compilers.

Fixes #3826

[non-BFB]
jonbob added a commit to E3SM-Project/E3SM that referenced this pull request Sep 23, 2020
Update mpas-source: Fix OMP Directives and Loop Bounds in Ocean

This PR is a bugfix that corrects errors in a few OpenMP private
clauses, and fixes loop bounds in an ALE thickness routine.

For additional details of the errors that this PR resolves, see #3826
and testing at MPAS-Dev/MPAS-Model#698.

This PR may be non-BFB with threading on some compilers.

Fixes #3826

[non-BFB]
@mark-petersen

Copy link
Copy Markdown
Contributor

@ambrad, @ndkeen, @rljacob, @vanroekel, @golaz
Just a note, per the discussion at yesterday's water cycle meeting. The comment just above, we had a non-bfb match between compiling without openmp, and compiling with openmp. In this case, the compiling without was correct, and the compiling with had some arrays that were being filled incorrectly, but just for certain compilers (gnu). We now test MPAS-Ocean regularly between with/without openmp compile flags.

@ambrad if your E3SM tests were run from master after E3SM-Project/E3SM#3844 was merged (Sept 23) then this is not the specific source of your bfb mismatch. Still, I think the current mismatch indicates that there is a bug, and the no-threading is much more likely to be correct. Until the mismatch is found, I would recommend compiling with OpenMP off.

@ambrad

ambrad commented Oct 8, 2020

Copy link
Copy Markdown

Thanks @mark-petersen; this is good information. The branch @ndkeen ran for his PE layouts analysis does not include PR 3844. For clarity, the branch we are advertising to others (E3SM-Project/E3SM#3879) does, because it's even with master as of Tues 6 Oct night. Thus, the 4 out of 24 threaded runs that diff may be explained by not having PR 3844 included in the build.

@mattdturner
mattdturner deleted the ocean/lisio_test_bugfix branch March 16, 2021 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants