#3315 Loop fusion of builtins on the same any_space_ - #3466
Conversation
|
To note, I've changed |
|
So the failure is occurring when PSycloning
However, I'm not sure if this is the behaviour we actually want from the fuse functionality. Leaving this dead node around seems unhelpful but it seems plausible that it could just be that the transformation script isn't well written for this case. |
|
Also, when checking the |
I think they probably shouldn't be fused then - the "same |
So previously we refused to fuse so this wasn't a problem? I agree the script is not well written - after the fusing, the |
Yes, so previously the loop fusion would fail so you wouldn't lose the node in |
I don't think my brain has caught up from being off, so apologies for the dumb question! Can I double check the functionality that we're trying to implement here? If I'm understanding what you said correctly then this should fall into that category because the next invoke is |
|
I have had a discussion with @mo-alistairp and I believe the problem with fusing two fields in an invoke that only use builtins is PSyclone has no way of knowing what space they are on. However, whilst this may have arisen in the training material, would this ever arise in LFRic? The only way to interact with a field is via an invoke. So it could only arise via flow control e.g. if a compute z=x/y or if b compute z=x for example but then they would need to be more complex chains of builtin i.e. more than one. However, the condition would be on a scalar, (so maybe min max). It would probably be possible to re-write the alg to avoid doing this - if we ever do. I think we don't. If we don't allow this we will miss most of the fusion we want to do. I think we can fuse in this way. We can solve this with a run-time check on undf? |
|
Just to see if I've understood you @christophermaynard, I think you're saying that there won't be any (or very few) cases of an invoke where the same field is passed to multiple builtins? I can see that that is probably true. A grep of an application working directory would help here but I can't currently get at a machine where I've build LFRic recently. Therefore, I think you're saying that if we find candidates for fusion, we should just check their undf and branch in the generated code accordingly? That would work. It would be even better (simpler generated code) to see whether we can determine whether two different fields are actually on the same space by static analysis (looking at any other, user-supplied kernels they are passed to in an invoke). However, in terms of this specific task, the check on |
|
Hi @arporter I am saying that there will be no instances of invokes with only builtins, so the assignment of any_space for builtins is sufficient. There is no reason to have only builtin invokes. The only place it could conceivably occur is in the transport where the could be branching on a scalar and either side of the branch, a different calculation - a different invoke would occur. I don't believe they would have multiple builtins though and if they did, transport is entirely W2 for wind so they are all the same space. |
When multiple builtins in an algorithm are on the same
any_space_they should iterate over the same number of DoFs. Hence, these are candidates for fusion. This is currently missed in the LFRic loop fusion validation step and can be extended to allow this increased functionality. This change should allow the removal of some PSyKAl-lite code in LFRic.