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 get_num_physical_cores() #1436

Merged
merged 2 commits into from
May 15, 2023
Merged

Conversation

zrm
Copy link
Contributor

@zrm zrm commented May 13, 2023

had been broken on complex topologies because "cpu cores" in /proc/cpuinfo is per-"physical id"

had been broken on complex topologies because "cpu cores" in /proc/cpuinfo is per-"physical id"
Copy link
Member

@slaren slaren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't test it on a complex topology, but on my 9900k it still defaults to the number of physical cores (8), so this seems right.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

examples/common.cpp Outdated Show resolved Hide resolved
examples/common.cpp Outdated Show resolved Hide resolved
@slaren slaren merged commit 63d2046 into ggml-org:master May 15, 2023
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

siblings.insert(line);
}
}
if (siblings.size() > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]

Suggested change
if (siblings.size() > 0) {
if (!siblings.empty()) {
Additional context

/usr/include/c++/11/bits/unordered_set.h:298: method 'unordered_set'::empty() defined here

      empty() const noexcept
      ^

@zrm zrm deleted the get_num_physical_cores-fix branch May 15, 2023 23:19
// enumerate the set of thread siblings, num entries is num cores
std::unordered_set<std::string> siblings;
for (uint32_t cpu=0; cpu < UINT32_MAX; ++cpu) {
std::ifstream thread_siblings("/sys/devices/system/cpu"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be "/sys/devices/system/cpu/cpu" + std::to_string(cpu) + "/topology/thread_siblings") ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, do you want to open a PR with fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants