rewrote cuda without atomics