-
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?
Changes from all commits
c871676
b0c458c
0d5dadf
6856abd
279ec53
4a2f3d4
9eb6784
5921958
de51056
49b856b
6aa870c
355a900
88956f8
488d0a5
c27c9ab
7fe581b
5b4d364
faa440b
d26c56c
ae2fb6d
c6d6366
226cfeb
134954d
72dd101
cf9c5c3
fead32a
5a0654a
eee9422
9fc397b
0523346
4bceba7
833782e
438e405
3d53e98
b460b3c
c475f0c
64874cd
650f584
8aeffda
e5e9af5
bd0c70a
0eea98f
19e1982
e672b5a
dfde2c6
a7cbe5e
3c6187e
3af3abb
2f49897
e3dc204
60db4b9
abd054f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2797,7 +2797,8 @@ are listed in the table below. | |
| +===============+=====================+================+====================+ | ||
| | GH_SCALAR | GH_INTEGER | n/a | GH_READ | | ||
| +---------------+---------------------+----------------+--------------------+ | ||
| | GH_SCALAR | GH_REAL | n/a | GH_READ, GH_SUM | | ||
| | GH_SCALAR | GH_REAL | n/a | GH_READ, GH_SUM, | | ||
| | | | | GH_MIN, GH_MAX | | ||
|
Comment on lines
+2800
to
+2801
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
| +---------------+---------------------+----------------+--------------------+ | ||
| | GH_FIELD | GH_REAL, GH_INTEGER | ANY_SPACE_<n> | GH_READ, GH_WRITE, | | ||
| | | | | GH_READWRITE | | ||
|
|
@@ -3455,6 +3456,34 @@ the same field (``X = min(a, X)``):: | |
|
|
||
| field(:) = MIN(rscalar, field(:)) | ||
|
|
||
| Global minimum and maximum field-element values | ||
| ############################################### | ||
|
|
||
| Built-ins which scan through all elements of a field and return its | ||
| maximum or minimum value. | ||
|
|
||
| .. warning:: | ||
| Support for these built-ins is not yet complete and therefore they | ||
| cannot currently be used. TODO #2381. | ||
|
|
||
| minval_X | ||
| ^^^^^^^^ | ||
|
|
||
| **minval_X** (*rscalar*, **field**) | ||
|
|
||
| Returns the minimum value held in the field *field*:: | ||
|
|
||
| rscalar = MINVAL(field(:)) | ||
|
|
||
| maxval_X | ||
| ^^^^^^^^ | ||
|
|
||
| **maxval_X** (*rscalar*, **field**) | ||
|
|
||
| Returns the maximum value held in the field *field*:: | ||
|
|
||
| rscalar = MAXVAL(field(:)) | ||
|
|
||
| Conversion of ``real`` field elements | ||
| ##################################### | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ | |
|
|
||
| '''This module implements the AccessType used throughout PSyclone.''' | ||
|
|
||
| from __future__ import annotations | ||
| from enum import Enum | ||
| from psyclone.configuration import Config | ||
|
|
||
|
|
@@ -75,6 +76,10 @@ class AccessType(Enum): | |
| #: is available at compile-time and can be used for type properties such | ||
| #: as kinds or dimensions. | ||
| CONSTANT = 10 | ||
| #: 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 | ||
|
Comment on lines
+79
to
+82
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
|
|
||
| def __str__(self) -> str: | ||
| '''Convert to a string representation, returning just the | ||
|
|
@@ -132,12 +137,11 @@ def all_read_accesses(): | |
| AccessType.READINC] | ||
|
|
||
| @staticmethod | ||
| def get_valid_reduction_modes(): | ||
| def get_valid_reduction_modes() -> list[AccessType]: | ||
| ''' | ||
| :returns: A list of valid reduction access modes. | ||
| :rtype: List of py:class:`psyclone.core.access_type.AccessType`. | ||
| ''' | ||
| return [AccessType.SUM] | ||
| return [AccessType.SUM, AccessType.MIN, AccessType.MAX] | ||
|
|
||
| @staticmethod | ||
| def get_valid_reduction_names(): | ||
|
|
||
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 :)