Skip to content

COMP: Simplify CUDA backend wiring and adopt ITK-conformant formatting (follow-up to #77)#80

Merged
hjmjohnson merged 4 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:enh/vkfft-cuda-cleanup
Jun 8, 2026
Merged

COMP: Simplify CUDA backend wiring and adopt ITK-conformant formatting (follow-up to #77)#80
hjmjohnson merged 4 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:enh/vkfft-cuda-cleanup

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

Follow-up to the merged #77. Two themes: (1) simplify the CUDA backend wiring, and (2) adopt ITK-conformant formatting tooling. The CUDA changes were validated on real hardware (RTX 6000 Ada, CUDA 13.2): explicit VKFFT_BACKEND=1, auto-detect, and VKFFT_BACKEND=3 (OpenCL) each build and pass 36/36 tests.

CUDA backend simplification (commit 1)

itkVkCommon.cxx is host code — VkFFT JIT-compiles CUDA kernels at runtime via nvrtc — so the nvcc language apparatus was inert and is removed:

  • enable_language(CUDA) (also stops forcing the CUDA language onto the whole ITK build when this module is built in-tree),
  • a set_source_files_properties(... LANGUAGE CUDA) override that targeted a non-existent itkVkCommon.cpp,
  • the $<COMPILE_LANGUAGE:CUDA> gencode flags (never applied), and
  • CUDA separable compilation / device-symbol resolution (no CUDA-language sources).

The CUDA backend now builds as host C++ linking CUDA::cudart / CUDA::cuda_driver / nvrtc (the build drops the empty cmake_device_link step). Also: itk-module-init.cmake is now the single source of the VKFFT_BACKEND default (the duplicate set() in CMakeLists.txt is guarded), the Apple framework probe no longer leaks cache variables, and the cache help strings are aligned.

Formatting + tooling (commits 2–4)
  • New .gersemi.config (remote-module style, mirroring RTK) and all CMake/*.wrap files formatted with gersemi 0.19.3.
  • .clang-format already matches ITK; applied clang-format v19.1.7, black 24.2.0, pyupgrade, plus end-of-file / trailing-whitespace hygiene.
  • New .pre-commit-config.yaml modeled on RTK. Formatters are pinned to ITK's exact versions (gersemi 0.19.3, clang-format v19.1.7, black 24.2.0, pyupgrade v3.21.2) because their output is not stable across releases; the version-insensitive pre-commit-hooks track latest (v6.0.0).
Hardware validation (RTX 6000 Ada, CUDA 13.2)

Built as an external module against ITK main:

Config Result
explicit VKFFT_BACKEND=1 36/36
auto-detect (no flag → selects CUDA) 36/36
VKFFT_BACKEND=3 (OpenCL) 36/36

The fully-formatted final tree was re-validated: VKFFT_BACKEND=1 → 36/36.

Build the CUDA backend as host code. itkVkCommon.cxx contains no device
kernels (VkFFT JIT-compiles them at runtime via nvrtc), so the nvcc
language apparatus was inert and is removed: enable_language(CUDA), the
LANGUAGE CUDA override that targeted a nonexistent itkVkCommon.cpp, the
$<COMPILE_LANGUAGE:CUDA> gencode flags, and CUDA separable compilation.
Removing enable_language(CUDA) also avoids enabling the CUDA language
for the whole parent project when the module is built in the ITK tree.

Make itk-module-init.cmake the single source of the VKFFT_BACKEND
default by guarding the duplicate set() in CMakeLists.txt, unset the
temporary Apple framework probe cache entries, and align the cache help
string with the full backend list.

Validated on an RTX 6000 Ada (CUDA 13.2): explicit VKFFT_BACKEND=1,
auto-detect (selects CUDA), and VKFFT_BACKEND=3 (OpenCL) each build and
pass 36/36 VkFFTBackend tests.
Add a remote-module .gersemi.config matching ITK conventions (2-space
indent, 80-column line length, favour-expansion list style) and apply
gersemi 0.19.3 to every CMakeLists.txt, *.cmake, and *.wrap file.

Formatting only; no build-behavior change. Validated VKFFT_BACKEND=1
builds and passes 36/36 VkFFTBackend tests on CUDA hardware.
Run the ITK-pinned formatters over the tree: clang-format v19.1.7
(itkVkCommon.cxx), black 24.2.0 and pyupgrade on the Python files, and
the standard end-of-file / trailing-whitespace hygiene fixes.

Formatting only; VKFFT_BACKEND=1 builds and passes 36/36 VkFFTBackend
tests on CUDA hardware.
Pin the formatters to the exact versions ITK uses so CMake, C++, and
Python formatting stays byte-identical with upstream: gersemi 0.19.3,
clang-format v19.1.7, black 24.2.0, pyupgrade v3.21.2. gersemi and the
formatters are not stable across releases, so matching ITK's pins is
required to avoid reformatting churn against ITK CI.

The version-insensitive hygiene hooks (pre-commit-hooks) track their
latest release, v6.0.0.
@hjmjohnson hjmjohnson marked this pull request as ready for review June 8, 2026 18:20
@hjmjohnson hjmjohnson merged commit 20b86e4 into InsightSoftwareConsortium:main Jun 8, 2026
14 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.

2 participants