What do you do with NUMA?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: What do you do with NUMA?

Post by syzygy »

You need to detect HT and it is quite trivial.
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: What do you do with NUMA?

Post by mcostalba »

syzygy wrote:You need to detect HT and it is quite trivial.
:-) Ok, care to provide some working code or for you was just enough to make me smile?
mar
Posts: 2555
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: What do you do with NUMA?

Post by mar »

:-) Ok, care to provide some working code or for you was just enough to make me smile?
it's bit 28 in edx (feature bits) in cpuid after eax=1
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: What do you do with NUMA?

Post by mcostalba »

mar wrote:
:-) Ok, care to provide some working code or for you was just enough to make me smile?
it's bit 28 in edx (feature bits) in cpuid after eax=1
Is not so simple:

https://software.intel.com/en-us/forums ... pic/294575
http://wiki.osdev.org/Detecting_CPU_Topology_(80x86)
http://stackoverflow.com/questions/7274 ... ed-core-id
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: What do you do with NUMA?

Post by mcostalba »

mcostalba wrote: Is not so simple:
I explain better, our aim is to set the thread affinity to different physical cores, so I need to know if CPUX is on a different core than CPUY
mar
Posts: 2555
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: What do you do with NUMA?

Post by mar »

mcostalba wrote:
mcostalba wrote: Is not so simple:
I explain better, our aim is to set the thread affinity to different physical cores, so I need to know if CPUX is on a different core than CPUY
I see, I thought you only need to detect HT.

Aren't the logical cores interleaved? Like each two logical cores are 1 physical (at least affinity on Windows seems to work this way, also mentioned in one othe links you sent)
This assumption might not hold in the future though...
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: What do you do with NUMA?

Post by syzygy »

mcostalba wrote:
syzygy wrote:You need to detect HT and it is quite trivial.
:-) Ok, care to provide some working code or for you was just enough to make me smile?
Thanks for biting. The numa patch already does it.
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: What do you do with NUMA?

Post by mcostalba »

bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: What do you do with NUMA?

Post by bob »

mcostalba wrote:
mar wrote:
:-) Ok, care to provide some working code or for you was just enough to make me smile?
it's bit 28 in edx (feature bits) in cpuid after eax=1
Is not so simple:

https://software.intel.com/en-us/forums ... pic/294575
http://wiki.osdev.org/Detecting_CPU_Topology_(80x86)
http://stackoverflow.com/questions/7274 ... ed-core-id
I side with Marco here. There are TWO issues:

(1) is hyper threading in use? This is trivial with CPUID

(2) which processor numbers share a physical core. This is NOT so trivial as it has changed multiple times over the past 10 years. I spent a lot of time on this and finally said "hell with it..." I ended up making my thread affinity user-controllable so that I can tell it which processor IDs are REAL cores...
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: What do you do with NUMA?

Post by bob »

mar wrote:
mcostalba wrote:
mcostalba wrote: Is not so simple:
I explain better, our aim is to set the thread affinity to different physical cores, so I need to know if CPUX is on a different core than CPUY
I see, I thought you only need to detect HT.

Aren't the logical cores interleaved? Like each two logical cores are 1 physical (at least affinity on Windows seems to work this way, also mentioned in one othe links you sent)
This assumption might not hold in the future though...
I have seen the following:

10 physical cores. With HT enabled, you get 20 logical cores, numbered 0-19. Which share a core?

(1) 0 and 1, 2 and 3, etc.

(2) 0 and 10, 1 and 11, etc.

BOTH happen. And of course, then there is IBM with 20 logical cores per physical core.

And once upon a time, when there was a non-power-of-two number of physical cores, all bets were off in both linux and windows.