Skip to content

ENH: Add support for ITK SingleMultiThreader - #2590

Merged
blowekamp merged 1 commit into
SimpleITK:mainfrom
blowekamp:add-single-multithreader-support
May 19, 2026
Merged

blowekamp merged 1 commit into
SimpleITK:mainfrom
blowekamp:add-single-multithreader-support

Conversation

@blowekamp

Copy link
Copy Markdown
Member

Add support for the new itk::SingleMultiThreader introduced in ITK PR #6222.

Changes

  • sitkProcessObject.h — Updated SetGlobalDefaultThreader documentation to list "SINGLE" as an available threader option.
  • sitkProcessObject.cxx — Fixed pre-existing bug in SetGlobalDefaultThreader where the #if !defined(ITK_USE_TBB) guard was checking ThreaderEnum::Unknown instead of ThreaderEnum::TBB. No additional guard is needed for "SINGLE" since ThreaderTypeFromString on older ITK returns Unknown for unrecognized strings.
  • Testing/Unit/CMakeLists.txt — Added check_include_file_cxx detection for itkSingleMultiThreader.h and passes SITK_ITK_HAS_SINGLE_THREADER as a compile definition to sitkCommonTests.cxx.
  • Testing/Unit/sitkCommonTests.cxx — Added conditional test verifying SetGlobalDefaultThreader("SINGLE") works when available, or returns false when not.
  • Wrapping/Python/tests/sitkFlatStaticMethod.py — Added runtime test for "SINGLE" threader via SetGlobalDefaultThreader.

Notes

When built against an ITK with SingleMultiThreader, users can select it via:

sitk.ProcessObject.SetGlobalDefaultThreader("SINGLE")

or the environment variable ITK_GLOBAL_DEFAULT_THREADER=Single.

Copilot AI 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.

Pull request overview

Adds SimpleITK-level support and verification for the new ITK itk::SingleMultiThreader (“SINGLE”) global default threader option, while also correcting an existing guard bug around the “TBB” threader selection.

Changes:

  • Document "SINGLE" as a valid ProcessObject::SetGlobalDefaultThreader option.
  • Fix SetGlobalDefaultThreader validation to correctly reject TBB when ITK_USE_TBB is not enabled.
  • Add C++ and Python tests intended to validate "SINGLE" behavior when available.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Wrapping/Python/tests/sitkFlatStaticMethod.py Adds a runtime check for setting "SINGLE" via flat static methods.
Testing/Unit/sitkCommonTests.cxx Adds conditional unit test coverage for "SINGLE" (supported vs unsupported builds).
Testing/Unit/CMakeLists.txt Adds configure-time detection for itkSingleMultiThreader.h and conditionally defines a compile macro for the unit test.
Code/Common/src/sitkProcessObject.cxx Fixes the non-TBB build guard to check ThreaderEnum::TBB (instead of redundantly checking Unknown).
Code/Common/include/sitkProcessObject.h Updates API documentation to include "SINGLE" / itk::SingleMultiThreader.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +116 to +120
include(CheckIncludeFileCXX)
check_include_file_cxx(
"itkSingleMultiThreader.h"
SITK_ITK_HAS_SINGLE_THREADER
)
* - "POOL" itk::PoolMultiThreader
* - "TBB" itk::TBBThreader (optional)
* - "PLATFORM" itk::PlatformMultiThreader
* - "SINGLE" itk::SingleMultiThreader
Add support for the "SINGLE" multi-threader option introduced in
ITK PR #6222. The SingleMultiThreader executes all work synchronously
on the calling thread with zero thread-pool overhead, useful for
application-level parallelism scenarios.

Changes:
- Update SetGlobalDefaultThreader documentation to list "SINGLE"
- Fix existing bug: TBB guard was checking Unknown instead of TBB
- Add conditional test for Single threader in sitkCommonTests
- Add runtime check in Python flat static method test
@blowekamp
blowekamp force-pushed the add-single-multithreader-support branch from e6f7d78 to 27c920a Compare May 15, 2026 17:35
@blowekamp
blowekamp requested review from dave3d and zivy May 19, 2026 11:34
@blowekamp
blowekamp merged commit a6ecdd8 into SimpleITK:main May 19, 2026
10 checks passed
@blowekamp
blowekamp deleted the add-single-multithreader-support branch September 9, 2026 12:55
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.

4 participants