shift CUDA code out of common