You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Later within the kernel arguments, the basis is accepted with the shape: basis_B_on_A(3, ndf_B, ndf_A) - {B on A}
Which looks as expected.
Now, in the adjoint code, the kernel metadata becomes:
type(arg_type) :: meta_args(4) = (/
arg_type(GH_FIELD*3, GH_REAL, GH_READ, ANY_SPACE_1), & ! intent(in) A
arg_type(GH_FIELD, GH_REAL, GH_INC, ANY_SPACE_2), & ! intent(inout) B
! ... (NOTE: No change elsewherein metadata)
Field A becomes in, B becomes inout. In the kernel (generated with PSyAD), the shape arguments are the same as before. This is correct because we are expecting the same basis as the forward code.
The problem
Since B has become inout, PSyclone erroneously generates code which passes the basis function: {B on B} rather than the required {B on A}, to the kernel.
The problem results in an incorrect adjoint. This requires manual intervention using PSy-lite code.
Summary
PSyclone has implicitly chosen B as the other part of the basis due to B being the inout GH_INC field in adjoint code, when in reality the basis should choose A in the adjoint case. This requires manual intervention using PSy-lite code.
This may be related to #2335, since I believe a similar version to that kernel produced both of these errors.
DrTVockerodtMO
changed the title
[LFRic] Mismatch between GH_BASIS kernel dummy arguments in the adjoint, and actual arguments provided in the PSy layer.
[LFRic] [PSyAD] Mismatch between GH_BASIS kernel dummy arguments in the adjoint, and actual arguments provided in the PSy layer.
Nov 22, 2024
Thanks @mo-joshuacolclough. This means that the adjoint kernel is no longer following the rules of the LFRic API (see https://psyclone.readthedocs.io/en/latest/dynamo0p3.html#lfric-gh-shape). If the function space on which the basis functions are to be provided is not that of the updated kernel argument, there will have to be some other mechanism to tell PSyclone that. This probably means an extension to the metadata. Probably, the best thing to do will be to follow what's supported for GH_SHAPE = GH_EVALUATOR (where we have an optional GH_EVALUATOR_TARGETS. Whatever we decide, ideally it must be backwards compatible with existing metadata. We could introduce an optional GH_BASIS_TARGETS for instance. This would need clarification with @tommbendall and @TeranIvy.
Sorry for the slow reply. I think I've followed the problem. I haven't understood whether this can be resolved with the existing GH_EVALUATOR_TARGETS metadata or if it needs something new?
Description
During the LFRic adjoint work, an issue was noted when
GH_BASIS
arguments are added for intended use withintent(in)
fields.The kernel metadata for the problematic case in the linear code was:
Later within the kernel arguments, the basis is accepted with the shape:
basis_B_on_A(3, ndf_B, ndf_A)
- {B on A}Which looks as expected.
Now, in the adjoint code, the kernel metadata becomes:
Field A becomes
in
, B becomesinout
. In the kernel (generated with PSyAD), the shape arguments are the same as before. This is correct because we are expecting the same basis as the forward code.The problem
Since B has become
inout
, PSyclone erroneously generates code which passes the basis function:{B on B}
rather than the required{B on A}
, to the kernel.This should instead be:
The problem results in an incorrect adjoint. This requires manual intervention using PSy-lite code.
Summary
PSyclone has implicitly chosen
B
as the other part of the basis due toB
being the inoutGH_INC
field in adjoint code, when in reality the basis should chooseA
in the adjoint case. This requires manual intervention using PSy-lite code.Tagging @DrTVockerodtMO
The text was updated successfully, but these errors were encountered: