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

ENH: refine code comments

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