<div dir="ltr">Please ignore this sending updated patch. Thanks</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr">Regards,<div>Praveen</div></div></div></div>
<br><div class="gmail_quote">On Tue, May 17, 2016 at 8:01 PM, Pradeep Ramachandran <span dir="ltr"><<a href="mailto:pradeep@multicorewareinc.com" target="_blank">pradeep@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Tue, May 17, 2016 at 7:07 PM, <span dir="ltr"><<a href="mailto:praveen@multicorewareinc.com" target="_blank">praveen@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Praveen Tiwari <<a href="mailto:praveen@multicorewareinc.com" target="_blank">praveen@multicorewareinc.com</a>><br>
# Date 1463492196 -19800<br>
# Tue May 17 19:06:36 2016 +0530<br>
# Node ID 372fc5b12ed6003f8784702956ccf7203ea68a2e<br>
# Parent e5b5bdc3c154f908706fb75e006f9abf9b3de96f<br>
ThreadPool.cpp: fix core count for windows machines<br>
<br>
diff -r e5b5bdc3c154 -r 372fc5b12ed6 source/common/threadpool.cpp<br>
--- a/source/common/threadpool.cpp Sat May 14 07:29:46 2016 +0530<br>
+++ b/source/common/threadpool.cpp Tue May 17 19:06:36 2016 +0530<br>
@@ -27,6 +27,7 @@<br>
#include "threading.h"<br>
<br>
#include <new><br>
+#include <winnt.h><br>
<br>
#if X86_64<br>
<br>
@@ -64,6 +65,18 @@<br>
# define strcasecmp _stricmp<br>
#endif<br>
<br>
+uint64_t bitCount(uint64_t value)<br>
+{<br>
+ uint64_t count = 0;<br>
+ while (value > 0) // until all bits are zero<br>
+ {<br>
+ if ((value & 1) == 1) // check lower bit<br>
+ count++;<br>
+ value >>= 1; // shift bits, removing lower bit<br>
+ }<br>
+ return count;<br>
+}<br>
+<br>
namespace X265_NS {<br>
// x265 private namespace<br>
<br>
@@ -238,7 +251,6 @@<br>
memset(nodeMaskPerPool, 0, sizeof(nodeMaskPerPool));<br>
<br>
int numNumaNodes = X265_MIN(getNumaNodeCount(), MAX_NODE_NUM);<br>
- int cpuCount = getCpuCount();<br>
bool bNumaSupport = false;<br>
<br>
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7<br>
@@ -248,20 +260,28 @@<br>
#endif<br>
<br>
<br>
+#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7<br>
+ PGROUP_AFFINITY groupAffinityPointer = new GROUP_AFFINITY;<br>
+ for (int i = 0; i < numNumaNodes; i++)<br>
+ {<br>
+ GetNumaNodeProcessorMaskEx((UCHAR)i, groupAffinityPointer);<br>
+ cpusPerNode[i] = (int)bitCount(groupAffinityPointer->Mask);<br>
+ }<br>
+ delete groupAffinityPointer;<br>
+#elif HAVE_LIBNUMA<br>
+ int cpuCount = getCpuCount();<br></blockquote><div><br></div></div></div><div>Can we move to the cleaner implementation of not relying on CPU counts for non-windows platforms also?</div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
for (int i = 0; i < cpuCount; i++)<br>
{<br>
-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7<br>
- UCHAR node;<br>
- if (GetNumaProcessorNode((UCHAR)i, &node))<br>
- cpusPerNode[X265_MIN(node, (UCHAR)MAX_NODE_NUM)]++;<br>
- else<br>
-#elif HAVE_LIBNUMA<br>
if (bNumaSupport >= 0)<br>
cpusPerNode[X265_MIN(numa_node_of_cpu(i), MAX_NODE_NUM)]++;<br>
- else<br>
+ }<br>
+#elif<br>
+ int cpuCount = getCpuCount();<br>
+ for (int i = 0; i < cpuCount; i++)<br>
+ {<br>
+ cpusPerNode[0]++;<br>
+ }<br></blockquote><div><br></div></span><div>How about cpusPerNode[0] = getCpuCount() here? The for loop is unnecessary.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
#endif<br>
- cpusPerNode[0]++;<br>
- }<br>
<br>
if (bNumaSupport && p->logLevel >= X265_LOG_DEBUG)<br>
for (int i = 0; i < numNumaNodes; i++)<br></span>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br></div></div>
<br>_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
<br></blockquote></div><br></div>