Cleaning up CUDA code