Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Call SetGlobalDefaultNumberOfThreads when processing "-threads" #1195

Merged
merged 1 commit into from
Jul 11, 2024

Conversation

N-Dekker
Copy link
Member

@N-Dekker N-Dekker commented Jul 11, 2024

It appears that SetGlobalMaximumNumberOfThreads may not affect the size of ITK's ThreadPool. The ThreadPool only uses "GlobalDefaultNumberOfThreads".


@Svdvoort This should at least partially address the multi-threading issues you reported

It appears that `SetGlobalMaximumNumberOfThreads` may not affect the size of ITK's ThreadPool. The ThreadPool only uses "GlobalDefaultNumberOfThreads".

- Related to ITK issue InsightSoftwareConsortium/ITK#4773 "GlobalDefaultNumberOfThreads should not be greater than GlobalMaximumNumberOfThreads"
@N-Dekker N-Dekker merged commit e3cafc5 into main Jul 11, 2024
7 of 8 checks passed
@N-Dekker N-Dekker deleted the SetGlobalDefaultNumberOfThreads-on-threads branch July 11, 2024 13:32
N-Dekker added a commit to N-Dekker/ITKElastix that referenced this pull request Jul 11, 2024
- Including pull request SuperElastix/elastix#1195
commit SuperElastix/elastix@e3cafc5
BUG: Call `SetGlobalDefaultNumberOfThreads` when processing "-threads"
@N-Dekker
Copy link
Member Author

N-Dekker commented Jul 11, 2024

For the record, on my LKEB/LUMC Windows 10 pc (6 cores, 12 logical processors), I tested the effect of the "-threads" command-line option within Visual Studio 2022, both before and after this pull request:

Before this pull request:

"-threads" command-line option actual number of threads
no such option 16
"-threads" 0 16
"-threads" 1 16
"-threads" 2 16
"-threads" 4 16

After this pull request:

"-threads" command-line option actual number of threads
no such option 16
"-threads" 0 5
"-threads" 1 5
"-threads" 2 6
"-threads" 4 8

These eight threads in the last row (from "-threads" 4) are the main thread, three Windows system threads, and four threads maintained by ITK's ThreadPool.

By the way, those three Windows system threads are there because of Windows 10 Parallel Loading: https://blogs.blackberry.com/en/2017/10/windows-10-parallel-loading-breakdown

@N-Dekker
Copy link
Member Author

@mstaring @stefanklein Please check that this is good enough: "-threads" 4 will create an ITK ThreadPool of (at most) 4 threads, but the executable may still have some other threads as well (e.g., a main thread, and a few "system threads".)

@stefanklein
Copy link
Member

stefanklein commented Jul 12, 2024 via email

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