[x265] [PATCH] ThreadPool.cpp: fix core count for windows machines

Praveen Tiwari praveen at multicorewareinc.com
Fri May 20 12:57:59 CEST 2016


Please  ignore this sending updated patch. Thanks

Regards,
Praveen

On Tue, May 17, 2016 at 8:01 PM, Pradeep Ramachandran <
pradeep at multicorewareinc.com> wrote:

>
> On Tue, May 17, 2016 at 7:07 PM, <praveen at multicorewareinc.com> wrote:
>
>> # HG changeset patch
>> # User Praveen Tiwari <praveen at multicorewareinc.com>
>> # Date 1463492196 -19800
>> #      Tue May 17 19:06:36 2016 +0530
>> # Node ID 372fc5b12ed6003f8784702956ccf7203ea68a2e
>> # Parent  e5b5bdc3c154f908706fb75e006f9abf9b3de96f
>> ThreadPool.cpp: fix core count for windows machines
>>
>> diff -r e5b5bdc3c154 -r 372fc5b12ed6 source/common/threadpool.cpp
>> --- a/source/common/threadpool.cpp      Sat May 14 07:29:46 2016 +0530
>> +++ b/source/common/threadpool.cpp      Tue May 17 19:06:36 2016 +0530
>> @@ -27,6 +27,7 @@
>>  #include "threading.h"
>>
>>  #include <new>
>> +#include <winnt.h>
>>
>>  #if X86_64
>>
>> @@ -64,6 +65,18 @@
>>  # define strcasecmp _stricmp
>>  #endif
>>
>> +uint64_t bitCount(uint64_t value)
>> +{
>> +    uint64_t count = 0;
>> +    while (value > 0)             // until all bits are zero
>> +    {
>> +        if ((value & 1) == 1)     // check lower bit
>> +            count++;
>> +        value >>= 1;              // shift bits, removing lower bit
>> +    }
>> +    return count;
>> +}
>> +
>>  namespace X265_NS {
>>  // x265 private namespace
>>
>> @@ -238,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
>> @@ -248,20 +260,28 @@
>>  #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] = (int)bitCount(groupAffinityPointer->Mask);
>> +    }
>> +    delete groupAffinityPointer;
>> +#elif HAVE_LIBNUMA
>> +    int cpuCount = getCpuCount();
>>
>
> Can we move to the cleaner implementation of not relying on CPU counts for
> non-windows platforms also?
>
>
>>      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
>> +    int cpuCount = getCpuCount();
>> +    for (int i = 0; i < cpuCount; i++)
>> +    {
>> +        cpusPerNode[0]++;
>> +    }
>>
>
> How about cpusPerNode[0] = getCpuCount() here? The for loop is unnecessary.
>
>
>>  #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
>>
>
>
> _______________________________________________
> 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/20160520/7d58b9b6/attachment.html>


More information about the x265-devel mailing list