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

(Towards #1960) put WHEREs containing reductions into CodeBlocks and fix non-unity lower-bound bug. #2372

Merged
merged 34 commits into from
Feb 5, 2024

Conversation

arporter
Copy link
Member

No description provided.

@arporter arporter self-assigned this Oct 19, 2023
@arporter arporter marked this pull request as draft October 19, 2023 16:01
@arporter arporter added in progress NEMO Issue relates to the NEMO domain labels Oct 19, 2023
@codecov
Copy link

codecov bot commented Oct 19, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (699ceb2) 99.85% compared to head (c360dcd) 99.85%.

❗ Current head c360dcd differs from pull request most recent head b1d501b. Consider uploading reports for the commit b1d501b to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2372   +/-   ##
=======================================
  Coverage   99.85%   99.85%           
=======================================
  Files         352      352           
  Lines       47334    47399   +65     
=======================================
+ Hits        47264    47330   +66     
+ Misses         70       69    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@arporter
Copy link
Member Author

I've asked Simon if he'd mind testing this branch with the files on master of NEMO that have been giving him trouble.

@arporter
Copy link
Member Author

There's a separate bug that causes us to generate incorrect loop bounds if the array being iterated over has a non-default lower bound. We currently always generate, e.g.:

      do widx2 = 1, SIZE(sjk, 2), 1
        do widx1 = 1, SIZE(sjk, 1), 1
          if (sjk(widx1,widx2,jn) /= 0._wp) then
            r1_sjk(widx1,widx2,jn) = 1._wp / sjk(widx1,widx2,jn)
          end if
        enddo
      enddo

while we should generate e.g. do widx2 = LBOUND(sjk,2), UBOUND(sjk,2), 1

@arporter
Copy link
Member Author

arporter commented Jan 18, 2024

Just checked with SPITZ12 (as that includes ice) and, with master, we get a compilation failure:

 nemo/cfgs/SPITZ_TEST/BLD_SCT_PSYCLONE/obj/iceistate.f90
NVFORTRAN-S-0074-Illegal number or type of arguments to sum - keyword argument array (/home/aporter/NEMO/nemo/cfgs/SPITZ_TEST/BLD_SCT_PSYCLONE/obj/iceistate.f90: 297)

0 inform, 0 warnings, 1 severes, 0 fatal for ice_istate

This PR fixes that one at least :-)

@arporter
Copy link
Member Author

I've realised that even moving to LBOUND/UBOUND isn't guaranteed to work because the mask expression only has to have the same shape as any arrays assigned to within a where-assignment-stmt:
image
and shape is defined as:
image
i.e. the shape does not include the lower bounds of the rank(s) of an array.

@arporter
Copy link
Member Author

Therefore, the generated loops should be over the shape of the mask expression. Whenever we index into an array (in a where-assignment-statement), that indexing should take into account the lower bound of the array.

@arporter
Copy link
Member Author

Tests are now happy (incl. with compilation). Need to test NEMO passthrough now.

@arporter
Copy link
Member Author

NEMO integration tests are green and performance is good :-)

@arporter
Copy link
Member Author

I can build GYRE_PISCES and SPITZ12 on NEMO main with the excludes that mention 'where' commented out of mk/sct_psyclone.sh. The GYRE_PISCES case also runs fine (single MPI process). I don't have input files for SPITZ12 for this version of NEMO.

@arporter
Copy link
Member Author

arporter commented Feb 1, 2024

I just need to check again with HEAD of nemo now...

@arporter
Copy link
Member Author

arporter commented Feb 1, 2024

GYRE builds and runs and SPITZ12 builds :-) Need to look at coverage now.

@arporter
Copy link
Member Author

arporter commented Feb 1, 2024

CI is happy now. Ready for another look from @sergisiso.

@arporter arporter changed the title (Towards #1960) put WHEREs containing reductions into CodeBlocks (Towards #1960) put WHEREs containing reductions into CodeBlocks and fix non-unity lower-bound bug. Feb 1, 2024
Copy link
Collaborator

@sergisiso sergisiso left a comment

Choose a reason for hiding this comment

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

@arporter The WHERE implementation looks good now, the integration test pass and also the formatting checks. I made some final minor comments. The only bigger comment is on the array_mixin get_effective_shape, but this is getting a bit out of scope so I would be happy to moving them to another issues if they are not simple to solve.

src/psyclone/psyir/nodes/array_mixin.py Outdated Show resolved Hide resolved
src/psyclone/psyir/nodes/array_reference.py Show resolved Hide resolved
src/psyclone/psyir/nodes/array_mixin.py Outdated Show resolved Hide resolved
@arporter
Copy link
Member Author

arporter commented Feb 2, 2024

SPITZ12 still builds OK, as does ORCA2_ICE_PISCES (in passthrough mode). Integration tests are running. Ready for another look now.

Copy link
Collaborator

@sergisiso sergisiso left a comment

Choose a reason for hiding this comment

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

Thanks @arporter for addressing all comments and refactoring the ArrayMixin utilities. This is a good improvement. The formatting checks pass, the integration test pass with expected results and the remaining where issues are properly marked with TODOs, so this is ready to merge.

@sergisiso sergisiso merged commit b393e04 into master Feb 5, 2024
9 checks passed
@sergisiso sergisiso deleted the 1960_where_oh_where branch February 5, 2024 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NEMO Issue relates to the NEMO domain ready to be merged Release Planning and creating PSyclone releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants