Skip to content

feat(hipfft): bind the hipFFT Xt API - #611

Merged
amontoison merged 4 commits into
developfrom
hipfft-xt
Oct 20, 2026
Merged

amontoison merged 4 commits into
developfrom
hipfft-xt

Conversation

@amontoison

@amontoison amontoison commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Binds the hipFFT Xt API in hipfort_hipfft, as plain bind(C) interfaces, regenerated from hipfftXt.h and hipfftMp.h (which include hipfft.h):

  • the multi-GPU descriptor API: hipfftXtSetGPUs, hipfftXtMalloc, hipfftXtMemcpy, hipfftXtFree, hipfftXtExecDescriptor{,C2C,R2C,C2R,Z2Z,D2Z,Z2D};
  • hipfftXtMakePlanMany, hipfftXtGetSizeMany and hipfftXtExec on hipDataType;
  • the callback routines (hipfftXtSetCallback, hipfftXtClearCallback, hipfftXtSetCallbackSharedSize, hipfftXtSetJITCallback);
  • the multi-process routines of hipfftMp.h: hipfftMpAttachComm, hipfftXtSetDistribution, hipfftXtSetSubformatDefault.

hipXtDesc and hipLibXtDesc are bind(C) derived types in a new hipfort_hipfft_types module; the Xt enums are in hipfort_hipfft_enums.

rocFFT and hipFFTW need no change: rocFFT has no Xt routines (its multi-GPU API, rocfft_field_* / rocfft_brick_*, is already bound), and hipfftw.h has no Xt API.

Notes

  • The hipfftMp.h routines need an MPI-enabled hipFFT. They are compiled only with HIPFFT_MPI_ENABLE, and the ROCm packages do not export them. A bind(C) interface adds no reference until a program calls it, so other programs link as before; the symbol test skips these three. hipfftMpAttachComm takes a pointer to a C MPI_Comm (build it with MPI_Comm_f2c), which hipFFT keeps, so it has to outlive the plan.
  • Descriptors are owned by hipFFT. Keep the type(c_ptr) that hipfftXtMalloc returns, c_f_pointer it to a type(hipLibXtDesc), pointer, and pass that pointer to hipfftXtExecDescriptor* / hipfftXtFree, never a copy of the type.
  • AMD limits, not binding limits: the descriptor routines require a plan over two or more GPUs, unbatched 1D is not implemented there, and a multi-GPU plan writes one work size per GPU (pass the first element of an array with one slot per GPU).
  • CUDA backend: the Xt and Mp routines are HIP-only (#ifndef USE_CUDA_NAMES), like every routine without a verified cufft twin.

Documentation

docs/tutorials/hipfft-examples.rst gains three sections: Xt plans on hipDataType, multi-GPU transforms (the descriptor workflow, ownership, one work size per GPU, the AMD limits, with the descriptor test as the example), and multi-process transforms with MPI (the C MPI_Comm helper and the lifetime rule).

Tests

  • hipfft_xt_makeplanmany_c: hipfftXtGetSizeMany + hipfftXtMakePlanMany + hipfftXtExec, batched C2C round trip on one GPU.
  • hipfft_xt_descriptor_z: 2D Z2Z round trip through XtSetGPUs / XtMalloc / XtMemcpy / XtExecDescriptorZ2Z / XtFree on two GPUs; it passes trivially with fewer than two.
  • test_hipfft (symbol test) links every new routine.

@amontoison
amontoison requested a review from a team as a code owner October 19, 2026 18:55
@amontoison
amontoison requested a review from Abuudiii October 19, 2026 19:37
@amontoison

amontoison commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator Author

@malcolmroberts Is it fine for you?

Regenerate hipfort_hipfft from hipfftXt.h instead of hipfft.h alone. The
module gains the 18 hipfftXt* routines as bind(C) interfaces: the
multi-GPU descriptor API (hipfftXtSetGPUs, hipfftXtMalloc, hipfftXtMemcpy,
hipfftXtFree, hipfftXtExecDescriptor*), hipfftXtMakePlanMany,
hipfftXtGetSizeMany and hipfftXtExec on hipDataType, and the callback
routines. hipXtDesc and hipLibXtDesc go in a new hipfort_hipfft_types
module, the Xt enums in hipfort_hipfft_enums. hipfftMp.h is not bound: its
routines exist only in a hipFFT built with HIPFFT_MPI_ENABLE. On the CUDA
backend the Xt routines stay out, like any routine without a verified
cufft twin.

Add two tests: hipfft_xt_makeplanmany_c runs an Xt plan on one GPU, and
hipfft_xt_descriptor_z does a 2D round trip through the descriptor API,
which hipFFT allows only on two or more GPUs (it passes trivially with
fewer). The symbol test links every new routine.
Regenerate hipfort_hipfft with hipfftMp.h as well: hipfftMpAttachComm,
hipfftXtSetDistribution and hipfftXtSetSubformatDefault, and the
HIPFFT_COMM_* constants. These routines exist only in a hipFFT built with
HIPFFT_MPI_ENABLE, which the ROCm packages are not; an interface adds no
reference until a program calls one, and the symbol test leaves them out.

Document the Xt API in the hipFFT examples: hipfftXtMakePlanMany on
hipDataType, the multi-GPU descriptor workflow (who owns the descriptor,
one work size per GPU, the AMD limits), and attaching an MPI communicator,
which takes a pointer to a C MPI_Comm that has to outlive the plan.
Doxygen cannot resolve ::hipfftXtMalloc, ::hipfftXtFree, ::hipLibXtDesc,
::hipfftXtMakePlanMany and ::hipfftXtSubFormat in the hipfort_hipfft
docstrings, which failed the Read the Docs build under WARN_AS_ERROR. The
generator now writes them as inline code, like the other unresolvable
targets.
rocfft_field_brick_z and hipfft_xt_descriptor_z need two visible GPUs.
Without them they stopped with status 0, so CTest counted them as passed
although they checked nothing, and the CI, which shows one GPU to each
test, never ran them. They now stop with 77 and declare SKIP_RETURN_CODE
77, so CTest reports them as skipped.

The two hipFFT Xt tests are also listed as ROCm-only: the Xt routines have
no cufftXt twin mapped yet, so they are not bound under USE_CUDA_NAMES.

@Abuudiii Abuudiii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested on 2 GPUs (gfx1201, ROCm 7.2.4): hipfft_xt_descriptor_z passes, and all 33 hipFFT tests pass.

@amontoison
amontoison merged commit 351259b into develop Oct 20, 2026
3 checks passed
@amontoison
amontoison deleted the hipfft-xt branch October 20, 2026 17:34
amontoison added a commit that referenced this pull request Oct 21, 2026
hipfort_hipfft_types (hipXtDesc, hipLibXtDesc) came with the hipFFT Xt
API (#611); the migration table lists it beside _enums, as it does for
hipFFTW and rocRAND.
amontoison added a commit that referenced this pull request Nov 3, 2026
hipfort_hipfft_types (hipXtDesc, hipLibXtDesc) came with the hipFFT Xt
API (#611); the migration table lists it beside _enums, as it does for
hipFFTW and rocRAND.
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.

2 participants