Fix build parallelism on Windows with NUMA (#21278)
authorJan Vorlicek <janvorli@microsoft.com>
Thu, 29 Nov 2018 18:06:34 +0000 (19:06 +0100)
committerGitHub <noreply@github.com>
Thu, 29 Nov 2018 18:06:34 +0000 (19:06 +0100)
When multiple NUMA nodes are enabled on the machine where coreclr is
built, we incorrectly detect the number of cores that we use for build
parallelism of the native part of the build (NumberOfCores) as only
a number in the last NUMA node.
The reason is that the `wmic cpu get NumberOfCores /value` returns
multiple lines, one per each NUMA node.
This change fixes it by summing values from all the lines.

build.cmd

index 781ed9f..41ff53d 100644 (file)
--- a/build.cmd
+++ b/build.cmd
@@ -332,9 +332,11 @@ REM NumberOfCores is an WMI property providing number of physical cores on machi
 REM processor(s). It is used to set optimal level of CL parallelism during native build step
 if not defined NumberOfCores (
     REM Determine number of physical processor cores available on machine
+    set TotalNumberOfCores=0
     for /f "tokens=*" %%I in (
         'wmic cpu get NumberOfCores /value ^| find "=" 2^>NUL'
-    ) do set %%I
+    ) do set %%I & set /a TotalNumberOfCores=TotalNumberOfCores+NumberOfCores
+    set NumberOfCores=!TotalNumberOfCores!
 )
 echo %__MsgPrefix%Number of processor cores %NumberOfCores%