SuperElastix / elastix

Official elastix repository
http://elastix.dev
Apache License 2.0
481 stars 116 forks source link

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

Closed N-Dekker closed 4 months ago

N-Dekker commented 4 months ago

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

N-Dekker commented 4 months ago

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 commented 4 months ago

@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 commented 4 months ago

No strong opinion, sounds reasonable to me Stefan

Van: Niels Dekker @.> Verzonden: vrijdag 12 juli 2024 16:43 Aan: SuperElastix/elastix @.> CC: Stefan Klein @.>; Mention @.> Onderwerp: Re: [SuperElastix/elastix] BUG: Call SetGlobalDefaultNumberOfThreads when processing "-threads" (PR #1195)

Waarschuwing: Deze e-mail is afkomstig van buiten de organisatie. Klik niet op links en open geen bijlagen, tenzij u de afzender herkent en weet dat de inhoud veilig is. Caution: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

@mstaringhttps://github.com/mstaring @stefankleinhttps://github.com/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".)

- Reply to this email directly, view it on GitHubhttps://github.com/SuperElastix/elastix/pull/1195#issuecomment-2225742486, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAF2LNLHUBV7TGNAKGMHMS3ZL7TNPAVCNFSM6AAAAABKW74KJWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRVG42DENBYGY. You are receiving this because you were mentioned.Message ID: @.**@.>>