Is there a better/cleaner/more elegant way to malloc and free in cuda?
问题 I am trying to cudaMalloc a bunch of device pointers, and gracefully exit if any of the mallocs didn't work. I have functioning code - but bloated because I have to cudaFree everything I'd previously malloc'd if one fails. So now I am wondering if there is a more succinct method of accomplishing this. Obviously I can't free something that hasn't been malloc'd - that will definitely cause problems. Below is the snippet of code I am trying to make more elegant. //define device pointers float d