-
Notifications
You must be signed in to change notification settings - Fork 32
(closes #2884) Allow WHERE with imported symbols by changing Ref2ArrayRange behaviour to do the validations #3260
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
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3260 +/- ##
==========================================
- Coverage 99.91% 99.91% -0.01%
==========================================
Files 376 376
Lines 53529 53522 -7
==========================================
- Hits 53484 53477 -7
Misses 45 45 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@arporter @LonelyCat124 This is ready for review. It changes the Reference2ArrayReference to fail if the outcome cannot be guaranteed, so thing like WHERE can rely on its validation. This will be followed by #1858 (structures) and #2722 (dependencies), which can be done in a single location after this PR, but it was to big to do here. |
arporter
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.
Really nice Sergi, it's good to see the simplification that this has achieved.
I'm worried that we are no longer raising an exception when we see a StructureReference - given that we can't handle them this needs to be flagged?
Apart from that, it's just minor tidying. I'll run the integration tests next time (or you could fire them off perhaps once you're done).
src/psyclone/psyir/transformations/reference2arrayrange_trans.py
Outdated
Show resolved
Hide resolved
src/psyclone/psyir/transformations/reference2arrayrange_trans.py
Outdated
Show resolved
Hide resolved
| # TODO issue #1858. Add support for structures containing arrays. | ||
| if node and node.parent and isinstance(node.parent, Call): | ||
| if node.position == 0: | ||
| return |
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.
Comment please - I didn't readily understand at first but presumably this is checking that the node isn't the Reference associated with the routine target of a Call?
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.
Exactly. Added 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.
You probably don't need the and node.parent part of L120 as, if it's None, it won't pass the isinstance(node.parent, Call)?
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.
Removed
src/psyclone/psyir/transformations/reference2arrayrange_trans.py
Outdated
Show resolved
Hide resolved
src/psyclone/tests/psyir/frontend/fparser2_where_handler_test.py
Outdated
Show resolved
Hide resolved
src/psyclone/tests/psyir/transformations/reference2arrayrange_trans_test.py
Outdated
Show resolved
Hide resolved
src/psyclone/tests/psyir/transformations/reference2arrayrange_trans_test.py
Outdated
Show resolved
Hide resolved
| trans.validate(reference) | ||
| assert ("node is passed as an argument to a Call to a non-elemental " | ||
| "routine (DEALLOCATE(a)" in str(info.value)) | ||
| trans.validate(assign.lhs) |
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.
The docstring says we test that a StructureReference raises an exception but clearly it doesn't any longer. Given that we don't support them yet, I would argue we should raise an exception as we don't know what to do with 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.
It felt bad to have the comment that are not supported and then just return the validation.
The reason I did it is because both the WHERE and the ArrayAssignment2Loop already implement and have several tests for structure references (which they happily take at face-value, without checking if they need to be added ranges).
Adding this restriction here, without implementing proper support for letting valid cases pass, and array types extended, makes all of those fail.
Also this is not worse than master, in master it had an exception but it was "except:pass" everywhere it was used.
I suggest I tackle this in a follow up (I attempted starting it but it quickly grows very large), or we can block this for now. Let me know what you prefer.
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 implemented it in #3266
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 Sergi. As you're in the process of doing #3266, please could you just update this test with TODO to that PR (or would you like to get that PR on first?).
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.
or would you like to get that PR on first?
I based that PR after this one's HEAD, so I can't change the order. The other PR is ready to go once this one is merge.
I added the TODO just before the test to avoid conflicts as I already modified this test significantly in the follow up.
src/psyclone/tests/psyir/transformations/reference2arrayrange_trans_test.py
Outdated
Show resolved
Hide resolved
99ab3e0 to
3e1c6b8
Compare
|
@arporter This is ready for another look, I just fired the integration test. |
arporter
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.
| to do so (e.g. it won't convert call arguments because it would change the | ||
| bounds values). | ||
| Note that if the provided node does not need to be modified is provided ( |
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.
s/is provided// but I can do this if there's nothing else.
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.
Done
| # TODO issue #1858. Add support for structures containing arrays. | ||
| if node and node.parent and isinstance(node.parent, Call): | ||
| if node.position == 0: | ||
| return |
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.
You probably don't need the and node.parent part of L120 as, if it's None, it won't pass the isinstance(node.parent, Call)?
| '''Test that a reference in a PointerAssignment raises an exception. ''' | ||
| def test_pointer_assignment(fortran_reader, fortran_writer): | ||
| ''' Test that a reference in a PointerAssignment raises an exception | ||
| Pointer and target attributes (currently represented by partial_datatype |
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.
Pls close the parentheses after "partial_datatype"
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.
Done
| trans.validate(reference) | ||
| assert ("node is passed as an argument to a Call to a non-elemental " | ||
| "routine (DEALLOCATE(a)" in str(info.value)) | ||
| trans.validate(assign.lhs) |
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 Sergi. As you're in the process of doing #3266, please could you just update this test with TODO to that PR (or would you like to get that PR on first?).
I already tried this but it didn't work. Unfortunately psyad is unsafe in master as it considers any imported symbol is scalar or a non-elemental call. This happens to be true but it is unsafe. Ultimately we need to remove the except as the transformation guarantees this but if I do it now there is a big regression because most of the psyad real code has imports that are unchecked. We need capabilities to follow imports in psyad and its build system. I modified a test to show this and created an issue and TODOs. |
|
@arporter This is ready for another look |

Change Ref2ArrayRange behaviour by letting it pass if the provided node is already in the expanded form, but making it fail if for a expression we cannot guarantee if it could be expanded or not. This will bring validations that now need to be done every time its used to inside the transformation.