CUDA code

Did spot checks and seems like it works.