[PATCH] D25564: Add interface to compute number of physical cores on host system

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 13 08:24:35 PDT 2016


tejohnson created this revision.
tejohnson added a reviewer: mehdi_amini.
tejohnson added a subscriber: llvm-commits.
Herald added subscribers: modocache, mgorny, beanz.

For now I have only added support for x86_64 Linux, but other systems
can be added incrementally.

This is to be used for setting the default parallelism for ThinLTO
backends (instead of thread::hardware_concurrency which includes
hyperthreading and is too aggressive). I'll send this as a follow-on
patch, and it will fall back to hardware_concurrency when the new
getHostNumPhysicalCores returns -1 (when not supported for a given
host system).

I also added an interface to MemoryBuffer to force reading a file
as a stream - this is required for /proc/cpuinfo which is a special
file that looks like a normal file but appears to have 0 size.
The existing readers of this file in Host.cpp are reading the first
1024 or so bytes from it, because the necessary info is near the top.
But for the new functionality we need to be able to read the entire
file. I can go back and change the other readers to use the new
getFileAsStream as a follow-on patch since it seems much more robust.

Added a unittest.


https://reviews.llvm.org/D25564

Files:
  include/llvm/Support/Host.h
  include/llvm/Support/MemoryBuffer.h
  lib/Support/Host.cpp
  lib/Support/MemoryBuffer.cpp
  unittests/Support/CMakeLists.txt
  unittests/Support/Host.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25564.74526.patch
Type: text/x-patch
Size: 6981 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161013/42e3d1c6/attachment.bin>


More information about the llvm-commits mailing list