general purpose cupy method, thread safety