Complete Cuda implementation.