Repository navigation
WIP: ENH: Remove the in-tree OpenCL GPU modules and ITK_USE_GPU - #7284
hjmjohnson wants to merge 3 commits into
Conversation
2ba7ba0 to
0b9aa14
Compare
|
I am still mildly against removing now. Let's see what others think. Let's keep the PR open for at least a few weeks, so people have a chance to pitch in. |
GPUSmoothingRecursiveYvvGaussianImageFilter builds only with ITK_USE_GPU and derives from the ITKGPUCommon and ITKGPUSmoothing classes that ITK 6 removes. Drop it with its OpenCL kernel, GPU tests, and GPU branches in the shared test helpers. The CPU filters, their wrapping, and the tests a default build registers are unchanged.
ITKGPUCommon, ITKGPUFiniteDifference, ITKGPUImageFilterBase, ITKGPUAnisotropicSmoothing, ITKGPUSmoothing, ITKGPUThresholding, ITKGPURegistrationCommon, and ITKGPUPDEDeformableRegistration need OpenCL, which Apple deprecated in macOS 10.14, and no CI job builds them. ITK 6.0 beta deprecated them and took them out of the default build. Delete them with their tests, wrapping, and data manifest entries.
With the GPU modules gone, the ITK_USE_GPU option, CMake/itkOpenCL.cmake, the ITKGPU header-test gate, and the itkConfigure.h define configure nothing. Remove them, and fail configure when a cache still sets ITK_USE_GPU=ON. ITKConfig.cmake keeps ITK_USE_GPU set to OFF, because open_iA tests its value and errors when it is unset. The GPU kernel macros in itkMacro.h stay, because elastix builds its own OpenCL classes on them.
0b9aa14 to
3c895f9
Compare
|
Downstream status for the two projects that request these modules: ITK-SNAP barely uses the GPU.
elastix: confirmed,
|
|
No objections from ITK-SNAP -- I am not aware of anyone having ever built/used ITK-SNAP with ITK_USE_GPU=ON. |
SNAP_USE_GPU (off by default, unchanged since 2014) swapped the DiscreteGaussianImageFilter in edge preprocessing for ITK's OpenCL GPUDiscreteGaussianImageFilter. ITK 6 removes its OpenCL GPU modules (InsightSoftwareConsortium/ITK#7284), so standalone.cmake can no longer require ITKGPUCommon and ITKGPUSmoothing. With ITK 5.4 and ITK_USE_GPU off those modules build no library, so default builds see no change. Remove the option, its CPUImageToGPUImageFilter helper, and the GPU branches; the CPU edge preprocessing code is unchanged.
SimonRit
left a comment
There was a problem hiding this comment.
I personally have no objection, we are not using OpenCL. I intentionally intended to use it in place of CUDA when I started RTK in 2010 but ended up using CUDA only. RTKConsortium/ITKCudaCommon was initially heavily based on ITK's OpenCL module and diverged since. I tend to agree with @dzenanz on waiting for ITK v7 but I also understand that keeping code which no one uses seems pointless. Maybe the contributors to this module should be identified and asked for reviews?
Remove the eight in-tree OpenCL GPU modules, the OpenCL filter in
SmoothingRecursiveYvvGaussianFilter, and theITK_USE_GPUoption, completing #6075 (steps 2, 4, and 5). Closes #6075. #6106 already deprecated these modules and excluded them from the default build.Merge danger: one-way door for ITK 6 (about 18,700 lines deleted; a revert restores them). Blast radius: builds that set
ITK_USE_GPU=ONor requestITKGPU*components. Default builds are unaffected.WIP: waiting for downstream confirmation. A search of the ITK forest and GitHub found two products that request these modules:
CMake/standalone.cmakelistsITKGPUCommonandITKGPUSmoothingunderFIND_PACKAGE(ITK 5.4 REQUIRED COMPONENTS ...). After this change, configuring against ITK 6 fails until those two components are dropped, or requested only whenSNAP_USE_GPUis on.SNAP_USE_GPU=ONcan no longer be built against ITK 6, because it usesitkGPUImage.h,itkGPUKernelManager.h, anditkGPUDiscreteGaussianImageFilter.h. Is that acceptable for ITK-SNAP? The proposed change is COMP: Remove the optional OpenCL Gaussian blur and ITK GPU modules (ITK 6) pyushkevich/itksnap#330.ELASTIX_USE_OPENCL=ON, though, elastix still namesITKGPUCommonin two places: the top-levelfind_package(ITK ...)component list and theelastix_link_itk(elxOpenCL ...)module list inCommon/OpenCL/CMakeLists.txt. Those two lines must change.itkGPUKernelClassMacro, which elastix's OpenCL classes use, stays initkMacro.h. Is that OK for elastix? The proposed change is COMP: Stop requiring ITKGPUCommon for ELASTIX_USE_OPENCL (ITK 6) SuperElastix/elastix#1503. With it, and with COMP: Use std::atomic for the OpenCLVectorBase reference count SuperElastix/elastix#1504 (which replacesvcl_atomic_count, dropped from ITKmainin ENH: Update vendored VNL to the ITK-stripped numerics-only vxl (UpdateFromUpstream) #6421 independently of this PR),ELASTIX_USE_OPENCL=ONbuilds against this PR: 401 of 401 targets.Earlier objection: on #6107, @dzenanz asked to deprecate now and remove in ITK 7. This PR removes the modules in ITK 6. The deprecation (#6106) landed on
mainafter the 6.0b02 beta, so no release has shipped it yet; whether a 6.0 beta or RC carrying the deprecation is enough is a question for reviewers.Why remove rather than maintain
OpenCL itself is still a maintained Khronos standard: OpenCL 3.1 shipped in May 2026, and NVIDIA, Intel, Mesa Rusticl, and PoCL implementations pass its conformance tests. The case concerns ITK's modules and the platforms they target:
ITK_USE_GPU=ON, and GPU modules are listed as available even ifITK_USE_GPUisOFF#415, GPU memory leakage #1887, build itk with ITK_USE_CUFFTW ITK_USE_GPU ON gets error #3744, and GPU filters fail when invoked from Python #4846 were never fixed.Shape of the change
Kept:
itkGPUKernelClassMacro,itkGPUKernelMacro, anditkGetOpenCLSourceFromKernelMacroinitkMacro.h, which elastix's OpenCL classes use. Step 3 of #6075, an optional standalone archive of the modules, happens outside this repository.Evidence
Local, macOS arm64,
pixi run configure-ci(which enables SmoothingRecursiveYvvGaussianFilter) at3c895f9:ctest -R 'Yvv|SmoothingRecursiveYvvGaussianFilterHeaderTest': 7 of 7 tests pass.-DITK_USE_GPU=ONstops with "ITK_USE_GPU is no longer supported: ITK 6 removed the in-tree OpenCL GPU modules."find_package(ITK)followed by open_iA'sif (${ITK_USE_GPU} STREQUAL "OFF")check configures and seesOFF.pre-commit run --all-filespasses.Downstream search (tracked files of 329 forest repositories, plus GitHub code search):
REQUIRED COMPONENTS ITKGPUCommon ITKGPUSmoothing: configure fails, so ITK-SNAP needs a changeELASTIX_USE_OPENCL=ONis affected: dropITKGPUCommonfrom two CMake listsITKUltrasound_USE_clFFToption (off by default) can no longer be usedITK_USE_GPU=OFFis keptREQUIRED, so they are skippedForest build (ITK with Python wrapping and remote modules, plus elastix, default options) at
0b9aa14, compared with the itk-main forest:itkPyBufferMemoryLeakTestfailed once in the parallel run; run alone it passed 3 of 3. The test checks peak-RSS growth against a roughly 1 MB threshold. The other failures are the same Python and disabled tests as on main.Not tested: a Windows build.
AI assistance
Claude Code (Opus 5.5) carried out the removal, the downstream search, and the local build and tests, under Hans Johnson's direction and review.