basic conversion of most of the functions to CUDA