<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 17, 2015 at 12:08 AM, Steve Borho <span dir="ltr"><<a href="mailto:steve@borho.org" target="_blank">steve@borho.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On 09/15, Pradeep Ramachandran wrote:<br>
> # HG changeset patch<br>
> # User Pradeep Ramachandran <<a href="mailto:pradeep@multicorewareinc.com">pradeep@multicorewareinc.com</a>><br>
> # Date 1442332345 -19800<br>
> # Tue Sep 15 21:22:25 2015 +0530<br>
> # Node ID a103f446053e9992b06e4b522e9fcab62d47ca68<br>
> # Parent 365f7ed4d89628d49cd6af8d81d4edc01f73ffad<br>
> bug: Making windows cpu mask 64-bits<br>
><br>
> diff -r 365f7ed4d896 -r a103f446053e source/common/threadpool.cpp<br>
> --- a/source/common/threadpool.cpp Tue Sep 08 16:38:01 2015 +0530<br>
> +++ b/source/common/threadpool.cpp Tue Sep 15 21:22:25 2015 +0530<br>
> @@ -473,7 +473,7 @@<br>
> void ThreadPool::setThreadNodeAffinity(void *numaMask)<br>
> {<br>
> #if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7<br>
> - if (SetThreadAffinityMask(GetCurrentThread(), (DWORD_PTR)(*((DWORD*)numaMask))))<br>
> + if (SetThreadAffinityMask(GetCurrentThread(), (DWORD_PTR)(*((DWORD64*)numaMask))))<br>
<br>
</span>why the casts at all, isn't this just (DWORD_PTR)numaMask? Or are there<br>
some crazy little endian pointer tricks being done here?<br>
<br>
btw: gotta love Windows data types.. DWORD64? really?</blockquote><div><br></div><div>:-)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class=""><br>
> return;<br>
> else<br>
> x265_log(NULL, X265_LOG_ERROR, "unable to set thread affinity for NUMA node mask\n");<br>
> diff -r 365f7ed4d896 -r a103f446053e source/common/threadpool.h<br>
> --- a/source/common/threadpool.h Tue Sep 08 16:38:01 2015 +0530<br>
> +++ b/source/common/threadpool.h Tue Sep 15 21:22:25 2015 +0530<br>
> @@ -85,7 +85,7 @@<br>
> int m_numWorkers;<br>
> void* m_numaMask; // node mask in linux, cpu mask in windows<br>
> #if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7<br>
> - DWORD m_winCpuMask;<br>
> + DWORD64 m_winCpuMask;<br>
<br>
</span>technically, we're copying bits from GROUP_AFFINITY.Mask, which is<br>
defined as type KAFFINITY, which appears to be a mirror for a kernel<br>
variable size. But SetThreadAffinityMask() wants a DWORD_PTR. Honestly,<br>
these win32 APIs are a mess.<br>
<br>
digging around and found this:<br>
<br>
<a href="http://stackoverflow.com/questions/20792975/what-is-the-replacement-for-undocumeneted-windows-kernel-api-kesetaffinitythre" rel="noreferrer" target="_blank">http://stackoverflow.com/questions/20792975/what-is-the-replacement-for-undocumeneted-windows-kernel-api-kesetaffinitythre</a><br>
<br>
which has no answers. The APIs you really want are only available to<br>
kernel space code.<br>
<br>
I also get the impression that if libx265 is compiled for 32bits,<br>
m_winCpuMask should be DWORD. IE: win64 SetThreadAffinityMask() is<br>
expecting the pointer to reference a DWORD64 but 32bit win32<br>
SetThreadAffinityMask() is expecting a DWORD32.<br></blockquote><div><br></div><div>Looks like DWORD_PTR and KAFFINITY are typedefed from ULONG_PTR. Scroll to DWORD_PTR in <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx">https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx</a></div><div>So moving m_winCpuMask to DWORD_PTR should work</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>
Hmm.. perhaps we should be using SetThreadGroupAffinity()<br></blockquote><div><br></div><div>But we're trying to set a mask as multiple numa nodes may be selected.</div><div><br></div><div>Pradeep.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class=""><font color="#888888"><br>
--<br>
Steve Borho<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>
</font></span></blockquote></div><br></div></div>