Merged
fix(machine): Fix missing unit issue. #5489
chaizhengtongAdd on Aug 17
fix(machine): Fix missing unit issue. #5489
Merged
Merged fromchai-hw/pypto_chaimachine_formatintocann/pyptomaster
Total: 16 files changed+46-38
| @@ -74,8 +74,8 @@ std::shared_ptr<LoadedBundle> KernelBundleLoader::LoadFromMemory(const uint8_t* | |||
| 74 | return nullptr; | 74 | return nullptr; |
| 75 | } | 75 | } |
| 76 | if (hdr.totalSize != n) { | 76 | if (hdr.totalSize != n) { |
| 77 | - MACHINE_LOGE(DevCommonErr::FILE_ERROR, "[kernel-bundle] size mismatch: header=%lu actual=%zu", hdr.totalSize, | 77 | + MACHINE_LOGE(DevCommonErr::FILE_ERROR, "[kernel-bundle] size mismatch: header=%lu bytes actual=%zu bytes", |
| 78 | - n); | 78 | + hdr.totalSize, n); |
| 79 | return nullptr; | 79 | return nullptr; |
| 80 | } | 80 | } |
| 81 | if (Crc32(p, sizeof(BundleHeader) - sizeof(uint32_t)) != hdr.headerCrc32) { | 81 | if (Crc32(p, sizeof(BundleHeader) - sizeof(uint32_t)) != hdr.headerCrc32) { |
| @@ -40,7 +40,7 @@ namespace npu::tile_fwk::dynamic { | |||
| 40 | uint8_t* AllocHostAddr(size_t size) | 40 | uint8_t* AllocHostAddr(size_t size) |
| 41 | { | 41 | { |
| 42 | if (size == 0 || size > 0x500000000) { | 42 | if (size == 0 || size > 0x500000000) { |
| 43 | - DISTRIBUTED_LOGE(DistributedErrorCode::CONTEXT_CONFIGURE_FAILED, "AllocHostAddr failed size %zu", size); | 43 | + DISTRIBUTED_LOGE(DistributedErrorCode::CONTEXT_CONFIGURE_FAILED, "AllocHostAddr failed size %zu bytes", size); |
| 44 | return nullptr; | 44 | return nullptr; |
| 45 | } | 45 | } |
| 46 | auto hostPtr = (uint8_t*)malloc(size); | 46 | auto hostPtr = (uint8_t*)malloc(size); |
| @@ -258,7 +258,7 @@ static std::vector<DeviceTensorData> toHostTensorData(const std::vector<DeviceTe | |||
| 258 | for (auto& devData : devDataList) { | 258 | for (auto& devData : devDataList) { |
| 259 | int64_t size = devData.GetDataSize(); | 259 | int64_t size = devData.GetDataSize(); |
| 260 | if (size == 0 || size > 0x500000000) { | 260 | if (size == 0 || size > 0x500000000) { |
| 261 | - MACHINE_LOGE(DevCommonErr::PARAM_INVALID, "AllocDev failed: size=%ld", size); | 261 | + MACHINE_LOGE(DevCommonErr::PARAM_INVALID, "AllocDev failed: size=%ld bytes", size); |
| 262 | return {}; | 262 | return {}; |
| 263 | } | 263 | } |
| 264 | void* ptr = malloc(size); | 264 | void* ptr = malloc(size); |
| @@ -36,7 +36,7 @@ struct AicoreModelMemoryUtils { | |||
| 36 | { | 36 | { |
| 37 | (void)cachedDevAddrHolder; | 37 | (void)cachedDevAddrHolder; |
| 38 | if (size == 0 || size > 0x500000000) { | 38 | if (size == 0 || size > 0x500000000) { |
| 39 | - MACHINE_LOGE(DevCommonErr::PARAM_INVALID, "AllocDev failed: size=%zu", size); | 39 | + MACHINE_LOGE(DevCommonErr::PARAM_INVALID, "AllocDev failed: size=%zu bytes", size); |
| 40 | return nullptr; | 40 | return nullptr; |
| 41 | } | 41 | } |
| 42 | uint8_t* rawPtr = (uint8_t*)malloc(size); | 42 | uint8_t* rawPtr = (uint8_t*)malloc(size); |
| @@ -157,7 +157,7 @@ int DeviceLauncher::DeviceLaunchOnceWithDeviceTensorData( | |||
| 157 | DeviceMemoryUtils devMem; | 157 | DeviceMemoryUtils devMem; |
| 158 | wsAddr = reinterpret_cast<int64_t*>(devMem.AllocDev(static_cast<size_t>(wsSize), nullptr)); | 158 | wsAddr = reinterpret_cast<int64_t*>(devMem.AllocDev(static_cast<size_t>(wsSize), nullptr)); |
| 159 | if (wsAddr == nullptr) { | 159 | if (wsAddr == nullptr) { |
| 160 | - MACHINE_LOGE(RtErr::RT_MALLOC_FAILED, "Failed to alloc workspace of size %ld", wsSize); | 160 | + MACHINE_LOGE(RtErr::RT_MALLOC_FAILED, "Failed to alloc workspace of size %ld bytes", wsSize); |
| 161 | return -1; | 161 | return -1; |
| 162 | } | 162 | } |
| 163 | } | 163 | } |
| @@ -421,7 +421,7 @@ public: | |||
| 421 | kArgs.inputs = reinterpret_cast<int64_t*>(tensorInfo_.data() + sizeof(AiCpuArgs)); | 421 | kArgs.inputs = reinterpret_cast<int64_t*>(tensorInfo_.data() + sizeof(AiCpuArgs)); |
| 422 | kArgs.outputs = kArgs.inputs + 1; | 422 | kArgs.outputs = kArgs.inputs + 1; |
| 423 | } | 423 | } |
| 424 | - MACHINE_LOGD("Inputs=%p, outputs=%p, workspace=%p, cfgdata=%p, tensorSize=%zu, patchTailSize=%zu.", | 424 | + MACHINE_LOGD("Inputs=%p, outputs=%p, workspace=%p, cfgdata=%p, tensorSize=%zu bytes, patchTailSize=%zu bytes.", |
| 425 | kArgs.inputs, kArgs.outputs, kArgs.workspace, kArgs.cfgdata, tensorSize, patchTailSize); | 425 | kArgs.inputs, kArgs.outputs, kArgs.workspace, kArgs.cfgdata, tensorSize, patchTailSize); |
| 426 | } | 426 | } |
| 427 | 427 | ||
| @@ -317,7 +317,7 @@ static std::vector<DeviceTensorData> toHostTensorData(const std::vector<DeviceTe | |||
| 317 | auto size = devData.GetDataSize(); | 317 | auto size = devData.GetDataSize(); |
| 318 | if (size == 0) { | 318 | if (size == 0) { |
| 319 | // Optional placeholder (e.g. empty dequant_scale); no device buffer — skip D2H memcpy. | 319 | // Optional placeholder (e.g. empty dequant_scale); no device buffer — skip D2H memcpy. |
| 320 | - MACHINE_LOGW("toHostTensorData: skip zero-size tensor, isInput=%d", isInput); | 320 | + MACHINE_LOGW("toHostTensorData: skip empty tensor, isInput=%d", isInput); |
| 321 | hostDataList.emplace_back(devData.GetDataType(), nullptr, devData.GetShape()); | 321 | hostDataList.emplace_back(devData.GetDataType(), nullptr, devData.GetShape()); |
| 322 | continue; | 322 | continue; |
| 323 | } | 323 | } |
| @@ -32,7 +32,7 @@ struct EmulationMemoryUtils { | |||
| 32 | { | 32 | { |
| 33 | (void)cachedDevAddrHolder; | 33 | (void)cachedDevAddrHolder; |
| 34 | if (size == 0 || size >= 0xFFFFFFFFF) { | 34 | if (size == 0 || size >= 0xFFFFFFFFF) { |
| 35 | - MACHINE_LOGE(DevCommonErr::PARAM_INVALID, "AllocDev failed: size=%zu", size); | 35 | + MACHINE_LOGE(DevCommonErr::PARAM_INVALID, "AllocDev failed: size=%zu bytes", size); |
| 36 | return nullptr; | 36 | return nullptr; |
| 37 | } | 37 | } |
| 38 | uint8_t* rawPtr = (uint8_t*)malloc(size); | 38 | uint8_t* rawPtr = (uint8_t*)malloc(size); |
| @@ -72,7 +72,7 @@ DevMemoryPool::~DevMemoryPool() | |||
| 72 | void DevMemoryPool::AllocDevAddr(uint8_t** devAddr, const uint64_t size) | 72 | void DevMemoryPool::AllocDevAddr(uint8_t** devAddr, const uint64_t size) |
| 73 | { | 73 | { |
| 74 | if (!AllocDevAddrInPool(devAddr, size)) { | 74 | if (!AllocDevAddrInPool(devAddr, size)) { |
| 75 | - MACHINE_LOGE(DevCommonErr::ALLOC_FAILED, "AllocDevAddrInPool failed for size %lu", size); | 75 | + MACHINE_LOGE(DevCommonErr::ALLOC_FAILED, "AllocDevAddrInPool failed for size %lu bytes", size); |
| 76 | } else { | 76 | } else { |
| 77 | MACHINE_LOGI("RuntimeAgentMemory: Alloc success %p", *devAddr); | 77 | MACHINE_LOGI("RuntimeAgentMemory: Alloc success %p", *devAddr); |
| 78 | } | 78 | } |
| @@ -112,7 +112,7 @@ bool DevMemoryPool::AllocDevAddrInPool(uint8_t** devAddr, const uint64_t size) | |||
| 112 | } | 112 | } |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | - MACHINE_LOGE(DevCommonErr::ALLOC_FAILED, "Allocate failed: size=%lu", size); | 115 | + MACHINE_LOGE(DevCommonErr::ALLOC_FAILED, "Allocate failed: size=%lu bytes", size); |
| 116 | return false; | 116 | return false; |
| 117 | } | 117 | } |
| 118 | 118 | ||
| @@ -285,7 +285,7 @@ void DevMemoryPool::FreeMemBlock(MemoryBlock* block) | |||
| 285 | } | 285 | } |
| 286 | 286 | ||
| 287 | if (block->baseAddr != nullptr) { | 287 | if (block->baseAddr != nullptr) { |
| 288 | - MACHINE_LOGI("Releasing physical memory: addr=%p, size=%lu", block->baseAddr, block->blockSize); | 288 | + MACHINE_LOGI("Releasing physical memory: addr=%p, size=%lu bytes", block->baseAddr, block->blockSize); |
| 289 | RuntimeFree(block->baseAddr); | 289 | RuntimeFree(block->baseAddr); |
| 290 | block->baseAddr = nullptr; | 290 | block->baseAddr = nullptr; |
| 291 | } | 291 | } |
| @@ -319,7 +319,7 @@ void* DevAlloc(const uint64_t size) | |||
| 319 | } | 319 | } |
| 320 | if (RuntimeMemset(devPtr, size, 0, size) != RT_SUCCESS) { | 320 | if (RuntimeMemset(devPtr, size, 0, size) != RT_SUCCESS) { |
| 321 | DevMemoryPool::Instance().FreeDevAddr(devPtr); | 321 | DevMemoryPool::Instance().FreeDevAddr(devPtr); |
| 322 | - MACHINE_LOGE(RtErr::RT_MEMSET_FAILED, "RuntimeMemset failed size=%lu.", size); | 322 | + MACHINE_LOGE(RtErr::RT_MEMSET_FAILED, "RuntimeMemset failed size=%lu bytes.", size); |
| 323 | return nullptr; | 323 | return nullptr; |
| 324 | } | 324 | } |
| 325 | return devPtr; | 325 | return devPtr; |
| @@ -329,12 +329,12 @@ void* CopyDataToDevice(const void* dataPtr, const uint64_t dataSize) | |||
| 329 | { | 329 | { |
| 330 | void* devAddr = DevAlloc(dataSize); | 330 | void* devAddr = DevAlloc(dataSize); |
| 331 | if (devAddr == nullptr) { | 331 | if (devAddr == nullptr) { |
| 332 | - MACHINE_LOGE(DevCommonErr::ALLOC_FAILED, "Failed to alloc dev memory of size %lu", dataSize); | 332 | + MACHINE_LOGE(DevCommonErr::ALLOC_FAILED, "Failed to alloc dev memory of size %lu bytes", dataSize); |
| 333 | return nullptr; | 333 | return nullptr; |
| 334 | } | 334 | } |
| 335 | if (RuntimeMemcpyDirect(devAddr, dataSize, dataPtr, dataSize, RtMemcpyKind::HOST_TO_DEVICE) != RT_SUCCESS) { | 335 | if (RuntimeMemcpyDirect(devAddr, dataSize, dataPtr, dataSize, RtMemcpyKind::HOST_TO_DEVICE) != RT_SUCCESS) { |
| 336 | DevMemoryPool::Instance().FreeDevAddr(devAddr); | 336 | DevMemoryPool::Instance().FreeDevAddr(devAddr); |
| 337 | - MACHINE_LOGE(DevCommonErr::ALLOC_FAILED, "Failed to copy data to dev of size %lu", dataSize); | 337 | + MACHINE_LOGE(DevCommonErr::ALLOC_FAILED, "Failed to copy data to dev of size %lu bytes", dataSize); |
| 338 | return nullptr; | 338 | return nullptr; |
| 339 | } | 339 | } |
| 340 | return devAddr; | 340 | return devAddr; |
| @@ -38,13 +38,15 @@ int AicorePrintHostManager::Init(const DeviceArgs& args) | |||
| 38 | for (uint32_t i = 0; i < numCores_; i++) { | 38 | for (uint32_t i = 0; i < numCores_; i++) { |
| 39 | void* devPtr = nullptr; | 39 | void* devPtr = nullptr; |
| 40 | if (RuntimeMalloc(&devPtr, PRINT_BUFFER_SIZE, RT_MEMORY_HBM, 0) != RT_SUCCESS) { | 40 | if (RuntimeMalloc(&devPtr, PRINT_BUFFER_SIZE, RT_MEMORY_HBM, 0) != RT_SUCCESS) { |
| 41 | - MACHINE_LOGE(DevCommonErr::ALLOC_FAILED, "Failed to alloc aicore print buffer for core %u", i); | 41 | + MACHINE_LOGE(DevCommonErr::ALLOC_FAILED, "Failed to alloc aicore print buffer, size=%lu bytes, coreId=%u", |
| 42 | + PRINT_BUFFER_SIZE, i); | ||
| 42 | Release(); | 43 | Release(); |
| 43 | return static_cast<int>(DevCommonErr::ALLOC_FAILED); | 44 | return static_cast<int>(DevCommonErr::ALLOC_FAILED); |
| 44 | } | 45 | } |
| 45 | - MACHINE_LOGD("AicorePrintHostManager alloc core %u buffer=%p size=%lu", i, devPtr, PRINT_BUFFER_SIZE); | 46 | + MACHINE_LOGD("AicorePrintHostManager alloc buffer=%p size=%lu bytes, coreId=%u", devPtr, PRINT_BUFFER_SIZE, i); |
| 46 | if (RuntimeMemset(devPtr, PRINT_BUFFER_SIZE, 0, PRINT_BUFFER_SIZE) != RT_SUCCESS) { | 47 | if (RuntimeMemset(devPtr, PRINT_BUFFER_SIZE, 0, PRINT_BUFFER_SIZE) != RT_SUCCESS) { |
| 47 | - MACHINE_LOGE(DevCommonErr::MEMRESET_FAILED, "Failed to memset aicore print buffer for core %u", i); | 48 | + MACHINE_LOGE(DevCommonErr::MEMRESET_FAILED, |
| 49 | + "Failed to memset aicore print buffer, size=%lu bytes, coreId=%u", PRINT_BUFFER_SIZE, i); | ||
| 48 | RuntimeFree(devPtr); | 50 | RuntimeFree(devPtr); |
| 49 | Release(); | 51 | Release(); |
| 50 | return static_cast<int>(DevCommonErr::MEMRESET_FAILED); | 52 | return static_cast<int>(DevCommonErr::MEMRESET_FAILED); |
| @@ -57,7 +59,7 @@ int AicorePrintHostManager::Init(const DeviceArgs& args) | |||
| 57 | return static_cast<int>(DevCommonErr::MEMCPY_FAILED); | 59 | return static_cast<int>(DevCommonErr::MEMCPY_FAILED); |
| 58 | } | 60 | } |
| 59 | hostBuf_.resize(PRINT_BUFFER_SIZE); | 61 | hostBuf_.resize(PRINT_BUFFER_SIZE); |
| 60 | - MACHINE_LOGI("AicorePrintHostManager init success: %u cores, buffer size %lu", numCores_, PRINT_BUFFER_SIZE); | 62 | + MACHINE_LOGI("AicorePrintHostManager init success: %u cores, buffer size %lu bytes", numCores_, PRINT_BUFFER_SIZE); |
| 61 | return 0; | 63 | return 0; |
| 62 | } | 64 | } |
| 63 | 65 | ||
| @@ -94,7 +96,9 @@ int AicorePrintHostManager::DumpAicoreLog() | |||
| 94 | auto ret = NormalizedRtMemcpy(hostBuf_.data(), PRINT_BUFFER_SIZE, devBuffers_[i], PRINT_BUFFER_SIZE, | 96 | auto ret = NormalizedRtMemcpy(hostBuf_.data(), PRINT_BUFFER_SIZE, devBuffers_[i], PRINT_BUFFER_SIZE, |
| 95 | RtMemcpyKind::DEVICE_TO_HOST); | 97 | RtMemcpyKind::DEVICE_TO_HOST); |
| 96 | if (ret != RT_SUCCESS) { | 98 | if (ret != RT_SUCCESS) { |
| 97 | - MACHINE_LOGE(DevCommonErr::MEMCPY_FAILED, "D2H copy aicore print buffer failed, core %u, ret %d", i, ret); | 99 | + MACHINE_LOGE(DevCommonErr::MEMCPY_FAILED, |
| 100 | + "D2H copy aicore print buffer failed, size=%lu bytes, coreId=%u, ret %d", PRINT_BUFFER_SIZE, i, | ||
| 101 | + ret); | ||
| 98 | retCode = static_cast<int>(DevCommonErr::MEMCPY_FAILED); | 102 | retCode = static_cast<int>(DevCommonErr::MEMCPY_FAILED); |
| 99 | continue; | 103 | continue; |
| 100 | } | 104 | } |
| @@ -329,7 +329,7 @@ void HostProf::HostProfReportCacheTaskInfo(const AclRtStream stream, const uint3 | |||
| 329 | size_t bufferSize = sizeof(CacheTaskInfo) + sizeof(MspfTensorData) * tensorSize; | 329 | size_t bufferSize = sizeof(CacheTaskInfo) + sizeof(MspfTensorData) * tensorSize; |
| 330 | void* buffer = malloc(bufferSize); | 330 | void* buffer = malloc(bufferSize); |
| 331 | if (buffer == nullptr) { | 331 | if (buffer == nullptr) { |
| 332 | - MACHINE_LOGW("Fail to malloc memory, size is [%zu]", bufferSize); | 332 | + MACHINE_LOGW("Fail to malloc memory, size is [%zu] bytes", bufferSize); |
| 333 | return; | 333 | return; |
| 334 | } | 334 | } |
| 335 | (void)memset_s(buffer, bufferSize, 0, bufferSize); | 335 | (void)memset_s(buffer, bufferSize, 0, bufferSize); |
| @@ -196,7 +196,7 @@ int64_t KernelBinary::GetWorkspaceSize(const std::vector<DeviceTensorData>& tens | |||
| 196 | 196 | ||
| 197 | // check and pretty print total workspace consumption | 197 | // check and pretty print total workspace consumption |
| 198 | auto* wsChecker = RebuildableAttributeManager::GetInstance().GetAttr<RebuildableWorkspaceDesc>(dynFunc.get()); | 198 | auto* wsChecker = RebuildableAttributeManager::GetInstance().GetAttr<RebuildableWorkspaceDesc>(dynFunc.get()); |
| 199 | - MACHINE_LOGI_FULL("Memory Consumption: size=%ld\n%s\n", workspaceSize, | 199 | + MACHINE_LOGI_FULL("Memory Consumption: size=%ld bytes\n%s\n", workspaceSize, |
| 200 | wsChecker | 200 | wsChecker |
| 201 | ->PrettyDumpSize(devProg->memBudget.tensor.maxDynamicAssembleOutcastMem, | 201 | ->PrettyDumpSize(devProg->memBudget.tensor.maxDynamicAssembleOutcastMem, |
| 202 | devProg->memBudget.debug.Total()) | 202 | devProg->memBudget.debug.Total()) |
| @@ -76,8 +76,8 @@ inline void RuntimeMemcpyWithCheck(void* dst, uint64_t destMax, const void* src, | |||
| 76 | const RtError ret = RuntimeMemcpyDirect(dst, destMax, src, cnt, kind); | 76 | const RtError ret = RuntimeMemcpyDirect(dst, destMax, src, cnt, kind); |
| 77 | if (ret != RT_SUCCESS) { | 77 | if (ret != RT_SUCCESS) { |
| 78 | MACHINE_LOGE(RtErr::RT_MEMCPY_FAILED, | 78 | MACHINE_LOGE(RtErr::RT_MEMCPY_FAILED, |
| 79 | - "RuntimeMemcpy failed: func=%s, file=%s:%d, ret=%d, kind=%d, size=%lu, dst=%p, src=%p", func, file, | 79 | + "RuntimeMemcpy failed: func=%s, file=%s:%d, ret=%d, kind=%d, size=%lu bytes, dst=%p, src=%p", func, |
| 80 | - line, static_cast<int>(ret), static_cast<int>(kind), cnt, dst, src); | 80 | + file, line, static_cast<int>(ret), static_cast<int>(kind), cnt, dst, src); |
| 81 | MACHINE_ASSERT(false) << "RuntimeMemcpy failed, ret=" << static_cast<int>(ret); | 81 | MACHINE_ASSERT(false) << "RuntimeMemcpy failed, ret=" << static_cast<int>(ret); |
| 82 | } | 82 | } |
| 83 | } | 83 | } |
| @@ -89,8 +89,8 @@ inline void RuntimeMemcpyAsyncWithCheck(void* dst, uint64_t destMax, const void* | |||
| 89 | const RtError ret = RuntimeMemcpyDirectAsync(dst, destMax, src, cnt, kind, stm); | 89 | const RtError ret = RuntimeMemcpyDirectAsync(dst, destMax, src, cnt, kind, stm); |
| 90 | if (ret != RT_SUCCESS) { | 90 | if (ret != RT_SUCCESS) { |
| 91 | MACHINE_LOGE(RtErr::RT_MEMCPY_FAILED, | 91 | MACHINE_LOGE(RtErr::RT_MEMCPY_FAILED, |
| 92 | - "RuntimeMemcpyAsync failed: func=%s, file=%s:%d, ret=%d, kind=%d, size=%lu, dst=%p, src=%p", func, | 92 | + "RuntimeMemcpyAsync failed: func=%s, file=%s:%d, ret=%d, kind=%d, size=%lu bytes, dst=%p, src=%p", |
| 93 | - file, line, static_cast<int>(ret), static_cast<int>(kind), cnt, dst, src); | 93 | + func, file, line, static_cast<int>(ret), static_cast<int>(kind), cnt, dst, src); |
| 94 | MACHINE_ASSERT(false) << "RuntimeMemcpyAsync failed, ret=" << static_cast<int>(ret); | 94 | MACHINE_ASSERT(false) << "RuntimeMemcpyAsync failed, ret=" << static_cast<int>(ret); |
| 95 | } | 95 | } |
| 96 | } | 96 | } |
| @@ -142,11 +142,11 @@ inline void* DevMallocWithAlignSize(const uint64_t size, const RtMemType memType | |||
| 142 | { | 142 | { |
| 143 | uint8_t* devPtr = nullptr; | 143 | uint8_t* devPtr = nullptr; |
| 144 | if (RuntimeMalloc(reinterpret_cast<void**>(&devPtr), AlignSize(size), memType, 0) != 0) { | 144 | if (RuntimeMalloc(reinterpret_cast<void**>(&devPtr), AlignSize(size), memType, 0) != 0) { |
| 145 | - MACHINE_LOGW("Fail to malloc dev memory with size[%lu] and mem type[%u].", size, memType); | 145 | + MACHINE_LOGW("Fail to malloc dev memory with size[%lu] bytes and mem type[%u].", size, memType); |
| 146 | return nullptr; | 146 | return nullptr; |
| 147 | } | 147 | } |
| 148 | if (RuntimeMemset(devPtr, AlignSize(size), 0, AlignSize(size)) != 0) { | 148 | if (RuntimeMemset(devPtr, AlignSize(size), 0, AlignSize(size)) != 0) { |
| 149 | - MACHINE_LOGW("Fail to memset of size[%lu].", size); | 149 | + MACHINE_LOGW("Fail to memset of size[%lu] bytes.", size); |
| 150 | RuntimeFree(devPtr); | 150 | RuntimeFree(devPtr); |
| 151 | return nullptr; | 151 | return nullptr; |
| 152 | } | 152 | } |
| @@ -48,7 +48,7 @@ inline bool InitAicoreModelCoreAddrs(DeviceMemoryTy& devMem, DevAscendProgram* d | |||
| 48 | auto allocAndAssign = [&](uint64_t& addr, size_t bytes, const char* name) { | 48 | auto allocAndAssign = [&](uint64_t& addr, size_t bytes, const char* name) { |
| 49 | auto* ptr = devMem.AllocZero(bytes, nullptr); | 49 | auto* ptr = devMem.AllocZero(bytes, nullptr); |
| 50 | if (ptr == nullptr) { | 50 | if (ptr == nullptr) { |
| 51 | - MACHINE_LOGE(DevCommonErr::ALLOC_FAILED, "Alloc aicore model host %s failed, size=%zu", name, bytes); | 51 | + MACHINE_LOGE(DevCommonErr::ALLOC_FAILED, "Alloc aicore model host %s failed, size=%zu bytes", name, bytes); |
| 52 | addr = 0; | 52 | addr = 0; |
| 53 | return false; | 53 | return false; |
| 54 | } | 54 | } |
| @@ -81,7 +81,8 @@ inline bool InitAicoreModelMetrics(DeviceMemoryTy& devMem, DevAscendProgram* dev | |||
| 81 | auto* args = reinterpret_cast<KernelArgs*>(sharedBuffer + static_cast<size_t>(i) * SHARED_BUFFER_SIZE); | 81 | auto* args = reinterpret_cast<KernelArgs*>(sharedBuffer + static_cast<size_t>(i) * SHARED_BUFFER_SIZE); |
| 82 | auto* metric = devMem.AllocZero(metricSize, nullptr); | 82 | auto* metric = devMem.AllocZero(metricSize, nullptr); |
| 83 | if (metric == nullptr) { | 83 | if (metric == nullptr) { |
| 84 | - MACHINE_LOGE(DevCommonErr::ALLOC_FAILED, "Alloc aicore model host metric failed, core=%u", i); | 84 | + MACHINE_LOGE(DevCommonErr::ALLOC_FAILED, "Alloc aicore model host metric failed, size=%zu bytes, coreId=%u", |
| 85 | + metricSize, i); | ||
| 85 | devProg->devArgs.sharedBuffer = 0; | 86 | devProg->devArgs.sharedBuffer = 0; |
| 86 | return false; | 87 | return false; |
| 87 | } | 88 | } |
| @@ -161,7 +161,7 @@ uint64_t CalcGeneralMetadataSlotWorkspace(DevAscendProgram* devProg) | |||
| 161 | itemPoolMemSize, vectorMemSize, slotAllocatorMemSize); | 161 | itemPoolMemSize, vectorMemSize, slotAllocatorMemSize); |
| 162 | static constexpr uint64_t AICPU_SLOT_STATIC_MEMSIZE = 2 * MEBI; | 162 | static constexpr uint64_t AICPU_SLOT_STATIC_MEMSIZE = 2 * MEBI; |
| 163 | generalMetadataSlotSize = itemPoolMemSize + vectorMemSize + slotAllocatorMemSize + AICPU_SLOT_STATIC_MEMSIZE; | 163 | generalMetadataSlotSize = itemPoolMemSize + vectorMemSize + slotAllocatorMemSize + AICPU_SLOT_STATIC_MEMSIZE; |
| 164 | - MACHINE_LOGI("[workspaceSize] Workspace of generalMetadataSlotSize is %lu., ", generalMetadataSlotSize); | 164 | + MACHINE_LOGI("[workspaceSize] Workspace of generalMetadataSlotSize is %lu bytes., ", generalMetadataSlotSize); |
| 165 | return generalMetadataSlotSize; | 165 | return generalMetadataSlotSize; |
| 166 | } | 166 | } |
| 167 | 167 | ||
| @@ -215,7 +215,7 @@ uint64_t CalcStitchWorkspace(DevAscendProgram& devProg) | |||
| 215 | uint32_t requiredSlabNum = ((objUsedNum[i] << 2) + slabCapacity[i] - 1) / slabCapacity[i]; | 215 | uint32_t requiredSlabNum = ((objUsedNum[i] << 2) + slabCapacity[i] - 1) / slabCapacity[i]; |
| 216 | stitchPoolSize += slabSize * requiredSlabNum; | 216 | stitchPoolSize += slabSize * requiredSlabNum; |
| 217 | } | 217 | } |
| 218 | - MACHINE_LOGD("[workspaceSize] Stitch pool size is %lu, with slab size:%u.", stitchPoolSize, slabSize); | 218 | + MACHINE_LOGD("[workspaceSize] Stitch pool size is %lu bytes, with slab size:%u bytes.", stitchPoolSize, slabSize); |
| 219 | return (stitchPoolSize + SLAB_ALIGN_GRANULARITY) * devProg.GetParallelism(); | 219 | return (stitchPoolSize + SLAB_ALIGN_GRANULARITY) * devProg.GetParallelism(); |
| 220 | } | 220 | } |
| 221 | 221 | ||
| @@ -249,7 +249,7 @@ uint64_t CalcStitchCacheSize(DevAscendProgram* devProg) | |||
| 249 | } | 249 | } |
| 250 | uint64_t cacheSize = static_cast<uint64_t>(devProg->rootFuncMaxCallOpsize) * devProg->rootFuncMaxCallOpsize * | 250 | uint64_t cacheSize = static_cast<uint64_t>(devProg->rootFuncMaxCallOpsize) * devProg->rootFuncMaxCallOpsize * |
| 251 | sizeof(uint64_t); | 251 | sizeof(uint64_t); |
| 252 | - MACHINE_LOGI("stitchCacheSize: %lu, maxCallOpsize: %u", cacheSize, devProg->rootFuncMaxCallOpsize); | 252 | + MACHINE_LOGI("stitchCacheSize: %lu bytes, maxCallOpsize: %u", cacheSize, devProg->rootFuncMaxCallOpsize); |
| 253 | return cacheSize; | 253 | return cacheSize; |
| 254 | } | 254 | } |
| 255 | 255 | ||
| @@ -299,10 +299,13 @@ void LogWorkspaceEncodeSummary(int kMin, uint32_t stitchNumMax, const DevAscendP | |||
| 299 | const StitchDepthConfig& depthConfig, uint64_t maxWorkspaceBytes, | 299 | const StitchDepthConfig& depthConfig, uint64_t maxWorkspaceBytes, |
| 300 | uint64_t workspaceStitchMin) | 300 | uint64_t workspaceStitchMin) |
| 301 | { | 301 | { |
| 302 | - MACHINE_LOGI("[workspaceSize] stitch depth: k_min=%d, stitchNumMax=%u, k_eff=%u, outcastCacheDepth=%u, " | 302 | + MACHINE_LOGI("[workspaceSize] stitch depth: k_min=%d, stitchNumMax=%u, k_eff=%u, " |
| 303 | - "runtimeOutcastPoolDepth=%u, devTaskBoundaryOutcastNum=%lu, devTaskInnerTemporalOutcastNum=%lu, " | 303 | + "outcastCacheDepth=%u, " |
| 304 | - "stitchMax=%u, stitch_1=%lu, encoded_tensor_budget=%lu, context_workspace=%lu, metadata=%lu, " | 304 | + "runtimeOutcastPoolDepth=%u, devTaskBoundaryOutcastNum=%lu, " |
| 305 | - "max_workspace_kb=%lu, memory_driven=%d, runtimeOutcastPoolSize=%u.", | 305 | + "devTaskInnerTemporalOutcastNum=%lu, " |
| 306 | + "stitchMax=%u, stitch_1=%lu bytes, encoded_tensor_budget=%lu bytes, context_workspace=%lu bytes, " | ||
| 307 | + "metadata=%lu bytes, " | ||
| 308 | + "max_workspace_kb=%lu KB, memory_driven=%d, runtimeOutcastPoolSize=%u bytes.", | ||
| 306 | kMin, stitchNumMax, depthConfig.kEff, depthConfig.outcastCacheDepth, | 309 | kMin, stitchNumMax, depthConfig.kEff, depthConfig.outcastCacheDepth, |
| 307 | depthConfig.runtimeOutcastPoolDepth, devProg.memBudget.tensor.devTaskBoundaryOutcastNum, | 310 | depthConfig.runtimeOutcastPoolDepth, devProg.memBudget.tensor.devTaskBoundaryOutcastNum, |
| 308 | devProg.memBudget.tensor.devTaskInnerTemporalOutcastNum, devProg.stitchMaxFunctionNum, | 311 | devProg.memBudget.tensor.devTaskInnerTemporalOutcastNum, devProg.stitchMaxFunctionNum, |
| @@ -700,7 +700,7 @@ private: | |||
| 700 | auto pyalloc = py::getattr(module, "alloc"); | 700 | auto pyalloc = py::getattr(module, "alloc"); |
| 701 | wsAddr = (int64_t*)pyalloc(wsSize).cast<int64_t>(); | 701 | wsAddr = (int64_t*)pyalloc(wsSize).cast<int64_t>(); |
| 702 | } | 702 | } |
| 703 | - COMPILER_LOGD("alloc workspace %ld", wsSize); | 703 | + COMPILER_LOGD("alloc workspace %ld bytes", wsSize); |
| 704 | HOST_PERF_TRACE(TracePhase::LaunchAllocWorkSpace); | 704 | HOST_PERF_TRACE(TracePhase::LaunchAllocWorkSpace); |
| 705 | 705 | ||
| 706 | uint8_t* ctrlFlowCache = DeviceLauncher::PrepareLaunch(kbinary, tensors, rtModel, kmodule->GetLaunchMode()); | 706 | uint8_t* ctrlFlowCache = DeviceLauncher::PrepareLaunch(kbinary, tensors, rtModel, kmodule->GetLaunchMode()); |