Skip to content

std::thread::available_parallelism() is wrong about Windows 11/Server 2022 #152389

Description

@nabijaczleweli

std::thread::available_parallelism() says

On Windows:

  • It may undercount the amount of parallelism available on systems with more than 64 logical CPUs. However, programs typically need specific support to take advantage of more than 64 logical CPUs, and in the absence of such support, the number returned by this function accurately reflects the number of logical CPUs the program can use by default.

and per https://learn.microsoft.com/en-us/windows/win32/procthread/processor-groups#behavior-starting-with-windows-11-and-windows-server-2022 this was true before Windows 11/Server 2022, but on these and subsequent systems processes are usefully scheduled across all CPUs by default.

The implementation uses GetSystemInfo().dwNumberOfProcessors. I think GetActiveProcessorCount(ALL_PROCESSOR_GROUPS) will return the same data at full range?

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-windowsOperating system: WindowsT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions