Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jon-chuang opened this issue Apr 26, 2023 · 1 comment · May be fixed by #1278
Closed

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

jon-chuang opened this issue Apr 26, 2023 · 1 comment · May be fixed by #1278
Labels
enhancement New feature or request hardware Hardware related stale threading Parallel processing and thread management windows Issues specific to Windows

Comments

@jon-chuang
Copy link
Contributor

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

@sw sw added enhancement New feature or request hardware Hardware related windows Issues specific to Windows threading Parallel processing and thread management labels May 12, 2023
@sw sw linked a pull request May 12, 2023 that will close this issue
@github-actions github-actions bot added the stale label Mar 25, 2024
Copy link
Contributor

github-actions bot commented Apr 9, 2024

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
Labels
enhancement New feature or request hardware Hardware related stale threading Parallel processing and thread management windows Issues specific to Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants