Merge pull request #3134 from unknownbrackets/gpu-thread

Improve separate CPU thread performance, fix condition variable misuse
Improve performance on x86 as well using movq.
Use atomic operations on Android + warning fixes.