Skip to content

win: new uv_available_parallelism returns double the expected threads in 32-bit applications #4524

@giordano

Description

@giordano

While #4521 seems to be working very well on 64-bit Windows (it passes all Julia tests, thanks!), on 32-bit Windows (technically it's a WoW64, I don't have access to a real 32-bit system) I'm getting weird results: uv_available_parallelism() seems to always return double the expected number of cores, see for example the failing tests at JuliaLang/julia#55592 (comment). For example I tested this on a 64-bit Windows GitHub-hosted Actions runner (using https://github.com/mxschmitt/action-tmate):

# julia.exe -e '@show @ccall uv_available_parallelism()::Cint; @show Sys.CPU_THREADS'
#= none:1 =# @ccall(uv_available_parallelism()::Cint) = 8
Sys.CPU_THREADS = 4

While the number of threads available in the system should be 4, uv_available_parallelism() returns 8.

Perhaps https://learn.microsoft.com/en-us/windows/win32/winprog64/processor-affinity is relevant?

32-bit Windows supports a maximum of 32 processors. Therefore, functions such as GetProcessAffinityMask simulate a computer with 32 processors when called under WOW64.

The affinity mask is obtained by performing a bitwise OR operation of the top 32 bits of the mask with the low 32 bits. Therefore, if a thread has affinity for processors 0, 1, and 32, WOW64 reports the affinity as 0 and 1, because processor 32 maps to processor 0. Functions that set processor affinity, such as SetThreadAffinityMask, restrict processors to the first 32 processors under WOW64.

  • Version: JuliaLang@c57e7f0
  • Platform:
    • OS: Windows (i686-w64-mingw32) (uname -a: MINGW64_NT-10.0-20348 fv-az1111-282 3.5.3-d8b21b8c.x86_64 2024-07-09 18:03 UTC x86_64 Msys)
    • CPU: 4 × AMD EPYC 7763 64-Core Processor
    • WORD_SIZE: 32

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions