Skip to content
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 #1664) Add ACCWaitDirective and async keyword on kernels, enter data, parallel #2664

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

arporter
Copy link
Member

This is a replacement/takeover of #2070 as Sebastien has moved to a new job.

@arporter
Copy link
Member Author

Now that I look at this again, there don't seem to be any tests of the new directive and keyword for the Fortran psyir backend (it's all gen_code in LFRic).

@arporter
Copy link
Member Author

I see from #2070 (comment) that this PR was started before we had ACCClause (#2157). However, we do now have clauses and therefore this code needs updating (to remove the use of Signature) and tests for the Fortran backend are required.

Copy link

codecov bot commented Nov 22, 2024

Codecov Report

Attention: Patch coverage is 98.88889% with 3 lines in your changes missing coverage. Please review.

Project coverage is 99.88%. Comparing base (b051810) to head (8b4e0e9).

Files with missing lines Patch % Lines
src/psyclone/psyir/backend/fortran.py 50.00% 2 Missing ⚠️
src/psyclone/psyir/nodes/acc_clauses.py 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2664      +/-   ##
==========================================
- Coverage   99.88%   99.88%   -0.01%     
==========================================
  Files         359      360       +1     
  Lines       50681    50874     +193     
==========================================
+ Hits        50625    50815     +190     
- Misses         56       59       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@schreiberx
Copy link
Collaborator

@arporter

  1. I worked on the code coverage. Let's see what the next push brings.
  2. There was something in the code that I didn't understand:
    async_queue was never to None, but then checked against None.
    But I found places where async_queue was set to False if the option didn't exist. I changed this throughout the code that async_queue is set per default to None and to an integer otherwise.
  3. Regarding the options dictionary, I set the default argument value to {}. This avoids further checks below ala option is None.

@schreiberx
Copy link
Collaborator

@arporter

1. I worked on the code coverage. Let's see what the next push brings.

2. There was something in the code that I didn't understand:
   `async_queue` was never to `None`, but then checked against `None`.
   But I found places where `async_queue` was set to `False` if the option didn't exist. I changed this throughout the code that `async_queue` is set per default to `None` and to an integer otherwise.

3. Regarding the options dictionary, I set the default argument value to {}. This avoids further checks below ala `option is None`.

I updated the async part in the previous push.
async_queue can be finally set to these values:

  • None or False which doesn't make use of it
  • True which uses it without specifying a concrete queue
  • An integer or a Reference as the concrete queue to use.

Copy link
Collaborator

@sergisiso sergisiso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arporter @schreiberx I don't know who is the owner of this PR but I added my review. My main concern is that it adds PSyIR nodes in a private attribute of a mixin, and this has been a source of issues in the past as these are easy to forget when doing tree modifications. I think we should consider making it a ACCClause so all the tree functionality works as expected.

self.parallelism = parallelism
assert self.parallelism in self.SUPPORTED_PARALLELISM
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove, this is done in the setter above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

:param async_queue: Enable async support and attach it to the given queue.
Can use False to disable, True to enable on default
stream. Int to attach to the given stream ID or use a
variable Signature to say at runtime what stream to be
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code does not use a Singature, but a Reference which is better, update the docstring.

We could also consider replacing it with a DataNode to accept operations as they are valid.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done and moved to DataNode. Updated appropriate test to check this works.

self,
children: List[Node] = None,
parent: Node = None,
async_queue: Union[bool, int, Reference, None] = None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we do: Union[bool, int, Reference] = False as I assume False and None have the same meaning?

Also everywhere else that has async_queue

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure they did but I've changed things now so that True means an async clause without an explicit queue while False means no async clause. I've removed the support for None.

Comment on lines 119 to 121
Tuple[
Set[Signature], Set[Signature]
]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being picky I slightly prefer would put this tree lines into one. But to make it more readable, but I can also be convinced not too (e.g. is what black choses)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

Comment on lines +38 to +39
''' This module contains the mixins to apply some ACC features on many
classes.'''
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am tempted to say that this should be in acc_directives.py, as I quite liked that everything regarding OpenACC was encapsulated there, but that file has reached the 1000 (although we will delete gen_code soon - hopefully), so can be convinced otherwise.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fairly relaxed about having another file and as you say, the directives file is at 1.3K now. If we really care we could have an openacc submodule?

from psyclone.psyir.symbols import UnsupportedFortranType
from psyclone.psyir.transformations.region_trans import RegionTrans
from psyclone.psyir.transformations.transformation_error import (
TransformationError)

from typing import Any, Dict, List, Union
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pylint wants this before third party libs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

:param options: a dictionary with options for transformations.
:type options: Optional[Dict[str, Any]]
:param bool options["default_present"]: whether or not the kernels
"default_present": boolean whether or not the kernels
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this still be :param bool options["default_present"]: as before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it should. I've also put back the one for "async_queue".

:param options: a dictionary with options for transformations.
:type options: Optional[Dict[str, Any]]
:param bool options["disable_loop_check"]: whether to disable the
"disable_loop_check": boolean whether to disable the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here and below, I am unsure which format is rendered more clearly in the docs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reverted to our original form.

Comment on lines 2502 to 2504
The available options are :
- async_queue : Permit to force using the given async stream if
not None.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use common format for option arguments.

@@ -35,6 +35,7 @@
# A. B. G. Chalk, STFC Daresbury Lab
# Modified I. Kavcic, Met Office
# Modified J. Henrichs, Bureau of Meteorology
# Modified S. Valat, INRIA / LJK
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe delete since at this point there isn't modifications at this specific file (but there is a couple of actually modified files in this PR where the contributors' names could be added).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants