CuriosAI / sai

SAI: a fork of Leela Zero with variable komi.
GNU General Public License v3.0
104 stars 11 forks source link

Fix the shared mutex stall (Need more tests). #143

Closed CGLemon closed 2 years ago

CGLemon commented 3 years ago

The original shared mutex has stall issue. I optimize the shared mutex. Now it is fast than before, even if the std::mutex version. I also add a option for c++17 shared mutex. If we want to use it, adding " -DUSE_CPP_17=1" on cmake.

In order to benchmark against different mutex versions, I create a simple test. The test is that all different versions start from the same board( has been moved ). Then, do one "go" to collect playouts speed. All version sample ten times.

This is my my simple test result std::mutex avg : 4212.2(playouts/second(s)) my shared mutex avg : 4330.3(playouts/second(s)) c++17 shared mutex avg : 4302.6(playouts/second(s)) Parameters: ./sai -w -p 100000 --noponder --lambda 0.3 --mu 0.03 -t 10 -b 5 OS: Ubuntu CPU: i5-9400f GPU: RTX2070s CUDA:10.2 OpenCL:1.2

This test tries to make all NNCache lookup fail. So, this test don't represent the real game. Need more tests.

amato-gianluca commented 3 years ago

Do you have the standard deviation for you results ?

I tried to replicate the results with my laptop but the thermal effect makes measurements unreliable. I will try tomorrow with a desktop system.

CGLemon commented 3 years ago

std::mutex AvgDev : 67.8 my shared mutex AvgDev : 53.36 c++17 shared mutex AvgDev : 90.4 Data Size : 10