Skip to content

fix (perf/UX): get physical cores for Windows #1189

Closed
@jon-chuang

Description

@jon-chuang

Complete #934 with the windows impl of physical cores

The impl is approximately:

DWORD buffer_size = 0;
DWORD result = GetLogicalProcessorInformation(NULL, &buffer_size);
// assert result == FALSE && GetLastError() == ERROR_INSUFFICIENT_BUFFER
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION buffer = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION)malloc(buffer_size);
result = GetLogicalProcessorInformation(buffer, &buffer_size);
if (result != FALSE) {
    int num_physical_cores = 0;
    DWORD_PTR byte_offset = 0;
    while (byte_offset < buffer_size) {
        if (buffer->Relationship == RelationProcessorCore) {
            num_physical_cores++;
        }
        byte_offset += sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION);
        buffer++;
    }
    std::cout << "Number of physical cores: " << num_physical_cores << std::endl;
} else {
    std::cerr << "Error getting logical processor information: " << GetLastError() << std::endl;
}
free(buffer);

The location of the change is here: https://github.com/ggerganov/llama.cpp/blob/4a98a0f21ad63d97a643ba6fb21f613cb596cb23/examples/common.cpp#L57

Activity

added
enhancementNew feature or request
hardwareHardware related
windowsIssues specific to Windows
threadingParallel processing and thread management
on May 12, 2023
linked a pull request that will close this issueImplement get_num_physical_cores() for Windows #1278on May 12, 2023
github-actions

github-actions commented on Apr 9, 2024

@github-actions
Contributor

This issue was closed because it has been inactive for 14 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthardwareHardware relatedstalethreadingParallel processing and thread managementwindowsIssues specific to Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @sw@jon-chuang

      Issue actions

        fix (perf/UX): get physical cores for Windows · Issue #1189 · ggml-org/llama.cpp