未验证 提交 a0d80754 编写于 作者: H Huihuang Zheng 提交者: GitHub

Add comments for CUDA Device Context Allocator related stuff (#19809)

上级 cc311bdf
......@@ -20,6 +20,12 @@ namespace paddle {
namespace memory {
namespace allocation {
/**
* CUDADeviceContextAllocation is a wrapper of the underbeneath allocation.
* CUDADeviceContextAllocation adds a CUDA stream callback for the underbeneath
* allocation so that CUDADeviceContextAllocation can be used in a CUDA stream
* which deletes allocation in the callback.
*/
class CUDADeviceContextAllocation : public Allocation {
public:
explicit CUDADeviceContextAllocation(AllocationPtr allocation);
......
......@@ -24,6 +24,12 @@ namespace paddle {
namespace memory {
namespace allocation {
/**
* CUDADeviceContextAllocator will allocate a CUDADeviceContextAllocation
* after waiting for a self-created event on the default stream. It does so to
* let the non-default stream be able to allocate GPU memory which will be
* released by stream callback
*/
class CUDADeviceContextAllocator : public Allocator {
public:
explicit CUDADeviceContextAllocator(platform::CUDAPlace place,
......
......@@ -24,6 +24,13 @@ namespace paddle {
namespace memory {
namespace allocation {
/**
* CUDADeviceContextAllocatorPool is a singletion stores mapping from
* CUDAPlace(s) to std::shared_ptr<CUDADeviceContextAllocator>. When a
* CUDADeviceContext's compute stream isn't default stream, it can call this
* class to allocate GPU memory which will be released by a callback after
* stream execution.
*/
class CUDADeviceContextAllocatorPool {
public:
static CUDADeviceContextAllocatorPool &Instance();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册