[x265] [PATCH 2 of 7] threadpool.cpp: nicely populate detected NUMA node along with logical cores per node -> windows system fix
Pradeep Ramachandran
pradeep at multicorewareinc.com
Mon May 23 05:37:37 CEST 2016
On Fri, May 20, 2016 at 4:31 PM, <praveen at multicorewareinc.com> wrote:
> # 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
> + }
>
Looks like linux is still counting cpusPerNode[] by first asking for # CPUs
and then asking which NUMA node each CPU belongs to.
Can we move linux to also work similar to how windows is doing it - ask for
how many CPUs are there in each NUMA node? I think that is cleaner.
> +#elif
> + cpusPerNode[0] = getCpuCount();
> #endif
> - cpusPerNode[0]++;
> - }
>
> if (bNumaSupport && p->logLevel >= X265_LOG_DEBUG)
> for (int i = 0; i < numNumaNodes; i++)
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20160523/6a127028/attachment.html>
More information about the x265-devel
mailing list