[x265] [PATCH] ThreadPool.cpp: fix getCpuCount function for windows systems

praveen at multicorewareinc.com praveen at multicorewareinc.com
Tue May 17 15:47:32 CEST 2016


# HG changeset patch
# User Praveen Tiwari <praveen at multicorewareinc.com>
# Date 1463492830 -19800
#      Tue May 17 19:17:10 2016 +0530
# Node ID cf3c2e0dce0997a499ae1d50fda6891cae83e685
# Parent  372fc5b12ed6003f8784702956ccf7203ea68a2e
ThreadPool.cpp: fix getCpuCount function for windows systems

diff -r 372fc5b12ed6 -r cf3c2e0dce09 source/common/threadpool.cpp
--- a/source/common/threadpool.cpp	Tue May 17 19:06:36 2016 +0530
+++ b/source/common/threadpool.cpp	Tue May 17 19:17:10 2016 +0530
@@ -545,9 +545,17 @@
 int ThreadPool::getCpuCount()
 {
 #if _WIN32
-    SYSTEM_INFO sysinfo;
-    GetSystemInfo(&sysinfo);
-    return sysinfo.dwNumberOfProcessors;
+    enum { MAX_NODE_NUM = 127 };
+    int cpus = 0;
+    int numNumaNodes = X265_MIN(getNumaNodeCount(), MAX_NODE_NUM);
+    PGROUP_AFFINITY groupAffinityPointer = new GROUP_AFFINITY;
+    for (int i = 0; i < numNumaNodes; i++)
+    {
+        GetNumaNodeProcessorMaskEx((UCHAR)i, groupAffinityPointer);
+        cpus += (int)bitCount(groupAffinityPointer->Mask);
+    }
+    delete groupAffinityPointer;
+    return cpus;
 #elif __unix__ && X265_ARCH_ARM
     /* Return the number of processors configured by OS. Because, most embedded linux distributions
      * uses only one processor as the scheduler doesn't have enough work to utilize all processors */


More information about the x265-devel mailing list