updated version with check between CPU and GPU version work. the gradient function is still in grid_grad_GPU.cu for now
Former-commit-id: dee834c2d14ca8c88030ba6a396ad9600c259bcb