refactored GpuMat and CudaMem