Browse Source

fix-the-bug-of-can-not-find-the-device-address-in-auto-parallel

tags/v1.0.0
lvliang 5 years ago
parent
commit
bf1ee34fd9
4 changed files with 21 additions and 6 deletions
  1. +0
    -2
      mindspore/ccsrc/pipeline/pynative/pynative_execute.h
  2. +1
    -4
      mindspore/ccsrc/runtime/device/ascend/ascend_memory_manager.cc
  3. +19
    -0
      mindspore/ccsrc/runtime/device/ascend/ascend_memory_pool.cc
  4. +1
    -0
      mindspore/ccsrc/runtime/device/ascend/ascend_memory_pool.h

+ 0
- 2
mindspore/ccsrc/pipeline/pynative/pynative_execute.h View File

@@ -38,7 +38,6 @@

namespace mindspore {
namespace pynative {

namespace py = pybind11;
using ResourcePtr = std::shared_ptr<pipeline::Resource>;
using GradOperationPtr = std::shared_ptr<prim::GradOperation>;
@@ -168,7 +167,6 @@ class PynativeExecutor : public std::enable_shared_from_this<PynativeExecutor> {
};

using PynativeExecutorPtr = std::shared_ptr<PynativeExecutor>;

} // namespace pynative
} // namespace mindspore



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

@@ -34,10 +34,7 @@ void AscendMemoryManager::MallocDeviceMemory() {
MS_EXCEPTION(DeviceProcessError) << "rtMalloc mem size[" << device_mem_size_ << "] fail, ret[" << ret << "]";
}

AscendMemoryPool::GetInstance().set_device_mem_size(device_mem_size_);
AscendMemoryPool::GetInstance().set_device_mem_pool_base(device_mem_base_);
AscendMemoryPool::GetInstance().set_device_mem_pool_offset(device_mem_size_);
AscendMemoryPool::GetInstance().set_graph_dynamic_mem_offset(dynamic_mem_offset_);
AscendMemoryPool::GetInstance().Init(device_mem_base_, device_mem_size_, dynamic_mem_offset_);
}

uint64_t AscendMemoryManager::GetDeviceMemSizeFromContext() {


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

@@ -21,6 +21,25 @@
namespace mindspore {
namespace device {
namespace ascend {
void AscendMemoryPool::Init(uint8_t *device_mem_base, uint64_t device_mem_size, uint64_t dynamic_mem_offset) {
static bool initialized = false;
if (initialized) {
return;
}

MS_EXCEPTION_IF_NULL(device_mem_base);
set_device_mem_pool_base(device_mem_base);

if (dynamic_mem_offset > device_mem_size) {
MS_LOG(EXCEPTION) << "Dynamic memory offset: " << dynamic_mem_offset
<< " exceed the device memory size: " << device_mem_size;
}
set_device_mem_size(device_mem_size);
set_device_mem_pool_offset(device_mem_size);
set_graph_dynamic_mem_offset(dynamic_mem_offset);
initialized = true;
}

size_t AscendMemoryPool::AllocDeviceMem(size_t size, DeviceMemPtr *addr) {
if (size == 0) {
MS_LOG(EXCEPTION) << "Failed to alloc memory pool resource, the size is zero!";


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

@@ -29,6 +29,7 @@ class AscendMemoryPool : public DynamicMemPoolBestFit {
AscendMemoryPool(const AscendMemoryPool &) = delete;
AscendMemoryPool &operator=(const AscendMemoryPool &) = delete;

void Init(uint8_t *device_mem_base, uint64_t device_mem_size, uint64_t dynamic_mem_offset);
size_t AllocDeviceMem(size_t size, DeviceMemPtr *addr) override;
bool FreeDeviceMem(const DeviceMemPtr &addr) override;
void ResetIdleMemBuf();


Loading…
Cancel
Save