@@ -31,7 +31,7 @@ In `paddle/memory/memory.h` we have:
...
@@ -31,7 +31,7 @@ In `paddle/memory/memory.h` we have:
namespacememory{
namespacememory{
template<typenamePlace>void*Alloc(Place,size_t);
template<typenamePlace>void*Alloc(Place,size_t);
template<typenamePlace>voidFree(Place,void*);
template<typenamePlace>voidFree(Place,void*);
template<typenamePlace>voidUsed(Place);
template<typenamePlace>size_tUsed(Place);
}// namespace memory
}// namespace memory
```
```
...
@@ -39,7 +39,7 @@ These function templates have specializations on either `platform::CPUPlace` or
...
@@ -39,7 +39,7 @@ These function templates have specializations on either `platform::CPUPlace` or
```cpp
```cpp
template<>
template<>
voidAlloc<CPUPlace>(CPUPlacep,size_tsize){
void*Alloc<CPUPlace>(CPUPlacep,size_tsize){
returnGetCPUBuddyAllocator()->Alloc(size);
returnGetCPUBuddyAllocator()->Alloc(size);
}
}
```
```
...
@@ -102,15 +102,11 @@ class BuddyAllocator {
...
@@ -102,15 +102,11 @@ class BuddyAllocator {
};
};
```
```
#### System Allocators
Because BuddyAllocator has the meta-data of each block, it can trace the used memory -- record the amount returned by `Alloc` freed in `Free`. Instead, `CPUAllocator` and `GPUAllocator` doesn't know the size of freed memory block and cannot do the trace.
The `GPUAllocator` and `CPUAllocator` are calls *system allocators*. They work as the fallback allocators of `BuddyAllocator`. A system allocator holds information about a device, including the amount of memory has been allocated, so we can call
-`GPUAllocator::Used()` and
#### System Allocators
-`CPUAllocator::Used()`
to get the amount of memory that has been allocated so far.
The `GPUAllocator` and `CPUAllocator` are calls *system allocators*. They work as the fallback allocators of `BuddyAllocator`.