-
Notifications
You must be signed in to change notification settings - Fork 374
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
add distinct passive tracer background vert diffusivity #6263
Conversation
|
@mark-petersen please review. |
@maltrud since Mark is out of the office, can someone else review this? |
if (trim(groupItr % memberName) /= 'activeTracers' .and. & | ||
config_cvmix_background_diffusion_passive_enable) then | ||
vertDiffPassiveTopOfCell = vertDiffTopOfCell - & | ||
config_cvmix_background_diffusion + config_cvmix_background_diffusion_passive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maltrud this probably doesn't impact the simulation but this does create a nonzero diffusivity at the surface and bottom of the ocean, which I don't think we want in the code. The change should only be from k=2:maxLevelCell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, this should be in explicit loops over cells as well as k=2:maxLevelCell
. Implicit indexing hides everything, and does not include the acc and openmp pragmas. The loop should look like, e.g., line 1553 in mpas_ocn_vmix.F
, with all the lengthy pragmas and ifdefs around it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vanroekel and @mark-petersen thanks for finding this. I'll clean it up--array syntax has become second nature to me so going back to loops often doesn't occur to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this look correct to you? it compiled ok and I'll make sure it runs.
#ifdef MPAS_OPENACC
!$acc parallel loop gang vector collapse(3) present(vertDiffPassiveTopOfCell, vertDiffTopOfCell)
#else
!$omp parallel
!$omp do schedule(runtime) private(k, iTracer)
#endif
do iCell = 1, nCellsOwned
do k = 2, maxLevelCell(iCell)
vertDiffPassiveTopOfCell(k,iCell) = vertDiffTopOfCell(k,iCell) - &
config_cvmix_background_diffusion + config_cvmix_background_diffusion_passive
end do
end do
#ifndef MPAS_OPENACC
!$omp end do
!$omp end parallel
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the $acc directive also have maxLevelCell?
also a general question: in the loop @mark-petersen references as an example (thanks for that!) the k loop is 1:nVertLevels, not 1:maxLevelCell(iCell). I realize this is a bit different (we don't want a k=1 value for diffusivity) but why not loop over 1:maxLevelCell?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maltrud you won't be able to collapse these loops with maxLevelCell as a loop limit. For maximum parallelism, you can either use fixed loop (2:nVertLevels) and add a conditional inside (if k < maxLevelCell) or use a mask. Otherwise, you can have just one level of parallelism over cells and leave the loop limit variable. And yes, you'll need maxLevelCell in the present() list. You also need to change collapse to either (2) in the first case or remove it if you only parallelize the cell loop. Finally, you should verify that the arrays in the present() list have all been copied to the device at some point (all mesh related variables like maxLevel are always on device and vertDiffTopOfCell I think has been copied earlier, but don't know if you added VertDiffPassive...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for your help, @philipwjones. I think I'll opt for limits of 2:nVertLevels and adding a conditional, though I assume that would affect vectorization. would using 'merge' help for vectorization? eg:
vertDiffPassiveTopOfCell(k,iCell) = merge( vertDiffTopOfCell(k,iCell) -....,0.0_RKIND,k<maxLevelCell(k,iCell))
how can I tell if something is present? I see $acc update host for vertDiffTopOfCell in ocn_vmix_coefs, then $acc update device after the coefficients are calculated. do I need to do something similar for vertDiffPassiveTopOfCell? I did put in $acc update host for vertDiffPassiveTopOfCell but I suspect that isn't correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maltrud it may affect CPU/vector performance but I suspect this loop has a fairly small cost anyway. The merge probably won't be any better - this is a simple enough loop the compiler should figure it out anyway and sometimes the intrinsic is actually worse. I didn't look closely at the data transfers when I wrote that last, but what you have looks correct - this is computed on the device so you just need to update the host which you've done. And you added it to the create/destroy calls in diagnostic_vars so should be fine.
!maltrud debug | ||
do k = 1, maxLevelCell(1) | ||
write(*,*)' DEBUG01: ',k,vertDiffPassiveTopOfCell(k,1) | ||
enddo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing you meant to remove these debug lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vanroekel , yeah, thanks for catching that. will remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a look since Mark is out of office. I think it looks good by visual inspection, just a couple of comments.
if (trim(groupItr % memberName) /= 'activeTracers' .and. & | ||
config_cvmix_background_diffusion_passive_enable) then | ||
vertDiffPassiveTopOfCell = vertDiffTopOfCell - & | ||
config_cvmix_background_diffusion + config_cvmix_background_diffusion_passive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For multiple passive tracers this line of code is redundant. It could be placed above the tracer loop, but it is way up there, so for a few wasted flops this more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mark-petersen yes I debated this one in my head a bit, and also decided clarity might might be worth some redundancy. I'll make a comment in the code but leave the logic as-is if that's OK with you.
@maltrud, apologies for the late review. Are there instances where you would like a different background diffusion for different tracer groups, rather than a single flag for all passive tracers? That seems useful to me. It wouldn't be too hard to make that alteration. You would change the flags
Then you would grab that flag just before using it:
I think that's it, except for adding to the bld namelist scripts. Let me know what you think of that idea. Otherwise, everything looks good. |
@mark-petersen I don't really foresee the need for each passive tracer group to have its own value of background diffusivity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maltrud, if you don't foresee the need for varying diffusivity on a per tracer basis, I'm happy with the changes you made here.
@vanroekel -- can you please check and make sure your concerns have been addressed? |
@jonbob it doesn't seem so. The responses to the comment look good, but they don't appear to be associated with actual code changes. Maybe I'm missing it? |
@vanroekel -- you're absolutely correct. We'll wait for Mat to fix this |
I just pushed the changes (explicit k-loop from 2:maxLevelCell(iCell)) to my branch. my test run with the changes was bit-for-bit with the case before I made the changes. |
…(PR #6263) Add distinct passive tracer background vert diffusivity Add capability to specify a different background vertical diffusivity for passive tracers than is used for active tracers. [NML] [BFB]
passes:
wth expected NML DIFFs. Merged to next |
merged to master and bless requests submitted for all expected NML DIFFs |
This merge updates the E3SM-Project submodule from [31e0924](https://github.com/E3SM-Project/E3SM/tree/31e0924) to [8939709](https://github.com/E3SM-Project/E3SM/tree/8939709). This update includes the following MPAS-Ocean and MPAS-Frameworks PRs (check mark indicates bit-for-bit with previous PR in the list): - [ ] (ocn) E3SM-Project/E3SM#6263 - [ ] (ocn) E3SM-Project/E3SM#6310 - [ ] (fwk) E3SM-Project/E3SM#6427 - [ ] (ocn) E3SM-Project/E3SM#6397 - [ ] (ocn) E3SM-Project/E3SM#6306 - [ ] (ocn) E3SM-Project/E3SM#6454
Add capability to specify a different background vertical diffusivity for passive tracers than is used for active tracers. Design document is attached. Testing described in the design document with EC30to60E2r2 grid G-case was successful.
designDocumentPassiveTracerDiffusivity.pdf
[NML]
[BFB]