www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Thread affinity?

reply "Rob T" <alanb ucora.com> writes:
In core.thread I don't see a portable way to pin a thread to a 
specific core, or at least pin the thread to whatever core it is 
currently running in.

I found this solution, but it's for Windows only.

http://www.gamedev.net/blog/1140/entry-2254424-setting-thread-affinity-on-windows-in-d/

I can find solutions for pthread coded in C/C++, but I'm not sure 
how to apply these solutions when using the D Thread class. I may 
be able hack something out, but I need to be sure it's safe and 
correct.

http://stackoverflow.com/questions/1407786/how-to-set-cpu-affinity-of-a-particular-pthread

Any help is appreciated.

--rt
Dec 03 2013
parent reply "qznc" <qznc web.de> writes:
On Tuesday, 3 December 2013 at 17:10:07 UTC, Rob T wrote:
 In core.thread I don't see a portable way to pin a thread to a 
 specific core, or at least pin the thread to whatever core it 
 is currently running in.

 I found this solution, but it's for Windows only.

 http://www.gamedev.net/blog/1140/entry-2254424-setting-thread-affinity-on-windows-in-d/

 I can find solutions for pthread coded in C/C++, but I'm not 
 sure how to apply these solutions when using the D Thread 
 class. I may be able hack something out, but I need to be sure 
 it's safe and correct.

 http://stackoverflow.com/questions/1407786/how-to-set-cpu-affinity-of-a-particular-pthread

 Any help is appreciated.
You should file an issue [0] as this should actually be in core.thread. [0] https://d.puremagic.com/issues/enter_bug.cgi
Dec 04 2013
parent "Rob T" <alanb ucora.com> writes:
On Wednesday, 4 December 2013 at 08:38:12 UTC, qznc wrote:
 You should file an issue [0] as this should actually be in 
 core.thread.

 [0] https://d.puremagic.com/issues/enter_bug.cgi
I filed an enhancement request for the thread module. Digging deeper, I notice that module core.sys.posix.pthread is missing the affinity related functions, so I'll file that as a bug. --rt
Dec 04 2013