-
Notifications
You must be signed in to change notification settings - Fork 32
(Towards #2381 #2674) add min max access types and new LFRic builtins #3263
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
base: master
Are you sure you want to change the base?
Conversation
…into 2381_arp_global_reduction
…into 2381_arp_global_reduction
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3263 +/- ##
=======================================
Coverage 99.91% 99.91%
=======================================
Files 376 376
Lines 53522 53555 +33
=======================================
+ Hits 53477 53510 +33
Misses 45 45 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Ready for a first look from anyone still working @sergisiso or @hiker ? |
sergisiso
left a comment
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.
@arporter Most of the PR looks good but I am getting confused by the need of these specific access types, these seem regular writes to me. It would be good to clarify if these are really needed before continuing.
config/psyclone.cfg
Outdated
| access_mapping = gh_read: read, gh_write: write, gh_readwrite: readwrite, | ||
| gh_inc: inc, gh_readinc: readinc, gh_sum: sum | ||
| gh_inc: inc, gh_readinc: readinc, gh_sum: sum, | ||
| gh_min: min, gh_max: max |
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.
tab to spaces :)
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.
Ah! Done.
| | GH_SCALAR | GH_REAL | n/a | GH_READ, GH_SUM, | | ||
| | | | | GH_MIN, GH_MAX | |
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 don't understand why do we need GH_SUM, GH_MIN or GH_MAX. These is the output scalar of the built-in which will only be written to, Why not GH_WRITE?
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.
This is a good point. Currently, we rely on knowing the type of reduction being performed by a built-in when creating the Invoke (in lfric_invoke.py):

At this point, we don't have the PSyIR for the built-in - just its name and metadata. Therefore, if the scalar argument was just GH_WRITE we would know that it was a reduction but could not determine the type. I feel we may have conflated DSL metadata "access" information with PSyIR access concepts.
| #: Is the output of a MIN reduction (i.e. global minimum value). | ||
| MIN = 11 | ||
| #: Is the output of a MAX reduction (i.e. global maximum value). | ||
| MAX = 12 |
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.
Again MIN/MAX is not an AccessType (same with the pre-existing SUM). It is even more confusing that this refer to the output scalar, which is just written to. So why do we differentiate them?
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.
As commented elsewhere, I agree. I'll look to see if I can restrict the MIN/MAX/SUM concept to the kernel metadata.
|
I thought the best way to solve this would be to have |
Could we not just determine the type using its name?
I am not sure if this would be just moving the problem, I don't feel it is information that belong to the AccessType. Looking at the code snippet that you shared is the reason for not being GH_WRITE the validation? So we don't allow scalar GH_WRITE because they would be a race condition, but we allow scalar reduction writes because the synchronisation is built-in in the operation? In this case, could we add a GH_SAFE_WRITE/GH_ATOMIC_WRITE, this could be the metadata of the reduction built-ins but also for kernels where the race condition is handled inside the kernel (although we may not want to advertise this feature). This would be useful in the generic AccessType because in the future we may want to identify these safe_writes in generic code as they have less dependencies that what we give them now. |
|
My feeling is that we currently have quite a lot of domain-specific information in AccessType which should not be there (e.g. INC). All of the generic PSyIR should, as you say, use READ/WRITE/READWRITE. The concept of a reduction or INC access belongs with a domain. I was therefore planning on separating the two out and ensuring that the domain-specific access types are only referred to in appropriate places in the code. I'm not that keen on the idea of having a mapping of particular built-ins to the type of reduction they perform - it feels more natural to keep that information as part of the metadata associated with the kernel. The potential future re-use of |
|
Having now realised that we also have |
|
@sergisiso ready for another look and/or continued discussion. |

This is a step towards both #2381 (generalising global reductions) and #2674 (new field_min_max builtin). It attempts to reduce the size of #3222 by only adding the two new access types for reductions as well as the skeletons for the new builtins.