提交 e309bcd4 编写于 作者: Y Yi Wang

Update

上级 770cec4e
...@@ -26,7 +26,7 @@ void TestAllocator(paddle::memory::detail::SystemAllocator* a, size_t size) { ...@@ -26,7 +26,7 @@ void TestAllocator(paddle::memory::detail::SystemAllocator* a, size_t size) {
bool freed = false; bool freed = false;
{ {
size_t index; size_t index;
void* p = a->Alloc(index, size); void* p = a->Alloc(&index, size);
if (size > 0) { if (size > 0) {
EXPECT_NE(p, nullptr); EXPECT_NE(p, nullptr);
} else { } else {
......
...@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ...@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#include "paddle/fluid/memory/memory.h" #include "paddle/fluid/memory/malloc.h"
#include <unordered_map> #include <unordered_map>
...@@ -27,7 +27,7 @@ inline bool is_aligned(void const *p) { ...@@ -27,7 +27,7 @@ inline bool is_aligned(void const *p) {
} }
size_t align(size_t size, paddle::platform::CPUPlace place) { size_t align(size_t size, paddle::platform::CPUPlace place) {
size += sizeof(paddle::memory::detail::Metadata); size += sizeof(paddle::memory::detail::MemoryBlock::Desc);
size_t alignment = paddle::platform::CpuMinChunkSize(); size_t alignment = paddle::platform::CpuMinChunkSize();
size_t remaining = size % alignment; size_t remaining = size % alignment;
return remaining == 0 ? size : size + (alignment - remaining); return remaining == 0 ? size : size + (alignment - remaining);
...@@ -85,7 +85,7 @@ TEST(BuddyAllocator, CPUMultAlloc) { ...@@ -85,7 +85,7 @@ TEST(BuddyAllocator, CPUMultAlloc) {
#ifdef PADDLE_WITH_CUDA #ifdef PADDLE_WITH_CUDA
size_t align(size_t size, paddle::platform::CUDAPlace place) { size_t align(size_t size, paddle::platform::CUDAPlace place) {
size += sizeof(paddle::memory::detail::Metadata); size += sizeof(paddle::memory::detail::MemoryBlock::Desc);
size_t alignment = paddle::platform::GpuMinChunkSize(); size_t alignment = paddle::platform::GpuMinChunkSize();
size_t remaining = size % alignment; size_t remaining = size % alignment;
return remaining == 0 ? size : size + (alignment - remaining); return remaining == 0 ? size : size + (alignment - remaining);
...@@ -141,7 +141,7 @@ TEST(BuddyAllocator, GPUMultAlloc) { ...@@ -141,7 +141,7 @@ TEST(BuddyAllocator, GPUMultAlloc) {
} }
size_t align(size_t size, paddle::platform::CUDAPinnedPlace place) { size_t align(size_t size, paddle::platform::CUDAPinnedPlace place) {
size += sizeof(paddle::memory::detail::Metadata); size += sizeof(paddle::memory::detail::MemoryBlock::Desc);
size_t alignment = paddle::platform::CUDAPinnedMinChunkSize(); size_t alignment = paddle::platform::CUDAPinnedMinChunkSize();
size_t remaining = size % alignment; size_t remaining = size % alignment;
return remaining == 0 ? size : size + (alignment - remaining); return remaining == 0 ? size : size + (alignment - remaining);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册