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

Psyclone 3 support #388

Open
wants to merge 430 commits into
base: main
Choose a base branch
from
Open

Psyclone 3 support #388

wants to merge 430 commits into from

Conversation

hiker
Copy link
Collaborator

@hiker hiker commented Feb 14, 2025

Supports the new 3.0 release, but also older PSyclone versions.

hiker and others added 30 commits June 7, 2024 10:29
… only one artefact set is involved when running PSyclone.
…les to the default build artefact collections.
hiker added 26 commits November 20, 2024 14:57
…ive compiler names are longer (crayftn-cray, craycc-cray).
…ms with compiler wrapper which do not support this).
@hiker hiker requested a review from MatthewHambley February 14, 2025 13:42
@hiker hiker changed the title Psyclone 3 support clean Psyclone 3 support Feb 14, 2025
Copy link
Collaborator

@MatthewHambley MatthewHambley left a comment

Choose a reason for hiding this comment

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

I think there may be a better way of handling the change of behaviour between versions.

Comment on lines +70 to +79
# The behaviour of PSyclone changes from 2.5.0 to the next
# release. But since head-of-trunk still reports 2.5.0, we
# need to run additional tests to see if we have the official
# 2.5.0 release, or current trunk (which already has the new
# command line options). PSyclone needs an existing file
# in order to work, so use __file__ to present this file.
# PSyclone will obviously abort since this is not a Fortran
# file, but we only need to check the error message to
# see if the domain name is incorrect (--> current trunk)
# or not (2.5.0 release)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not only has PSyclone 2.5.0 been released but so has 3.0.0. So any special cases can be removed and this section can be streamlined.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was hoping to clean this up before it reaches you tbh. OK, long story:
ATM, PSyclone 3.0 supports backwards compatibility in the trans(psy) function (it now expects a proper psyir node), though a warning marks this as deprecated. I've asked if for the 3.1 release we could disable this backwards compatibility hack in 3.1 and properly fail, but the other devs pointed out that PSyclone 2.5 (with a psy argument) is still important, since it was just added to the NEMO build system.
At the same time I also noticed that standard environments for NG-ARCH (on Archer2 and Pawsey) still come with PSyclone 2.5 installed :( I have Scott (ngmo-environments dev) added to Pawsey, so he can port ngmo-environments to Crays, so hopefully we soon have an up-to-date one.

So, since my plot to just stop supporting 2.5 failed, we still need to support it. BUT, I think what we can stop supporting is the odd mixture of development versions (after 2.5, before 3.0), which we have urged people in NG-ARCH to use (to get latest bug fixes).

So, I'll try to remove the crappy code to support 3.0 dev-versions, which we needed in the past. I believe that should significantly simplify the code in question, since now we can rely on --version giving us the right version number. And we have fixed our release process to properly (and at some stage maybe even automatically) support development version numbers (the idea being that e.g. 3.0.1-dev, which we have atm, will be converted to 3.0.0.1 internally in Fab, so we know that this version is between 3.0.0 and 3.1, the next release

self._api = api
self._version = None

def check_available(self) -> bool:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this whole complication, or a good section of it, be replaced by making use of shutil.which(...)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Interesting, I didn't know that tool (I know the shell tool, but afaik that's not available everywhere).
I still need to actually run psyclone, since e.g. on NCI we get:

$ psyclone
/apps/python3/3.12.1/bin/python3.12: error while loading shared libraries: libpython3.12.so.1.0: cannot open shared object file: No such file or directory
$ which psyclone
~/.local/bin/psyclone
$ python3
>>> import shutil
>>> shutil.which("psyclone")
'/home/903/jxh903/.local/bin/psyclone'

So, while indeed this is a kind of broken installation, I can't rely on shutil.which alone. But I'll check if this simplifies the code further.

Comment on lines +127 to +128
if api and api.lower() == "nemo":
api = ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than trying to make on class support quite different versions of the tool would it make sense to have an old PSyclone and a new PSyclone class with some sort of factory process to choose between them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would hope that this sequence of tests is not too bad. Yes, if we had two version, the if-statement would only have half the size (one version would contain the 'if' tests, which still need to test for new-style parameters, the other version the else branch with the old-style parameter), we would get quite a bit of either duplicated code, or if we create a base class, more files. I would think that this actually adds more overhead compared with one if-statement, but I am happy to re-evaluate once I have removed support for 3.0-dev versions.

@hiker
Copy link
Collaborator Author

hiker commented Feb 19, 2025

I'll try to fix this up and will tag you when I'm done (but for now #390 is really urgent since it breaks all our CI)

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

Successfully merging this pull request may close these issues.

4 participants