Browse Source

!11241 optimize the dynamic memory alloc

From: @limingqi107
Reviewed-by: @cristoval,@kisnwang
Signed-off-by: @kisnwang
tags/v1.2.0-rc1
mindspore-ci-bot Gitee 4 years ago
parent
commit
1e13cbb8da
2 changed files with 3 additions and 3 deletions
  1. +2
    -2
      mindspore/ccsrc/backend/optimizer/mem_reuse/mem_dynamic_allocator.h
  2. +1
    -1
      mindspore/ccsrc/runtime/device/ascend/ascend_memory_pool.cc

+ 2
- 2
mindspore/ccsrc/backend/optimizer/mem_reuse/mem_dynamic_allocator.h View File

@@ -33,8 +33,8 @@ enum DynamicMemBufStatus : int { kMemBufIdle, kMemBufUsed };
// Alloc memory aligned according to 512 bytes. // Alloc memory aligned according to 512 bytes.
static const size_t DYNAMIC_MEM_ALIGN_SIZE = 512; static const size_t DYNAMIC_MEM_ALIGN_SIZE = 512;
// The minimum unit size (500M) of memory block used for dynamic extend.
static const size_t DYNAMIC_MEM_ALLOC_UNIT_SIZE = 500 << 20;
// The minimum unit size (1G) of memory block used for dynamic extend.
static const size_t DYNAMIC_MEM_ALLOC_UNIT_SIZE = 1024 << 20;
// The Comparator of device address from small to large. // The Comparator of device address from small to large.
struct DeviceAddrCmp { struct DeviceAddrCmp {


+ 1
- 1
mindspore/ccsrc/runtime/device/ascend/ascend_memory_pool.cc View File

@@ -76,7 +76,7 @@ size_t AscendMemoryPool::AlignMemorySize(size_t size) const {
return size; return size;
} }


size_t AscendMemoryPool::mem_alloc_unit_size() const { return DYNAMIC_MEM_ALLOC_UNIT_SIZE / 2; }
size_t AscendMemoryPool::mem_alloc_unit_size() const { return DYNAMIC_MEM_ALLOC_UNIT_SIZE / 4; }


void AscendMemoryPool::set_device_mem_pool_base(uint8_t *device_mem_pool_base) { void AscendMemoryPool::set_device_mem_pool_base(uint8_t *device_mem_pool_base) {
MS_EXCEPTION_IF_NULL(device_mem_pool_base); MS_EXCEPTION_IF_NULL(device_mem_pool_base);


Loading…
Cancel
Save