-
Notifications
You must be signed in to change notification settings - Fork 31
(#Towards 2302) intrinsic argument names #3150
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
|
I think we could also delete the IAttr class entirely and replace it with |
I quickly tried this and decided its worse because you can't pass named arguments to |
|
I've fixed the remaining problems with the test suite. I expect there will be some coverage changes I need to look at next, notably I expect there are now unreachable sections of fparser2.py that I can remove, but I will wait to see what pycov says and go from there in case there are other sections I either miss testing or that can now be removed. One option I leave up to the review is whether to add something to the backend to not output argument names, as we will now be very explicit and add argument names wherever possible (assuming an IntrinsicCall has been canonicalised). |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3150 +/- ##
========================================
Coverage 99.90% 99.90%
========================================
Files 374 374
Lines 53011 53164 +153
========================================
+ Hits 52958 53111 +153
Misses 53 53 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@arporter @sergisiso This is ready for a first look now. |
|
I broke all the sympy stuff again when switching the default behaviour :'( |
…es in its definition
|
Hopefully integration works now, there was one badly defined intrinsic (capitalized argument names which docs say we shouldn't have) that I've fixed and I'm hoping was the remaining issue. |
|
@arporter I think this is ready for another look now - I've fixed the issues discussed and the NEMO4 integration tests work - I'm waiting on the others to finish running but the first LFRic attempt had the signal 11 issue from the Nvidia compiler so I've set it rerunning. |
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.
Thanks very much Aidan. Pretty much there now, just needs some tidying and perhaps a little refactor in the FortranWriter/SympyWriter handlers for IntrinsicCall.
doc/developer_guide/psyir.rst
Outdated
| fails, then PSyclone will not create an ``IntrinsicCall`` corresponding to | ||
| the input. This canonicalisation is required to guarantee correct behaviour | ||
| when computing reference_accesses or the return type of an Intrinsic. | ||
| will convert all of the arguments to be named arguments. If canonicalisation |
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.
Please could you reword this whole section (L597-) as I think we've agreed that we're not calling it "canonicalisation" any more?
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
| # By default, the PSyIR backends output argument names on (most) | ||
| # IntrinsicCalls. This option enables control of that behaviour. | ||
| self._backend_intrinsic_named_kwargs = True | ||
| self._backend_intrinsic_named_kwargs = False |
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 above needs changing as the default is now not to put unnecessary argument 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.
Done
src/psyclone/generator.py
Outdated
| # Record any intrinsic output format settings. | ||
| if "disable_named_intrinsic_args" in args: | ||
| if "backend_add_all_intrinsic_arg_names" in args: | ||
| # The backend won't attempt to add names to required |
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 update this comment too :-)
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
src/psyclone/generator.py
Outdated
| Config.get().backend_indentation_disabled = True | ||
| # A command-line flag overrides the setting in the Config file (if | ||
| # any). | ||
| if "backend_disable_validation" in args: |
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.
Please could you group this with the bit setting backend_intrinsic_named_kwargs above so that all the 'backend' options are in one place in the code.
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.
Moved.
| # Config says to avoid outputting argument names where | ||
| # possible. | ||
| try: | ||
| # Canonicalisation handles any error checking we might |
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/Canonicalisation/compute_argument_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.
Updated.
| :returns: the SymPy representation for the Intrinsic. | ||
| ''' |
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.
Do we still need this list of special routines (and if so, please add 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.
I think so yes - these are the intrinsics that require a Call XXXX format, so they need to be handled differently. I think the sympy stuff doesn't work for them, but we should still be precise I think.
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 could be wrong here maybe, I don't really understand the goal of the sympy output for intrinsics that sympy doesn't recognize)
| :returns: A symbol object with the same properties as this | ||
| symbol object. | ||
| :rtype: :py:class:`psyclone.psyir.symbols.IntrinsicSymbol` |
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.
Typehint instead pls (may need a from __future__ import annotations)
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.
Added
|
|
||
| def test_sym_writer_intrinsiccall_node(fortran_reader): | ||
| '''Handle unlikely edge cases for intrinsiccall node.''' | ||
| code = """subroutine test |
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.
Please could you specify what the 'unlikely edge cases' are.
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.
Added
| # Author A. B. G. Chalk, STFC Daresbury Lab | ||
| # ----------------------------------------------------------------------------- | ||
|
|
||
| ''' Perform py.test tests on the psygen.psyir.symbols.intrinsicsymbol file ''' |
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 should say "....intrinsic_symbol file" and this file should be named "intrinsic_symbol_test.py".
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.
Fixed
| intrinsic = psyir.walk(IntrinsicCall)[0] | ||
| assert isinstance(intrinsic.routine.symbol, IntrinsicSymbol) | ||
| isym = intrinsic.routine.symbol | ||
| copy = isym.copy() |
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 could you check that we do have a copy, i.e.:
assert copy is not isym
assert isym.datatype is not copy.datatype
etc.
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.
Added
|
@arporter I've addressed the comments now - the only one I'm not sure about is the sympy writer one (w.r.t what the sympy writer should output for these things it doesn't support). Let me know what you think. |
Could be closes, not sure, up to review.
Work in progress on doing this, remaining steps I have for this PR: