[PATCH] D78324: [Support][X86] Change getHostNumPhsicalCores() to return number of physical cores enabled by affinity

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 16 14:31:37 PDT 2020


MaskRay added inline comments.


================
Comment at: llvm/lib/Support/Host.cpp:1303
   int CurCoreId = -1;
   SmallSet<std::pair<int, int>, 32> UniqueItems;
+  for (StringRef Line : strs) {
----------------
aganea wrote:
> Since you're here, it seems really overkill to use a Set to represent a bitfield (also, this will allocate if processors > 32). Can we have `cpu_set_t Enabled` here instead, and use `CPU_COUNT(Enabled)` at the end?
The idea is that different processor ids may share the same `(physical id, core id)` pair, so we need to count the number of unique `(physical id, core id)` pair.

We arbitrarily define it as: if one processor id is allowed by the CPU affinity mask, consider its (physical id, core id) available.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78324/new/

https://reviews.llvm.org/D78324





More information about the llvm-commits mailing list