Various utility functions for CUDA