Page 1 of 1

Re: Lazy SMP >4 Thread Slowdown

Posted: Wed Nov 29, 2017 11:20 am
by syzygy
Shared cache lines. Use per-thread node counters, etc.

Are you using locked instructions or heavily accessed atomic variables?

On Linux, use "perf c2c" to find the cache lines that are shared, either because of a real shared variable or because of falsely shared variables (thread-specific ones that happen to sit in the same cache line).

Re: Lazy SMP >4 Thread Slowdown

Posted: Wed Nov 29, 2017 5:02 pm
by Dann Corbit
nitrocan wrote:I have recently implemented lazy smp and it works remarkably well with up to 4 cores. One weird thing that I did notice though is that as soon as I start using 8/16 cores, the nps actually starts decreasing instead of increasing. Same with the depth that it searches per unit time. Any ideas on why this might be happening? Could it be that too many threads are contending for the transposition table? All ideas are very welcome, thanks!
Perhaps there is a shared variable that is a bottleneck.

E.g. an eval hash (if global) might be better as a thread local storage so that each thread gets its own.

Besides the main hash table, what else is a public object in your program?

Re: Lazy SMP >4 Thread Slowdown

Posted: Wed Nov 29, 2017 7:20 pm
by nitrocan
Dann Corbit wrote:
nitrocan wrote:I have recently implemented lazy smp and it works remarkably well with up to 4 cores. One weird thing that I did notice though is that as soon as I start using 8/16 cores, the nps actually starts decreasing instead of increasing. Same with the depth that it searches per unit time. Any ideas on why this might be happening? Could it be that too many threads are contending for the transposition table? All ideas are very welcome, thanks!
Perhaps there is a shared variable that is a bottleneck.

E.g. an eval hash (if global) might be better as a thread local storage so that each thread gets its own.

Besides the main hash table, what else is a public object in your program?
That was pretty much exactly it. After making:

-Node counter
-Killer moves
-Counter moves
-History

thread specific, the scalability of threads is now working as intended. I'm sure there are other things I should look into as well but so far so good! Thanks everyone!

If anyone's interested, here's the pull request that I have made that addresses this issue:

https://github.com/nitrocan/sctr/pull/24/files