-
Notifications
You must be signed in to change notification settings - Fork 32
(Closes #3251) Implementation for the PSyDirective. #3255
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 #3255 +/- ##
=======================================
Coverage 99.91% 99.91%
=======================================
Files 376 377 +1
Lines 53512 53547 +35
=======================================
+ Hits 53467 53502 +35
Misses 45 45 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I still don't think we need psyclone ( |
|
We could do that instead, but it would mean more false positives when people are looking for something specific to their script, e.g. after I would maybe with ok with doing some |
Good points, what about [Unrecognised/Unsupported/Unknown]Directive (being sibling of Standalone/RegionDirective)? So it is clear that we don't support them and if we ever try to parse OpenMP, OpenACC into their own Directive the name will still make sense for those that we have not done yet. (my preferd is UnknownDirective, but I am unsure)
I don't understand this. It will be better than the current Codeblock, and it would allow searching for "ivdep" or other know compiler directive that may exist in the code.
Why excluding those? |
|
Yeah I agree with most of that, so I'll modify this PR towards that. My reasoning for ignoring omp/acc/etc. directives is party that keeping them as CodeBlocks means they'd keep any current properties that CodeBlocks have (i.e. disabling transformations etc.) and also make it clear that they're not meant to be used as part of any tree manipulation programming, but are just for keeping elements of the source code that PSyclone doesn't or can't support. |
|
@sergisiso this is ready for review, but no rush to do so. |
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.
@LonelyCat124 I like how this is implemented now, and especially having an example to showcase it. There are just minor comments now.
| """Test that the FortranReader stored a directive before an allocate as a | ||
| CodeBlock.""" | ||
| """Test that the FortranReader stored a directive before an allocate as an | ||
| UnknownDirective.""" |
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.
Revert (this one is still a Codeblock)
| from psyclone.psyir.nodes.directive import StandaloneDirective | ||
|
|
||
|
|
||
| class UnknownDirective(StandaloneDirective): |
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.
Maybe StandaloneDirective is the right choice, but why not just Directive?
| Directive representing PSyclone-specific directives in the tree. | ||
| :param directive_string: The content after the !$psy part of this | ||
| node in the tree. |
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.
param kwargs is missing
| :param directive_string: The content after the !$psy part of this | ||
| node in the tree. | ||
| ''' | ||
| _children_valid_format = "" |
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.
we typically write "<LeafNode>" as format for leafs
| Authors: A. B. G. Chalk, STFC Daresbury Lab | ||
| --> | ||
|
|
||
| # PSyclone PSyIR directives. |
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.
Maybe:
# Use custom directives
This directory contains an example of how write PSyclone scripts to transform code
by taking advantage of information provided by the use of custom Fortran code directives.
I would also call the directory "custom_directives" (although the node name is Unknown, the use case is probably what people will look for in the examples)
|
|
||
| The example can be compiled using the Makefile, but this is a simple operation: | ||
| ``psyclone --keep-directive -s omp.py directive_filtering.F90``. The | ||
| ``-keep-directives`` option is essential to enabling the directive of interest |
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.
double dash?
| from psyclone.psyir.nodes import Loop, Routine, UnknownDirective | ||
|
|
||
|
|
||
| # Find the PSyDirectives, check what the directive is for and then find the |
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.
Maybe "Find the custom directive and add the associated loop to the list of loops to skip. Parallelise the rest."
And better as the method docstring instead of a comment, to make pylint happy.
| # Author: M. Naylor, University of Cambridge, UK | ||
| # Modified: A. B. G. Chalk, STFC Daresbury Lab |
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.
Only you as author
| end do | ||
|
|
||
| ! Don't parallelise this next loop due to the string comparison | ||
| !$psy no_par |
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 would prefer a different string than "psy" for the example, maybe "mydirective" or "custom_directive" to not confuse anybody just looking at this file that this is a psyclone directive (change the readme with the same).
| # ----------------------------------------------------------------------------- | ||
| # Author: M. Naylor, University of Cambridge, UK | ||
| # Modified: A. B. G. Chalk, STFC Daresbury Lab | ||
|
|
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.
We typically add "transform, compile and run" standardised target names to all examples, and you will need to make ../Makefile recurse to it (at least for the transform target) so that this is tested in the CI.
Also, it will be good to mention the example in the parent folder README
Example and doc TODO
Basic implementation of PSyDirective including reading and writing.
At the moment I implemented it as a Standalone Directive (as it doesn't make sense to me to be a RegionDirective) but that could be more difficult to use in some ways, but I'll put together an example and see.