ENH: Modernize CUDA wiring and auto-detect default VKFFT backend#77
Merged
hjmjohnson merged 1 commit intoJun 8, 2026
Conversation
432a074 to
d85fd0a
Compare
* itk-module-init.cmake: replace removed find_package(CUDA) with enable_language(CUDA) + find_package(CUDAToolkit). Auto-pick a default VKFFT_BACKEND when not set: CUDA if a CUDA compiler is found, Metal if the Apple Metal/Foundation/QuartzCore frameworks probe successfully, otherwise OpenCL. * itk-module-init.cmake: handle VKFFT_BACKEND=5 (Metal) by locating the required Apple frameworks early. * src/CMakeLists.txt: link CUDA::cuda_driver instead of the bare 'cuda' name so conda/cross toolchains that do not search /usr/lib/x86_64-linux-gnu resolve libcuda. * CMakeLists.txt: pull the vendored VkFFT sources with EXCLUDE_FROM_ALL so the upstream VkFFT_TestSuite benchmark (which hard-requires CL/cl.h and vulkan/vulkan.h) is not built unless explicitly requested. Assisted-by: Claude Code (claude-opus-4-7) -- CMake modernization and Metal auto-detect branch.
d85fd0a to
d9a6036
Compare
dzenanz
approved these changes
Jun 8, 2026
dzenanz
left a comment
Member
There was a problem hiding this comment.
Mostly looks good on a glance.
hjmjohnson
added a commit
that referenced
this pull request
Jun 8, 2026
COMP: Simplify CUDA backend wiring and adopt ITK-conformant formatting (follow-up to #77)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Modernize CUDA wiring and add auto-detection of a sensible default VKFFT backend (CUDA → Metal → OpenCL). Verified locally with
VKFFT_BACKEND=1against ITK main on Linux + CUDA 13.2 (RTX 6000 Ada).What changed
itk-module-init.cmakefind_package(CUDA)(legacy module dropped in CMake 4.0+) withenable_language(CUDA)+find_package(CUDAToolkit).CUDA_LIBRARIESnow resolves toCUDA::cudart;CUDA_NVRTC_LIBis searched underCUDAToolkit_LIBRARY_DIR.VKFFT_BACKENDwhen the user has not set one: CUDA (1) ifcheck_language(CUDA)finds a working compiler, Metal (5) on Apple if theMetal/Foundation/QuartzCoreframeworks probe successfully, otherwise OpenCL (3).VKFFT_BACKEND=5(Metal): error out cleanly on non-Apple platforms; find the Metal/Foundation/QuartzCore frameworks here so they are available before the consumer-facing CMakeLists runs.src/CMakeLists.txtCUDA::cuda_driverinstead of barecuda. The bare name expands to-lcuda, which conda / cross toolchains using a private sysroot do not find (their linker does not search/usr/lib/x86_64-linux-gnu). The imported target carries the absolute path.CMakeLists.txtFetchContent_MakeAvailable(vkfft_lib)with manualFetchContent_Populate+add_subdirectory(... EXCLUDE_FROM_ALL). This keeps theVkFFT/halfinterface targets thatVkFFTBackendlinks against, but excludes the upstreamVkFFT_TestSuitebenchmark executable — which hard-requiresCL/cl.handvulkan/vulkan.heven when only the CUDA path is being built.Local validation
Built against ITK main on Linux x86_64 with CUDA 13.2:
Tested:
VKFFT_BACKEND=1(CUDA) — explicit, builds and links.-DVKFFT_BACKEND— auto-detect picks CUDA on this host.Not tested locally:
VKFFT_BACKEND=5(Metal) — no Apple hardware in this session.VKFFT_BACKEND=3(OpenCL) — unchanged path, regression risk low.Assisted-by: Claude Code (claude-opus-4-7) -- CMake modernization and Metal auto-detect branch.