Implementation of  CUDA memory allocation and copy functions