已合并
【PR】: remove SOMA calls from other APIs for 9.1.0 release #3308
chenlong360创建于 7月2日
【PR】: remove SOMA calls from other APIs for 9.1.0 release #3308
已合并
共 4 个文件变更+7-154
| @@ -230,16 +230,7 @@ int main() { | |||
| 230 | aclError aclrtMemPoolCreate(aclrtMemPool *memPool, const aclrtMemPoolProps *poolProps) | 230 | aclError aclrtMemPoolCreate(aclrtMemPool *memPool, const aclrtMemPoolProps *poolProps) |
| 231 | ``` | 231 | ``` |
| 232 | 232 | ||
| 233 | -**须知:本接口为试验特性,后续版本可能会存在变更,不支持应用于商用产品中。** | 233 | +**须知:本接口为预留接口,暂不支持。** |
| 234 | - | ||
| 235 | -### 产品支持情况 | ||
| 236 | - | ||
| 237 | - | ||
| 238 | -| 产品 | 是否支持 | | ||
| 239 | -| --- | :---: | | ||
| 240 | -| Ascend 950PR/Ascend 950DT | ☓ | | ||
| 241 | -| Atlas A3 训练系列产品/Atlas A3 推理系列产品 | ☓ | | ||
| 242 | -| Atlas A2 训练系列产品/Atlas A2 推理系列产品 | √ | | ||
| 243 | 234 | ||
| 244 | ### 功能说明 | 235 | ### 功能说明 |
| 245 | 236 | ||
| @@ -272,16 +263,7 @@ aclError aclrtMemPoolCreate(aclrtMemPool *memPool, const aclrtMemPoolProps *pool | |||
| 272 | aclError aclrtMemPoolDestroy(const aclrtMemPool memPool) | 263 | aclError aclrtMemPoolDestroy(const aclrtMemPool memPool) |
| 273 | ``` | 264 | ``` |
| 274 | 265 | ||
| 275 | -**须知:本接口为试验特性,后续版本可能会存在变更,不支持应用于商用产品中。** | 266 | +**须知:本接口为预留接口,暂不支持。** |
| 276 | - | ||
| 277 | -### 产品支持情况 | ||
| 278 | - | ||
| 279 | - | ||
| 280 | -| 产品 | 是否支持 | | ||
| 281 | -| --- | :---: | | ||
| 282 | -| Ascend 950PR/Ascend 950DT | ☓ | | ||
| 283 | -| Atlas A3 训练系列产品/Atlas A3 推理系列产品 | ☓ | | ||
| 284 | -| Atlas A2 训练系列产品/Atlas A2 推理系列产品 | √ | | ||
| 285 | 267 | ||
| 286 | ### 功能说明 | 268 | ### 功能说明 |
| 287 | 269 | ||
| @@ -313,16 +295,7 @@ aclError aclrtMemPoolDestroy(const aclrtMemPool memPool) | |||
| 313 | aclError aclrtMemPoolSetAttr(aclrtMemPool memPool, aclrtMemPoolAttr attr, void *value) | 295 | aclError aclrtMemPoolSetAttr(aclrtMemPool memPool, aclrtMemPoolAttr attr, void *value) |
| 314 | ``` | 296 | ``` |
| 315 | 297 | ||
| 316 | -**须知:本接口为试验特性,后续版本可能会存在变更,不支持应用于商用产品中。** | 298 | +**须知:本接口为预留接口,暂不支持。** |
| 317 | - | ||
| 318 | -### 产品支持情况 | ||
| 319 | - | ||
| 320 | - | ||
| 321 | -| 产品 | 是否支持 | | ||
| 322 | -| --- | :---: | | ||
| 323 | -| Ascend 950PR/Ascend 950DT | ☓ | | ||
| 324 | -| Atlas A3 训练系列产品/Atlas A3 推理系列产品 | ☓ | | ||
| 325 | -| Atlas A2 训练系列产品/Atlas A2 推理系列产品 | √ | | ||
| 326 | 299 | ||
| 327 | ### 功能说明 | 300 | ### 功能说明 |
| 328 | 301 | ||
| @@ -358,16 +331,7 @@ aclError aclrtMemPoolSetAttr(aclrtMemPool memPool, aclrtMemPoolAttr attr, void * | |||
| 358 | aclError aclrtMemPoolGetAttr(aclrtMemPool memPool, aclrtMemPoolAttr attr, void *value) | 331 | aclError aclrtMemPoolGetAttr(aclrtMemPool memPool, aclrtMemPoolAttr attr, void *value) |
| 359 | ``` | 332 | ``` |
| 360 | 333 | ||
| 361 | -**须知:本接口为试验特性,后续版本可能会存在变更,不支持应用于商用产品中。** | 334 | +**须知:本接口为预留接口,暂不支持。** |
| 362 | - | ||
| 363 | -### 产品支持情况 | ||
| 364 | - | ||
| 365 | - | ||
| 366 | -| 产品 | 是否支持 | | ||
| 367 | -| --- | :---: | | ||
| 368 | -| Ascend 950PR/Ascend 950DT | ☓ | | ||
| 369 | -| Atlas A3 训练系列产品/Atlas A3 推理系列产品 | ☓ | | ||
| 370 | -| Atlas A2 训练系列产品/Atlas A2 推理系列产品 | √ | | ||
| 371 | 335 | ||
| 372 | ### 功能说明 | 336 | ### 功能说明 |
| 373 | 337 | ||
| @@ -403,16 +367,7 @@ aclError aclrtMemPoolGetAttr(aclrtMemPool memPool, aclrtMemPoolAttr attr, void * | |||
| 403 | aclError aclrtMemPoolMallocAsync(void **ptr, size_t size, aclrtMemPool memPool, aclrtStream stream) | 367 | aclError aclrtMemPoolMallocAsync(void **ptr, size_t size, aclrtMemPool memPool, aclrtStream stream) |
| 404 | ``` | 368 | ``` |
| 405 | 369 | ||
| 406 | -**须知:本接口为试验特性,后续版本可能会存在变更,不支持应用于商用产品中。** | 370 | +**须知:本接口为预留接口,暂不支持。** |
| 407 | - | ||
| 408 | -### 产品支持情况 | ||
| 409 | - | ||
| 410 | - | ||
| 411 | -| 产品 | 是否支持 | | ||
| 412 | -| ------------------------------------------- | :------: | | ||
| 413 | -| Ascend 950PR/Ascend 950DT | ☓ | | ||
| 414 | -| Atlas A3 训练系列产品/Atlas A3 推理系列产品 | ☓ | | ||
| 415 | -| Atlas A2 训练系列产品/Atlas A2 推理系列产品 | √ | | ||
| 416 | 371 | ||
| 417 | ### 功能说明 | 372 | ### 功能说明 |
| 418 | 373 | ||
| @@ -447,57 +402,7 @@ aclError aclrtMemPoolMallocAsync(void **ptr, size_t size, aclrtMemPool memPool, | |||
| 447 | aclError aclrtMemPoolFreeAsync(void *ptr, aclrtStream stream) | 402 | aclError aclrtMemPoolFreeAsync(void *ptr, aclrtStream stream) |
| 448 | ``` | 403 | ``` |
| 449 | 404 | ||
| 450 | -**须知:本接口为试验特性,后续版本可能会存在变更,不支持应用于商用产品中。** | 405 | +**须知:本接口为预留接口,暂不支持。** |
| 451 | - | ||
| 452 | -### 产品支持情况 | ||
| 453 | - | ||
| 454 | - | ||
| 455 | -| 产品 | 是否支持 | | ||
| 456 | -| ------------------------------------------- | :------: | | ||
| 457 | -| Ascend 950PR/Ascend 950DT | ☓ | | ||
| 458 | -| Atlas A3 训练系列产品/Atlas A3 推理系列产品 | ☓ | | ||
| 459 | -| Atlas A2 训练系列产品/Atlas A2 推理系列产品 | √ | | ||
| 460 | - | ||
| 461 | -### 功能说明 | ||
| 462 | - | ||
| 463 | -销毁通过[aclrtMemPoolMallocAsync](#aclrtMemPoolMallocAsync)接口申请的内存,仅将内存归还给内存池,而不是实际释放物理内存。异步接口。 | ||
| 464 | - | ||
| 465 | -### 参数说明 | ||
| 466 | - | ||
| 467 | - | ||
| 468 | -| 参数名 | 输入/输出 | 说明 | | ||
| 469 | -| ------- | :-------: | ------------------------------------------------------------ | | ||
| 470 | -| ptr | 输入 | 指向待释放内存地址的指针。 | | ||
| 471 | -| memPool | 输入 | 指定执行内存释放任务的Stream。类型定义请参见[aclrtStream](25_数据类型及其操作接口.md#aclrtStream)。 | | ||
| 472 | - | ||
| 473 | -### 返回值说明 | ||
| 474 | - | ||
| 475 | -返回0表示成功,返回其他值表示失败,请参见[aclError](25_数据类型及其操作接口.md#aclError)。 | ||
| 476 | - | ||
| 477 | -<br> | ||
| 478 | -<br> | ||
| 479 | -<br> | ||
| 480 | - | ||
| 481 | - | ||
| 482 | - | ||
| 483 | -<a id="aclrtMemPoolFreeAsync"></a> | ||
| 484 | - | ||
| 485 | -## aclrtMemPoolFreeAsync | ||
C | |||
| 486 | - | ||
| 487 | -```c | ||
| 488 | -aclError aclrtMemPoolFreeAsync(void *ptr, aclrtStream stream) | ||
| 489 | -``` | ||
| 490 | - | ||
| 491 | -**须知:本接口为试验特性,后续版本可能会存在变更,不支持应用于商用产品中。** | ||
| 492 | - | ||
| 493 | -### 产品支持情况 | ||
| 494 | - | ||
| 495 | - | ||
| 496 | -| 产品 | 是否支持 | | ||
| 497 | -| ------------------------------------------- | :------: | | ||
| 498 | -| Ascend 950PR/Ascend 950DT | ☓ | | ||
| 499 | -| Atlas A3 训练系列产品/Atlas A3 推理系列产品 | ☓ | | ||
| 500 | -| Atlas A2 训练系列产品/Atlas A2 推理系列产品 | √ | | ||
| 501 | 406 | ||
| 502 | ### 功能说明 | 407 | ### 功能说明 |
| 503 | 408 | ||
| @@ -529,16 +434,7 @@ aclError aclrtMemPoolFreeAsync(void *ptr, aclrtStream stream) | |||
| 529 | aclError aclrtMemPoolTrimTo(aclrtMemPool memPool, size_t minBytesToKeep) | 434 | aclError aclrtMemPoolTrimTo(aclrtMemPool memPool, size_t minBytesToKeep) |
| 530 | ``` | 435 | ``` |
| 531 | 436 | ||
| 532 | -**须知:本接口为试验特性,后续版本可能会存在变更,不支持应用于商用产品中。** | 437 | +**须知:本接口为预留接口,暂不支持。** |
| 533 | - | ||
| 534 | -### 产品支持情况 | ||
| 535 | - | ||
| 536 | - | ||
| 537 | -| 产品 | 是否支持 | | ||
| 538 | -| ------------------------------------------- | :------: | | ||
| 539 | -| Ascend 950PR/Ascend 950DT | ☓ | | ||
| 540 | -| Atlas A3 训练系列产品/Atlas A3 推理系列产品 | ☓ | | ||
| 541 | -| Atlas A2 训练系列产品/Atlas A2 推理系列产品 | √ | | ||
| 542 | 438 | ||
| 543 | ### 功能说明 | 439 | ### 功能说明 |
| 544 | 440 | ||
| @@ -1673,13 +1673,6 @@ rtError_t ApiImpl::StreamSynchronize(Stream * const stm, const int32_t timeout) | |||
| 1673 | RT_LOG(RT_LOG_INFO, "Ctx switch back, stream_id=%d, current ctx=%#" PRIx64, | 1673 | RT_LOG(RT_LOG_INFO, "Ctx switch back, stream_id=%d, current ctx=%#" PRIx64, |
| 1674 | curStm->Id_(), static_cast<uint64_t>(reinterpret_cast<uintptr_t>(CurrentContext()))); | 1674 | curStm->Id_(), static_cast<uint64_t>(reinterpret_cast<uintptr_t>(CurrentContext()))); |
| 1675 | } | 1675 | } |
| 1676 | - | ||
| 1677 | - RT_LOG(RT_LOG_INFO, "Trigger implicit mempool trim (exclude graph pool)."); | ||
| 1678 | - rtError_t trimRet = Runtime::Instance()->ApiSoma_()->MemPoolTrimImplicit(false); | ||
| 1679 | - if (trimRet != RT_ERROR_NONE) { | ||
| 1680 | - RT_LOG(RT_LOG_WARNING, "Implicit mempool trim with errors, ret=%d.", trimRet); | ||
| 1681 | - } | ||
| 1682 | - | ||
| 1683 | return errCode; | 1676 | return errCode; |
| 1684 | } | 1677 | } |
| 1685 | 1678 | ||
| @@ -1996,7 +1989,6 @@ rtError_t ApiImpl::EventCreateEx(Event ** const evt, const uint64_t flag) | |||
| 1996 | 1989 | ||
| 1997 | rtError_t ApiImpl::EventDestroy(Event *evt) | 1990 | rtError_t ApiImpl::EventDestroy(Event *evt) |
| 1998 | { | 1991 | { |
| 1999 | - EventStateCallbackManager::Instance().Notify(nullptr, evt, EventStatePeriod::EVENT_STATE_PERIOD_DESTROY); | ||
| 2000 | if (evt->GetEventFlag() == RT_EVENT_IPC) { | 1992 | if (evt->GetEventFlag() == RT_EVENT_IPC) { |
| 2001 | IpcEvent *eventIpc = dynamic_cast<IpcEvent *>(evt); | 1993 | IpcEvent *eventIpc = dynamic_cast<IpcEvent *>(evt); |
| 2002 | IpcEventDestroy(&eventIpc, MAX_INT32_NUM, true); | 1994 | IpcEventDestroy(&eventIpc, MAX_INT32_NUM, true); |
| @@ -2135,12 +2127,6 @@ rtError_t ApiImpl::EventSynchronize(Event * const evt, const int32_t timeout) | |||
| 2135 | error = evt->Synchronize(timeout); | 2127 | error = evt->Synchronize(timeout); |
| 2136 | } | 2128 | } |
| 2137 | ERROR_RETURN(error, "Synchronize event failed."); | 2129 | ERROR_RETURN(error, "Synchronize event failed."); |
| 2138 | - RT_LOG(RT_LOG_INFO, "Event synchronize success, trigger implicit mempool trim (exclude graph pool)."); | ||
| 2139 | - rtError_t trimRet = Runtime::Instance()->ApiSoma_()->MemPoolTrimImplicit(false); | ||
| 2140 | - if (trimRet != RT_ERROR_NONE) { | ||
| 2141 | - RT_LOG(RT_LOG_WARNING, "Implicit mempool trim with errors, ret=%d.", trimRet); | ||
| 2142 | - } | ||
| 2143 | - | ||
| 2144 | return error; | 2130 | return error; |
| 2145 | } | 2131 | } |
| 2146 | 2132 | ||
| @@ -2218,15 +2204,6 @@ rtError_t ApiImpl::DevMalloc(void ** const devPtr, const uint64_t size, const rt | |||
| 2218 | auto driver = curCtx->Device_()->Driver_(); | 2204 | auto driver = curCtx->Device_()->Driver_(); |
| 2219 | uint32_t devId = curCtx->Device_()->Id_(); | 2205 | uint32_t devId = curCtx->Device_()->Id_(); |
| 2220 | rtError_t ret = driver->DevMemAlloc(devPtr, tmpSize, type, devId, moduleId); | 2206 | rtError_t ret = driver->DevMemAlloc(devPtr, tmpSize, type, devId, moduleId); |
| 2221 | - if (ret != RT_ERROR_NONE) { | ||
| 2222 | - RT_LOG(RT_LOG_INFO, "DevMemAlloc first try not successful, ret=%d, trigger implicit mempool trim.", ret); | ||
| 2223 | - rtError_t trimRet = Runtime::Instance()->ApiSoma_()->MemPoolTrimImplicit(true); | ||
| 2224 | - if (trimRet != RT_ERROR_NONE) { | ||
| 2225 | - RT_LOG(RT_LOG_WARNING, "Implicit mempool trim with errors, ret=%d.", trimRet); | ||
| 2226 | - } | ||
| 2227 | - ret = driver->DevMemAlloc(devPtr, tmpSize, type, devId, moduleId); | ||
| 2228 | - COND_RETURN_ERROR(ret != RT_ERROR_NONE, ret, "DevMemAlloc retry after trim failed, ret=%d.", ret); | ||
| 2229 | - } | ||
| 2230 | return ret; | 2207 | return ret; |
| 2231 | } | 2208 | } |
| 2232 | 2209 | ||
| @@ -2235,11 +2212,6 @@ rtError_t ApiImpl::DevFree(void * const devPtr) | |||
| 2235 | RT_LOG(RT_LOG_INFO, "device free mem=0x%llx", reinterpret_cast<uint64_t *>(devPtr)); | 2212 | RT_LOG(RT_LOG_INFO, "device free mem=0x%llx", reinterpret_cast<uint64_t *>(devPtr)); |
| 2236 | Context * const curCtx = CurrentContext(false); | 2213 | Context * const curCtx = CurrentContext(false); |
| 2237 | rtError_t error = DevFreeStatic(devPtr, curCtx); | 2214 | rtError_t error = DevFreeStatic(devPtr, curCtx); |
| 2238 | - if ((error == RT_ERROR_NONE) && Runtime::Instance()->ApiSoma_()->InMemPoolRegion(devPtr)) { | ||
| 2239 | - RT_LOG(RT_LOG_INFO, "Pointer %#" PRIx64 " is in SOMA memory pool range, assuming it's allocated by async api.", | ||
| 2240 | - RtPtrToValue(devPtr)); | ||
| 2241 | - return Runtime::Instance()->ApiSoma_()->MemPoolFreeSync(devPtr); | ||
| 2242 | - } | ||
| 2243 | return error; | 2215 | return error; |
| 2244 | } | 2216 | } |
| 2245 | 2217 | ||
| @@ -3741,13 +3713,6 @@ rtError_t ApiImpl::DeviceSynchronize(const int32_t timeout) | |||
| 3741 | Context * const curCtx = CurrentContext(); | 3713 | Context * const curCtx = CurrentContext(); |
| 3742 | CHECK_CONTEXT_VALID_WITH_RETURN(curCtx, RT_ERROR_CONTEXT_NULL); | 3714 | CHECK_CONTEXT_VALID_WITH_RETURN(curCtx, RT_ERROR_CONTEXT_NULL); |
| 3743 | rtError_t error = curCtx->Synchronize(timeout); | 3715 | rtError_t error = curCtx->Synchronize(timeout); |
| 3744 | - | ||
| 3745 | - RT_LOG(RT_LOG_INFO, "Trigger implicit mempool trim (exclude graph pool)."); | ||
| 3746 | - rtError_t trimRet = Runtime::Instance()->ApiSoma_()->MemPoolTrimImplicit(false); | ||
| 3747 | - if (trimRet != RT_ERROR_NONE) { | ||
| 3748 | - RT_LOG(RT_LOG_WARNING, "Implicit mempool trim with errors, ret=%d.", trimRet); | ||
| 3749 | - } | ||
| 3750 | - | ||
| 3751 | return error; | 3716 | return error; |
| 3752 | } | 3717 | } |
| 3753 | 3718 | ||
| @@ -455,7 +455,6 @@ rtError_t Event::Record(Stream * const stm, const bool isApiCall) | |||
| 455 | static_cast<uint32_t>(error)); | 455 | static_cast<uint32_t>(error)); |
| 456 | if (isApiCall) { | 456 | if (isApiCall) { |
| 457 | GET_THREAD_TASKID_AND_STREAMID(tsk, stm->AllocTaskStreamId()); | 457 | GET_THREAD_TASKID_AND_STREAMID(tsk, stm->AllocTaskStreamId()); |
| 458 | - EventStateCallbackManager::Instance().Notify(stm, this, EventStatePeriod::EVENT_STATE_PERIOD_RECORD); | ||
| 459 | } | 458 | } |
| 460 | isNotify_ = false; | 459 | isNotify_ = false; |
| 461 | return RT_ERROR_NONE; | 460 | return RT_ERROR_NONE; |
| @@ -555,7 +554,6 @@ rtError_t Event::Wait(Stream * const stm, const uint32_t timeout) | |||
| 555 | ERROR_GOTO_MSG_INNER(error, ERROR_RECYCLE, "Failed to submit wait task, retCode=%#x.", | 554 | ERROR_GOTO_MSG_INNER(error, ERROR_RECYCLE, "Failed to submit wait task, retCode=%#x.", |
| 556 | static_cast<uint32_t>(error)); | 555 | static_cast<uint32_t>(error)); |
| 557 | GET_THREAD_TASKID_AND_STREAMID(tsk, stm->AllocTaskStreamId()); | 556 | GET_THREAD_TASKID_AND_STREAMID(tsk, stm->AllocTaskStreamId()); |
| 558 | - EventStateCallbackManager::Instance().Notify(stm, this, EventStatePeriod::EVENT_STATE_PERIOD_WAIT); | ||
| 559 | return RT_ERROR_NONE; | 557 | return RT_ERROR_NONE; |
| 560 | 558 | ||
| 561 | ERROR_RECYCLE: | 559 | ERROR_RECYCLE: |
| @@ -502,12 +502,6 @@ rtError_t PoolRegistry::Init() | |||
| 502 | return RT_ERROR_MEMORY_ALLOCATION; | 502 | return RT_ERROR_MEMORY_ALLOCATION; |
| 503 | } | 503 | } |
| 504 | RT_LOG(RT_LOG_DEBUG, "Init mem address success, devptr=%#" PRIx64 ".", globalSegment_->basePtr); | 504 | RT_LOG(RT_LOG_DEBUG, "Init mem address success, devptr=%#" PRIx64 ".", globalSegment_->basePtr); |
| 505 | - rtError_t error = RegisterSomaCallBack(); | ||
| 506 | - if (error != RT_ERROR_NONE) { | ||
| 507 | - RT_LOG(RT_LOG_ERROR, "Soma Callback register failed, reCode=%#x.", error); | ||
| 508 | - DeleteManager(poolAllocator_); | ||
| 509 | - return error; | ||
| 510 | - } | ||
| 511 | return RT_ERROR_NONE; | 505 | return RT_ERROR_NONE; |
| 512 | } | 506 | } |
| 513 | 507 | ||
aclrtMemPoolFreeAsync一节重复了