sync changes from perft_gpu

- changes that are not supposed to make any difference to CPU version.
- Minor changes cause severe perf degradation. It might be possible to
tune more.