提交 199b5fcb 编写于 作者: L liaogang

ENH: refine code comments

上级 1ce2fca4
......@@ -42,7 +42,7 @@ class BuddyAllocator {
void Free(void*);
size_t Used();
private:
public:
// Disable copy and assignment.
BuddyAllocator(const BuddyAllocator&) = delete;
BuddyAllocator& operator=(const BuddyAllocator&) = delete;
......@@ -57,6 +57,7 @@ class BuddyAllocator {
/*! \brief If existing chunks are not suitable, refill pool */
PoolSet::iterator RefillPool();
/**
* \brief Find the suitable chunk from existing pool
*
......
......@@ -23,14 +23,14 @@ namespace paddle {
namespace memory {
namespace detail {
/*! A cache for accessing memory block meta-data that may be expensive to access
directly.
Note: this class exists to unify the metadata format between GPU and CPU
allocations.
It should be removed when the CPU can access all GPU allocations directly
via UVM.
*/
/**
* \brief A cache for accessing memory block meta-data that may be expensive
* to access directly.
*
* \note This class exists to unify the metadata format between GPU and CPU
* allocations. It should be removed when the CPU can access all GPU
* allocations directly via UVM.
*/
class MetadataCache {
public:
MetadataCache(bool uses_gpu);
......@@ -42,14 +42,7 @@ class MetadataCache {
/*! \brief Store the associated metadata for the specified memory block. */
void store(MemoryBlock*, const Metadata&);
public:
/*! \brief Acquire any external metadata updates. */
void acquire(MemoryBlock*);
/*! \brief Publish any local updates externally. */
void release(MemoryBlock*);
/*! \brief Indicate that the specified metadata will no longer be used */
/*! \brief Indicate that the specified metadata will no longer be used. */
void invalidate(MemoryBlock*);
public:
......
......@@ -60,7 +60,7 @@ void CPUAllocator::Free(void* p, size_t size, size_t index) {
free(p);
}
bool CPUAllocator::UseGpu() { return false; }
bool CPUAllocator::UseGpu() const { return false; }
#ifndef PADDLE_ONLY_CPU
......@@ -133,7 +133,7 @@ void GPUAllocator::Free(void* p, size_t size, size_t index) {
}
}
bool GPUAllocator::UseGpu() { return true; }
bool GPUAllocator::UseGpu() const { return true; }
#endif // PADDLE_ONLY_CPU
......
......@@ -32,14 +32,14 @@ class SystemAllocator {
virtual ~SystemAllocator() {}
virtual void* Alloc(size_t& index, size_t size) = 0;
virtual void Free(void* p, size_t size, size_t index) = 0;
virtual bool UseGpu() = 0;
virtual bool UseGpu() const = 0;
};
class CPUAllocator : public SystemAllocator {
public:
virtual void* Alloc(size_t& index, size_t size);
virtual void Free(void* p, size_t size, size_t index);
virtual bool UseGpu();
virtual bool UseGpu() const;
};
#ifndef PADDLE_ONLY_CPU
......@@ -47,7 +47,7 @@ class GPUAllocator : public SystemAllocator {
public:
virtual void* Alloc(size_t& index, size_t size);
virtual void Free(void* p, size_t size, size_t index);
virtual bool UseGpu();
virtual bool UseGpu() const;
private:
size_t gpu_alloc_size_ = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册