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

Use 3D FFT transforms directly and drop the current 1D decomposition capable strategy #83

Merged
merged 13 commits into from
Apr 10, 2024

Conversation

semi-h
Copy link
Member

@semi-h semi-h commented Mar 29, 2024

We're moving away from doing our own FFTs using our specialist data structure to carry out 3D FFT transforms. The strategy CUDA backend implements prior to this PR was capable of being extended to 1D decomposition (already done earlier for the Thomas based approach), and as it was limited to 1D it was possible to take advantage of this for some optimisations. However, the distributed tridiagonal solver we have necessitates each slab/pencil to have certain amount of thickness, which limits a 1D decomposition strategy for going above 2k^3 ~ 4k^3 domain sizes.

This important shift in strategy was already mentioned in #32, and also #73.

The changes implemented up to so far includes switching from specialist data structure to cartesian data structure so that distributed FFT libraries can be used easily.

And currently, there is a bug in CUDA backend in poisson_fft that prevents running with different nx, ny, nz sizes. Possibly due to 3D FFT transform halving a dimension that is different than the current implementation assumes. Should be fixed soon as its not a big deal. Fixed.

Closes #73.

@semi-h semi-h marked this pull request as ready for review April 5, 2024 09:52
Copy link
Collaborator

@JamieJQuinn JamieJQuinn left a comment

Choose a reason for hiding this comment

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

Looks grand! I added a few suggestions for more informative error handling, and some organisational requests but I think this is ready to merge after those are done.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably a good time to start documenting this function. At the very least I think it needs a description of arguments and a reference for the calculation being carried out. I presume this will need @slaizet's input?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, could this file be renamed to something more descriptive? Suggestions:

  • spectral_transform.f90
  • spectral_processing.f90
  • poisson_solver.f90

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a description for a few arguments, and a reference too if someone wants more details. I need @slaizet's help with the remaining ones.

With the complex reorder functions gone, in this module we'll only carry out postprocessing in spectral space, so renaming is a good idea. I went with spectral_processing.f90.

src/cuda/poisson_fft.f90 Outdated Show resolved Hide resolved
src/cuda/poisson_fft.f90 Outdated Show resolved Hide resolved
src/cuda/poisson_fft.f90 Outdated Show resolved Hide resolved
src/cuda/poisson_fft.f90 Outdated Show resolved Hide resolved
c_dev(1:SZ, 1:self%nx, 1:(self%ny*(self%nz/2 + 1))/SZ) => self%c_y_dev
! tsize is different than SZ, because here we work on a 3D Cartesian
! data structure, and free to specify any suitable thread/block size.
tsize = 16
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this might be tuned later, can it be stored more publicly? E.g. as a parameter in common.f90. I'm worried this parameter will get forgotten later.

Copy link
Member Author

Choose a reason for hiding this comment

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

At the moment the only use case for this variable is here in the postprocessing, and for this specific kernel. GPU kernels are generally written considering the block and thread sizes, so I think its a good idea to define it here and use right after. For example, if we need to process a 3D Cartesian array its likely that we'll require a different thread size. The variable here works well because the kernel we have requires 3 separate 1D arrays with global size to carry out the operation, probably we won't need a similar operation anywhere else. If we observe use of this elsewhere then maybe we can move somewhere else later on.

@semi-h semi-h merged commit e911518 into xcompact3d:main Apr 10, 2024
2 checks passed
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.

Possible cleanup needed in cuda complex reorder kernels
2 participants