# HG changeset patch
# User Praveen Tiwari <[email protected]>
# 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 */
_______________________________________________
x265-devel mailing list
[email protected]
https://mailman.videolan.org/listinfo/x265-devel

Reply via email to