-
Notifications
You must be signed in to change notification settings - Fork 30
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
(#Closes #2592 and 2582(?)) Routine has a _symbol attribute. #2596
Conversation
Thanks @LonelyCat124, I think what you're missing is use of the |
@LonelyCat124 I had a look at this, I think overriding the _parent setter is a good possible alternative and it should not cause problems with the ChildrenList automatic parent handling. (the other alternative is using What I am not sure is about what you did inside the name.setter "if not self._symbol" branch. I think if the Scope already have a symbol with the given name it could be because another routine or import already has it, and should fail. Maybe for new Routines should just set |
I see that one problem with this is that the fparser2reader forward-declares routine symbols (with the _process_routine_symbols calls). Because Fortran can have a Call to a routine that is declared below itself. Maybe we could modify the frontend to put empty Routines in a first pass (of the caller of _process_routine_symbols), so the symbols exist, and then populate them on a second pass. |
…592_Routine_symbol
…s. We need to wait on #2575 to complete this PR for FileContainers as well
I've merged master in (and fixed the conflict) and I now get some failing tests that aren't clear as to why they're failling for me. One such example is The code seems to assume that the |
|
I'm not sure - what was their original use-cases? If they're used in any scripts or any other part of PSyclone its not great to remove them, I can just fix the tests (there are also other failing tests I'm yet to examine). Edit: grepping in PSyclone only shows the tests using it, so it depends on any other uses externally. |
In that case I would remove it. I'm not aware of any external uses of it. @JulienRemy do you use |
We've never used the attribute I implemented in the closed PR nor |
Moving this into Routine looks to have some complex side effects w.r.t the DSL frontends. One example is in GOcean where simply initialising a GOcean PSyIR tree is problematic. From what I understand, it looks like we first get a standard PSyIR tree, and then the The problem now is that since the Routine has added its' symbol to the I'm not really sure how to resolve this issue - any advice would be appreciated. |
That does sound difficult. Could we perhaps overload the |
Yeah - I'm just not sure what the "special" thing should be. I can't decide if we should force removal of the symbol (somehow) in this case, but I'm not sure what the result of that would be, nor if we have that functionality. I did wonder about not adding the symbol to the parent if its a GOceanContainer or an LFRicContainer (or perhaps if its not either specifically a |
There's also some issues with outputs it seems like due to copying the tree. When copying the Container, it keeps the symbol in the new containers symbol table (i think? Its not clear that this always happens since not every test fails...), but for one of the inline trans tests (that i'm currently looking at) it fails here:
because Edit: this happens at the |
TODO:
|
I fixed the above things, just roaming through failing tests and fixing those that I understand that are caused by these changes. I've hit one that I don't understand how I can have changed the behaviour of the code. I don't think I modified the behaviour of process_declarations so I'm confused how this passed before - fparser2.py adds the Edit - will continue documenting tests i don't understand: Also some tests in Also having issues in test_lfric_adjoint test |
I also seem to have some failing tests in inline_trans because the order of |
Ok it again looks like not an easy fix. The test is simple:
During fparser, we create empty An alternative solution to this would be to not detach I wonder if I should force routine.detach() to work even if its symbol can't be removed, but I'm not sure what downsides this might have? I guess there is the "what if i'm attaching a routine to a container where its symbol already exists" issue, but I can check if its symbol is already present before trying to add it. Any thoughts @sergisiso? Edit: This inability to remove Routines due to their symbols being prevented from removal also breaks Remaining failing tests are in these files:
I'd guesstimate that 2/3rds or more fail because Routine.detach() fails at various points as the RoutineSymbol is referenced. |
I'm now forcing removal of symbols in ScopingNode._refine_copy, and keeping a list of "symbols_to_fix", but I'm not sure they ever actually need fixing as I think maybe something else is fixing the attachment of the It does have some un-pythonic/OO implementations in various points now, and once this is closer to review (i.e. the tests all work) then I probably need to discuss this with the reviewer probably. |
The changes break the test for lines 404-410 in Still one test failing in fparser2.py. My remaining concern is that I broke something in adjoint @arporter. The test
What seems to be happening is there are some symbols that refer to a "routine" All the other remaining tests are around kernel_module_inline_trans - I've left those alone for now - I think they're all happening due to symbols already being present in symbol tables but I need to dive into why this happens for some (but not all) tests. Edit: |
…the new Routine and symbol handling
I'm going to rerun the integration tests now after the error from alst week. Not sure why project coverage decreases though. |
A drop in coverage often indicates 'indirect changes' - i.e. changes in coverage of lines that aren't directly touched in this PR. If you look at https://app.codecov.io/gh/stfc/PSyclone/pull/2596/indirect-changes you'll see you have a few. |
…reachable statements
If this now works with coverage I'll run integration tests once more as I removed what I believe was unreachable code now with this branch, but I want to double check integration tests don't break. |
@sergisiso
We tested this file I thought and it was fine - I'll try to have another look at this tomorrow. |
@sergisiso I found the issue, the output contains this:
What seems to happen is the fparser2.py:5311 doesn't remove the fake Subroutine. I have a test that checks this subroutine is removed and will fix this up now. |
@sergisiso This should be ready for another look now - it made it past the failing part of integration so should be ok now. |
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.
@LonelyCat124 All the comments have been addressed, all the tests and integration test pass and the documentations builds. This is ready to merge
Reading and grepping the branch I found a bunch of symbol_table.lookup_with_tag('own_routine_symbol')
and routine.symbol_table.lookup(routine.name)
or similar instances, and I replaced all of these with routine.symbol. This has not broken any test, but I will run a final integration test just in case.
Integration test passed again, there was just some flake8 issues that I introduced myself and I have now fixed. |
@sergisiso @arporter I have a very initial implementation of the changes I feel are needed for the
Routine
node specifically to support this change. I'm a bit concerned about what I needed to do w.r.t to handling the creation of aRoutine
that doesn't have a parent and adding a parent in later (which is probably something reasonable to be able to do), as I needed to override_parent
as both a property and setter.If either you have time to have a look and let me know how you feel about this implementation before I move much further, and any suggestions/alternatives would be appreciated.