Skip to content

Conversation

@hiker
Copy link
Collaborator

@hiker hiker commented Sep 21, 2025

Adds the PSyclone training material (based on #3131)

hiker added 30 commits February 21, 2024 11:44
@hiker
Copy link
Collaborator Author

hiker commented Jan 6, 2026

@arporter , I have addressed all changes. I also added a lot of additional tests, since I had at least two examples being broken that were not picked up by my testing - which was pretty bad in the actual training sessions. One issue is fixed already (and also properly tested here), one is still outstanding (#3252).

The fact that this tutorial contains additional important testing makes me push for getting this in sooner than later. Otherwise we risk a never-ending PR: as PSyclone gets updated and the training is not tested, there is a chance that something breaks the training, Then I need to debug and fix this (or get help to fix this), instead of these problems being flagged when the PSyclone improvements are added (and then being fixed by the original developer before the PR is merged).

Note that I have opened #3270 for additional training improvements (e.g. linking files instead of duplicating ... at least evaluating this option; adding syntax highlighting). And also #3208 to review the individual training sections.

While I totally agree that this is not ideal, my suggestion would be that the review here focuses just on the testing side-of things, to get any issues there sorted out. No one has the time to proof-read all of this text material, and as mentioned, delays this PR just mean this will keep on being more work to keep this up-to-date. Yes, there is a risk that it might take a long time before this material (as in: the READMEs) gets properly updated, and I understand your reluctance.

I am open for any suggestion you have, I don't have a particular brilliant idea either :(

Am triggering the full CI as well.

Copy link
Member

@arporter arporter left a comment

Choose a reason for hiding this comment

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

I'm enjoying going through (in outline) your game-of-life example - it's great to see that you can recover performance :-)
Since most of the example transformation scripts need their module and apply-method docstrings updating, I'm going to pause here to let you do that.
As you suggested, I'm basically ignoring the actual text of the readme's so I am by no means reviewing the actual tutorials.

# Author: J. Henrichs, Bureau of Meteorology

# The transform target `test` runs tests on the gitlab CI (i.e. without
# compilation), `test_run` will compile all binaries (as far as possible
Copy link
Member

Choose a reason for hiding this comment

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

Do you mean compile instead of test_run and then s/run/test_run/ on the following line?

Copy link
Collaborator Author

@hiker hiker Jan 8, 2026

Choose a reason for hiding this comment

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

I've cleaned this up (including removing the 'compile' target from the top level makefiles ... most 'local' Makefiles have a compile for the convenience when running the training, but the high level ones should only use test or test_run)

.PHONY: allclean clean compile test test_run

allclean clean compile test test_run:
$(MAKE) -C psyclone_for_lfric_users $@
Copy link
Member

Choose a reason for hiding this comment

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

Ah, so this part is for LFRic users rather than developers? I think "lfric_users" would be fine since this is already under the "training" directory in the PSyclone repository.

Copy link
Member

Choose a reason for hiding this comment

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

If I do:

cd PSyclone/tutorial/training
make compile

then I get:

make -C psyclone_for_lfric_users compile
make[1]: Entering directory '/home/me/Projects/PSyclone/tutorial/training/psyclone_for_lfric_users'
make[1]: *** No rule to make target 'compile'.  Stop.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That was a left-over target, the top level Makefiles should only support 'test' and 'test_run' (many 'lowest level' makefiles support compile, since it's convenient for the user if e.g. they want to do performance measurements), but no need to support this everywhere.

This is the training material for the usage of PSyclone, a code
transformation and generator tool. PSyclone was originally developed
for the UK Met Office’s new LFRic numerical weather prediction system,
but it’s features of modifying large codes based on scripts have found
Copy link
Member

Choose a reason for hiding this comment

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

"its"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@@ -0,0 +1,90 @@
PSyclone Training
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for adding this Joerg - it's very helpful. Please could you also add a brief README in the directory above to explain what is contained in each of the subdirectories - i.e. it's not clear what the difference between 'training' and 'tutorial' is. Ideally, at some point, we'll probably want to merge the two.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

more open ended, and trainees are encouraged to go back to these
examples and implement better solutions later.

The trainings material is split into four parts, and the files
Copy link
Member

Choose a reason for hiding this comment

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

"training"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

# -----------------------------------------------------------------------------
# Author: J. Henrichs, Bureau of Meteorology

'''Python script intended to be passed to PSyclone's generate()
Copy link
Member

Choose a reason for hiding this comment

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

Pls update.


def trans(psyir):
'''
Take the supplied psyir object, and fuse all loops.
Copy link
Member

Choose a reason for hiding this comment

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

Also inlines...


def trans(psyir):
'''
Take the supplied psyir object, and fuse the last three loops.
Copy link
Member

Choose a reason for hiding this comment

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

Also inlines.

# -----------------------------------------------------------------------------
# Author: J. Henrichs, Bureau of Meteorology

'''Python script intended to be passed to PSyclone's generate()
Copy link
Member

Choose a reason for hiding this comment

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

Pls update.


line_count = 0

do
Copy link
Member

Choose a reason for hiding this comment

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

Comment please.

@hiker hiker deployed to integration January 8, 2026 04:21 — with GitHub Actions Active
@hiker
Copy link
Collaborator Author

hiker commented Jan 8, 2026

Wow, that was an impressive review. I think it took me over an hour just to add 'done' to your comments. You rightly pointed out some repeated errors (generat function, missing docstrings, inlining not mentioned). I think I've fixed them up everywhere.

I've triggered the full IT as well.

@hiker
Copy link
Collaborator Author

hiker commented Jan 8, 2026

@arporter I have a problem - turns out the OpenMP offloading does not work (anymore??). Due to a bug in the makefile, it actually hasn't applied the offloading script at all in my recent tests (I am pretty certain it did originally, but I did some refactoring/ simplifications of the Makefile, which I believe introduced this bug recently). Now I've fixed the Makefile, it aborts with:

make -C 2.16-GameOfLife-omp-offload/solution test_run
...
make --no-print-directory  run | tail -n 12 | diff -b - /archive/psyclone-tests/action-runner-software/actions-runner/_work/PSyclone-mirror/PSyclone-mirror/tutorial/training/gocean/gol-lib/glider.correct

libgomp: pointer target not mapped for attach

(see https://github.com/stfc/PSyclone-mirror/actions/runs/20805411529/job/59758702708)

Googling indicates that there might be a mapping missing (which we don't support afaik), or additional compiler options(?). I don't know what to do. I don't have (easy) access to hardware that would support managed memory, and I am not even certain what the right solution would be in this case :( Can you (or Sergi?) help? I assume you can log onto the machine and try running it there?

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.

3 participants