functions for CUDA calcs