Repository navigation
Conversation
With POCL_AFFINITY=1, thread i was pinned to CPU i. That ignores the CPUs the process may run on: under taskset -c 32-63, the threads ran on CPUs 0 and up anyway, and in a cpuset without CPU i, pinning fails. It also puts a subdevice of the first N threads on the first N CPUs, which are typically all on one NUMA node: on 2x EPYC 7502, a 32-thread subdevice ran SAXPY at 123 GB/s, the bandwidth of a single node. And it pinned through td->thread, which the creating thread may not have set yet. Pin the threads to the CPUs that the process's threads may run on (the union of their affinity masks, which includes the CPUs of applications that pin their own threads), one per core first, round-robin over the NUMA nodes, so that any number of first threads is spread evenly. The 32-thread subdevice now reaches 158 GB/s, like OpenMP threads spread over both nodes. With the static schedule, threads that run out of work-groups now also take them from threads on the same node first.
This was referenced Oct 26, 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.
Stacked on #7.
POCL_AFFINITY=1pinned thread i to CPU i. That causes three problems:taskset -c 32-63the threads ran on CPUs 0 and up anyway, and in a cpuset without CPU i pinning fails.td->thread, which the creating thread may not have set yet.This PR instead pins the threads to the CPUs that the process's threads may run on, i.e. the union of their affinity masks. That respects
tasksetand cpusets, and includes the CPUs of applications that pin their own threads before using PoCL. The first threads get a core of their own, round-robin over the NUMA nodes, so any number of first threads is spread evenly. The 32-thread subdevice now reaches 158 GB/s, the same as OpenMP threads spread over both nodes.With the static schedule, threads that run out of work-groups now take them from threads on the same NUMA node first.
Pinning stays opt-in, since PoCL can't know whether other processes or runtimes use the same CPUs.