refactored how to do cuda allocation