Repository navigation
CPU back-end: limit the threads with a sub-device instead of a PoCL extension - #841
Merged
Merged
Conversation
…xtension clSetCPUMaxComputeUnitsPOCL didn't make it upstream, and pocl_standalone_jll 7.2.2 drops it again. Instead, PoCL now only wakes up the worker threads of the sub-device a command targets (pocl/pocl#2371), so run kernels on a sub-device with as many compute units as Julia has threads. Its other threads stay asleep. A sub-device can't be larger than its device, so JULIA_KA_CPU_THREADS can no longer exceed the number of hardware threads; PoCL's variables still can. The precompilation workload sets those again, so that precompiling doesn't start a thread per core in every process.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #841 +/- ##
==========================================
- Coverage 79.34% 79.33% -0.01%
==========================================
Files 24 24
Lines 2091 2095 +4
==========================================
+ Hits 1659 1662 +3
- Misses 432 433 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
vchuravy
approved these changes
Oct 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#821 limits the CPU back-end to as many PoCL threads as Julia has, by calling
clSetCPUMaxComputeUnitsPOCL, an extension we carried in our PoCL builds. Upstream preferred making sub-devices usable over adding a global setting (pocl/pocl#2371), so the extension is gone again inpocl_standalone_jll7.2.2, and this PR uses a sub-device instead.A sub-device used to be just as slow as the whole device, because every command woke up all of PoCL's worker threads. pocl/pocl#2371 now only wakes the workers a command can use, on the sub-device it targets, and 7.2.2 includes that. So a sub-device sized to Julia's thread count behaves like the smaller thread pool the extension gave us. PoCL still starts a thread per hardware thread, but the ones outside the sub-device stay asleep and don't use CPU time.
Median saxpy launch time with
-t4on a 16-core/32-thread Ryzen 9950X:The behavior is the same as in #821, with one exception:
JULIA_KA_CPU_THREADScan no longer go above the number of hardware threads, since a sub-device can't be larger than its device. PoCL's own variables still can, as theCPUdocstring now says. If the device can't be partitioned (PoCL built with OpenMP, or thecpu-tbbdevice), the whole device is used.The precompilation workload sets PoCL's thread-count variables again, as before #821, so that precompiling doesn't start a thread per core in every process.
This requires
pocl_standalone_jll7.2.2 (JuliaPackaging/Yggdrasil#15005), so CI will fail until that's registered.The full test suite passes with
-t4against a local build of the 7.2.2 patch series.