change mixed-precision kernels to use iso-ieee kinds - #393
Conversation
Thomas Bendall (tommbendall)
left a comment
There was a problem hiding this comment.
This seems like a sensible change, thanks for making it.
My only comment is that just replacing r_single with real32 and similar for r_double means that there are now quite a few code sections which aren't aligned. Sorry to be tedious, but could you go through your changed kernels and realign any changed sections? I have posted a couple of examples so you see what I mean.
| ! REAL64 PRECISION | ||
| ! ================== | ||
| subroutine dg_inc_matrix_vector_code_r_double(cell, & | ||
| subroutine dg_inc_matrix_vector_code_real64(cell, & |
There was a problem hiding this comment.
| subroutine dg_inc_matrix_vector_code_real64(cell, & | |
| subroutine dg_inc_matrix_vector_code_real64( cell, & |
| ! REAL32 PRECISION | ||
| ! ================== | ||
| subroutine dg_inc_matrix_vector_code_r_single(cell, & | ||
| subroutine dg_inc_matrix_vector_code_real32(cell, & |
There was a problem hiding this comment.
| subroutine dg_inc_matrix_vector_code_real32(cell, & | |
| subroutine dg_inc_matrix_vector_code_real32( cell, & |
| ! REAL64 PRECISION | ||
| ! ================== | ||
| subroutine restrict_scalar_unweighted_code_r_double( & | ||
| subroutine restrict_scalar_unweighted_code_real64( & |
There was a problem hiding this comment.
| subroutine restrict_scalar_unweighted_code_real64( & | |
| subroutine restrict_scalar_unweighted_code_real64( & |
| real(kind=real64), intent(inout) :: coarse_field(undf_coarse) | ||
| real(kind=real64), intent(in) :: fine_field(undf_fine) |
There was a problem hiding this comment.
| real(kind=real64), intent(inout) :: coarse_field(undf_coarse) | |
| real(kind=real64), intent(in) :: fine_field(undf_fine) | |
| real(kind=real64), intent(inout) :: coarse_field(undf_coarse) | |
| real(kind=real64), intent(in) :: fine_field(undf_fine) |
|
|
||
| integer(kind=i_def) :: df, k, x_idx, y_idx, top_df | ||
| real(kind=r_double) :: denom, coarse_value(nlayers-1+ndf) | ||
| real(kind=real64) :: denom, coarse_value(nlayers-1+ndf) |
There was a problem hiding this comment.
| real(kind=real64) :: denom, coarse_value(nlayers-1+ndf) | |
| real(kind=real64) :: denom, coarse_value(nlayers-1+ndf) |
Thanks for this Tom, I hadn't noticed that these changes had knocked everything out of alignment. Have gone through it carefully and I think I've fixed everything. Let me know if I missed anything though, cheers. |
Thomas Bendall (tommbendall)
left a comment
There was a problem hiding this comment.
Great, thanks for neatening that up!
Benjamin Went (MetBenjaminWent)
left a comment
There was a problem hiding this comment.
Changes look good! I've checked this out locally and confirmed that all of these are removed from the kernels as advised in the PR summary.
I have however also noticed a few small formatting changes which could be updated?
Also whats the plan for lfric apps? I appreciate it's out of scope for this ticket, just some context present, like a linked issue apps side could be good here?
Besides these small changes, it's otherwise approved! Thanks
Co-authored-by: Benjamin Went <136574563+MetBenjaminWent@users.noreply.github.com>
Benjamin Went (@MetBenjaminWent) Thanks Ben! I've made those changes now. With regards to lfric apps, there is no plan to extend this to apps yet I don't think. |
Benjamin Went (MetBenjaminWent)
left a comment
There was a problem hiding this comment.
Thanks Matthew! Changes look good, SR approved.
Ed Hone (EdHone)
left a comment
There was a problem hiding this comment.
All changes look fine - the only request I would have would be for all the new use statements for iso_fortran_env be moved to the top in their own block, so they aren't confused with lfric modules: i.e., the first instance would become:
module dg_inc_matrix_vector_kernel_mod
use, intrinsic :: iso_fortran_env, only: real32, real64
use argument_mod, only : arg_type, &
GH_FIELD, GH_OPERATOR, &
GH_REAL, GH_READ, &
GH_READWRITE, ANY_SPACE_1, &
ANY_DISCONTINUOUS_SPACE_1, &
CELL_COLUMN
use constants_mod, only : i_def
use kernel_mod, only : kernel_type
Thanks for the suggestion Ed Hone (@EdHone), I've made these changes and pushed them. |
Ed Hone (EdHone)
left a comment
There was a problem hiding this comment.
There are still some style/lint errors to fix here:
Oops, sorry about that. Fixed. |
|
There were a few final whitespace issues to fix but I sorted them out |
|
Thanks very much Ed! |
PR Summary
Sci/Tech Reviewer: Benjamin Went (@MetBenjaminWent)
Code Reviewer: Ed Hone (@EdHone)
This PR is a replica of the Trac ticket #4463:
Some of the mixed precision kernels are using LFRic defined kinds of
r_singleandr_double. These are just labels inconstants_mod.F90and resolve toreal32andreal64respectively. However, the other mixed precision code is using the iso-ieee kinds. Moreover, we want to be explicit and unambiguous for compiler performance, especially for performance on GPUs where we may also want further reduced kinds. This ticket will re-write the kernels in the native kinds of real32 and real64.Code Quality Checklist
Testing
trac.log
Test Suite Results - lfric_core - mixed-precision2-core/run1
Suite Information
Task Information
✅ succeeded tasks - 422
Security Considerations
Performance Impact
AI Assistance and Attribution
Documentation
PSyclone Approval
Sci/Tech Review
(Please alert the code reviewer via a tag when you have approved the SR)
Code Review