Is there a CUDA smart pointer?

你说的曾经没有我的故事 提交于 2019-12-05 14:53:47

You can use RAII idiom and put your cudaMalloc() and cudaFree() calls to the constructor and destructor of your object respectively.

Once the exception is thrown your destructor will be called which will free the allocated memory.

If you wrap this object into a smart-pointer (or make it behave like a pointer) you will get your CUDA smart-pointer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!