Completed CUDA code