Skip to content

WIP: ENH: Remove the in-tree OpenCL GPU modules and ITK_USE_GPU - #7284

Draft
hjmjohnson wants to merge 3 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:enh-remove-opencl-gpu-modules
Draft

hjmjohnson wants to merge 3 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:enh-remove-opencl-gpu-modules

Conversation

@hjmjohnson

@hjmjohnson hjmjohnson commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Remove the eight in-tree OpenCL GPU modules, the OpenCL filter in SmoothingRecursiveYvvGaussianFilter, and the ITK_USE_GPU option, 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=ON or request ITKGPU* 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:

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 main after 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:

Shape of the change
60f1b48 ENH: Remove the OpenCL filter from SmoothingRecursiveYvvGaussianFilter
  - GPUSmoothingRecursiveYvvGaussianImageFilter.{h,hxx}, its .cl kernel, src/
  - GPU tests, and the #ifdef GPU branches of the shared test helpers (unifdef -UGPU)
c45ff08 ENH: Remove the in-tree OpenCL GPU modules
  - Modules/Core/{GPUCommon,GPUFiniteDifference}
  - Modules/Filtering/{GPUImageFilterBase,GPUAnisotropicSmoothing,GPUSmoothing,GPUThresholding}
  - Modules/Registration/{GPUCommon,GPUPDEDeformable}
  - their content-links.manifest entries and one Python exclude-filters entry
3c895f9 ENH: Remove ITK_USE_GPU and the OpenCL build support
  - CMakeLists.txt: the option is gone; configure fails if a cache still sets ITK_USE_GPU=ON
  - CMake/itkOpenCL.cmake deleted; the ITKGPU header-test gate removed
  - itkConfigure.h no longer defines ITK_USE_GPU
  - ITKConfig.cmake still sets ITK_USE_GPU to OFF (open_iA's `if (${ITK_USE_GPU} STREQUAL "OFF")` errors when it is unset)
  + migration record 20261201_RemoveOpenCLGPUModules.yaml

Kept: itkGPUKernelClassMacro, itkGPUKernelMacro, and itkGetOpenCLSourceFromKernelMacro in itkMacro.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) at 3c895f9:

  • Full build: 9,244 targets, 0 errors. The only warnings (7) come from the fetched proxTV sources, which this PR does not touch.
  • ctest -R 'Yvv|SmoothingRecursiveYvvGaussianFilterHeaderTest': 7 of 7 tests pass.
  • Configuring with -DITK_USE_GPU=ON stops with "ITK_USE_GPU is no longer supported: ITK 6 removed the in-tree OpenCL GPU modules."
  • A consumer running find_package(ITK) followed by open_iA's if (${ITK_USE_GPU} STREQUAL "OFF") check configures and sees OFF.
  • pre-commit run --all-files passes.

Downstream search (tracked files of 329 forest repositories, plus GitHub code search):

Project Effect
ITK-SNAP REQUIRED COMPONENTS ITKGPUCommon ITKGPUSmoothing: configure fails, so ITK-SNAP needs a change
elastix Only ELASTIX_USE_OPENCL=ON is affected: drop ITKGPUCommon from two CMake lists
ITKUltrasound The ITKUltrasound_USE_clFFT option (off by default) can no longer be used
open_iA Its GPU smoothing component is skipped; its configure check still works because ITK_USE_GPU=OFF is kept
OTB Lists GPU components without REQUIRED, so they are skipped
ANTs, BRAINSTools, SimpleITK, RTK, Slicer and 250 extensions, MITK, TubeTK, and the rest No references

Forest build (ITK with Python wrapping and remote modules, plus elastix, default options) at 0b9aa14, compared with the itk-main forest:

  • ITK: 6,998 tests, no new failures. itkPyBufferMemoryLeakTest failed 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.
  • elastix: 164 tests, the same 4 failures 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.

@github-actions github-actions Bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots area:Python wrapping Python bindings for a class type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:Registration Issues affecting the Registration module type:Data Changes to testing data area:Documentation Issues affecting the Documentation module labels Dec 1, 2026
@hjmjohnson
hjmjohnson force-pushed the enh-remove-opencl-gpu-modules branch from 2ba7ba0 to 0b9aa14 Compare December 1, 2026 17:32
@dzenanz
dzenanz requested a review from SimonRit December 1, 2026 17:38
@dzenanz

dzenanz commented Dec 1, 2026

Copy link
Copy Markdown
Member

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.
@hjmjohnson

Copy link
Copy Markdown
Member Author

Downstream status for the two projects that request these modules:

ITK-SNAP barely uses the GPU. SNAP_USE_GPU, off by default, swaps one Gaussian blur in the active-contour edge preprocessing for ITK's OpenCL version.

elastix: confirmed, ITKGPUCommon is required but not used. elastix requires ITK_USE_GPU=OFF, in which case ITKGPUCommon builds no library. elastix carries its own copy of every ITK GPU header it includes.

@pyushkevich

Copy link
Copy Markdown

No objections from ITK-SNAP -- I am not aware of anyone having ever built/used ITK-SNAP with ITK_USE_GPU=ON.

pyushkevich pushed a commit to pyushkevich/itksnap that referenced this pull request Dec 1, 2026
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 SimonRit left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Core Issues affecting the Core module area:Documentation Issues affecting the Documentation module area:Filtering Issues affecting the Filtering module area:Python wrapping Python bindings for a class area:Registration Issues affecting the Registration module type:Data Changes to testing data type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: Drop OpenGL/OpenCL GPU modules in ITK 6

4 participants