Skip to content

Conversation

samhatfield
Copy link
Collaborator

This PR implements a "host backend" for the GPU code path. Essentially I have made some minor tweaks to the Fortran and implemented host-side C++ backends for the Fourier and Legendre transforms, using the existing LAPACK and FFTW functionality brought in by the CPU version.

Along the way I have tried to separate out "host OpenMP" and "accelerator OpenMP" functionalities into separate CMake features, as I didn't want to affect the CPU build when switching off OpenMP for the GPU (actually also running on CPU) build. When this PR is working we should properly scrutinise how all the various features and builds interact.

Right now the host GPU backend is not working numerically, hence why this is still a draft. I'm almost there though... see this screenshot of the transformed spherical harmonic used in the benchmark case:

Screenshot 2025-08-05 at 11 19 12

It seems to be correct, except for some latitudes which have obvious error patterns. Really weird. Not sure what's going on there, but I will keep testing.

@samhatfield samhatfield added enhancement New feature or request gpu labels Aug 5, 2025
@samhatfield
Copy link
Collaborator Author

I forgot to mention why I'm doing this! The GPU code path has a number of data layout changes and general optimisations that we expect will improve also CPU performance. In the long term, we may therefore want to use this code path for operations instead of the "legacy" CPU version. But we need to do a proper side-by-side comparison first.

Also, this will be useful for debugging the behaviour of the GPU version when it's actually running on GPU.

@samhatfield
Copy link
Collaborator Author

The latest commit seems to fix the above error.

@samhatfield samhatfield force-pushed the host_side_gpu branch 2 times, most recently from 160ec9a to 2f44473 Compare August 12, 2025 12:17
No way we can have -DENABLE_OMPOFF=ON 😳
I don't think this works yet.
For some reason out-of-place FFTs give incorrect numbers but only for
(consistently) random latitudes, like lat 14. Why? No idea.
This allows one to reenable OpenMP directives when building the GPU host
backend. I am testing whether we can use the OpenMP target directives
also to accelerate host-side loops.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor enhancement New feature or request gpu
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant