What do you do with NUMA?

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
syzygy
Posts: 4460
Joined: Tue Feb 28, 2012 10:56 pm

Re: What do you do with NUMA?

Post by syzygy » Fri Sep 23, 2016 11:07 am

You need to detect HT and it is quite trivial.

mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 7:17 pm

Re: What do you do with NUMA?

Post by mcostalba » Fri Sep 23, 2016 11:30 am

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: 2019
Joined: Fri Nov 26, 2010 1:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: What do you do with NUMA?

Post by mar » Fri Sep 23, 2016 11:36 am

:-) 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 7:17 pm

Re: What do you do with NUMA?

Post by mcostalba » Fri Sep 23, 2016 11:43 am

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 7:17 pm

Re: What do you do with NUMA?

Post by mcostalba » Fri Sep 23, 2016 11:47 am

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: 2019
Joined: Fri Nov 26, 2010 1:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: What do you do with NUMA?

Post by mar » Fri Sep 23, 2016 11:59 am

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: 4460
Joined: Tue Feb 28, 2012 10:56 pm

Re: What do you do with NUMA?

Post by syzygy » Fri Sep 23, 2016 1:16 pm

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.


bob
Posts: 20667
Joined: Mon Feb 27, 2006 6:30 pm
Location: Birmingham, AL

Re: What do you do with NUMA?

Post by bob » Fri Sep 23, 2016 4:07 pm

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: 20667
Joined: Mon Feb 27, 2006 6:30 pm
Location: Birmingham, AL

Re: What do you do with NUMA?

Post by bob » Fri Sep 23, 2016 4:12 pm

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.

Post Reply