[x265] [PATCH 2 of 7] threadpool.cpp: nicely populate detected NUMA node along with logical cores per node -> windows system fix

praveen at multicorewareinc.com praveen at multicorewareinc.com
Fri May 20 13:01:55 CEST 2016


# HG changeset patch
# User Praveen Tiwari <praveen at multicorewareinc.com>
# Date 1463738737 -19800
#      Fri May 20 15:35:37 2016 +0530
# Node ID e988eee2f0dc962b9b94c8cef6f739522bce9afb
# Parent  9a6ab28b736e1167ac26977d7da8ab2d23cc296f
threadpool.cpp: nicely populate detected NUMA node along with logical cores per node -> windows system fix

diff -r 9a6ab28b736e -r e988eee2f0dc source/common/threadpool.cpp
--- a/source/common/threadpool.cpp	Thu May 19 16:27:58 2016 +0530
+++ b/source/common/threadpool.cpp	Fri May 20 15:35:37 2016 +0530
@@ -251,7 +251,6 @@
     memset(nodeMaskPerPool, 0, sizeof(nodeMaskPerPool));
 
     int numNumaNodes = X265_MIN(getNumaNodeCount(), MAX_NODE_NUM);
-    int cpuCount = getCpuCount();
     bool bNumaSupport = false;
 
 #if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7 
@@ -261,20 +260,24 @@
 #endif
 
 
+#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7
+    PGROUP_AFFINITY groupAffinityPointer = new GROUP_AFFINITY;
+    for (int i = 0; i < numNumaNodes; i++)
+    {
+        GetNumaNodeProcessorMaskEx((UCHAR)i, groupAffinityPointer);
+        cpusPerNode[i] = popCount(groupAffinityPointer->Mask);
+    }
+    delete groupAffinityPointer;
+#elif HAVE_LIBNUMA
+    int cpuCount = getCpuCount();
     for (int i = 0; i < cpuCount; i++)
     {
-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7 
-        UCHAR node;
-        if (GetNumaProcessorNode((UCHAR)i, &node))
-            cpusPerNode[X265_MIN(node, (UCHAR)MAX_NODE_NUM)]++;
-        else
-#elif HAVE_LIBNUMA
         if (bNumaSupport >= 0)
             cpusPerNode[X265_MIN(numa_node_of_cpu(i), MAX_NODE_NUM)]++;
-        else
+    }
+#elif
+    cpusPerNode[0] = getCpuCount();
 #endif
-            cpusPerNode[0]++;
-    }
 
     if (bNumaSupport && p->logLevel >= X265_LOG_DEBUG)
         for (int i = 0; i < numNumaNodes; i++)


More information about the x265-devel mailing list