LCOV - code coverage report
Current view: top level - coll_communicator_mgr/resource_mgr/local/my_rank/comm_engine/threads/order_launch_thread_mgr - order_launch_thread_mgr.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 80.8 % 255 206
Test Date: 2026-08-17 10:19:35 Functions: 84.2 % 19 16

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2026 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : #include "order_launch_thread_mgr.h"
      11              : #include "exception_util.h"
      12              : #include "acl/acl_rt.h"
      13              : #include "orion_adapter_rts.h"
      14              : #include "coll_comm.h"
      15              : #include "hcclCommOp.h"
      16              : #include "sal_pub.h"
      17              : #include "dlprof_function.h"
      18              : #include "hcomm_c_adpt.h"
      19              : 
      20              : namespace hccl {
      21              : 
      22              : constexpr u32 ORDER_THREAD_NOTIFY_NUM = 1;
      23              : 
      24           22 : static u32 GetAicpuBlockNum(s32 deviceLogicId)
      25              : {
      26           22 :     int64_t coreNum = 0;
      27           22 :     aclError ret = aclrtGetDeviceInfo(static_cast<uint32_t>(deviceLogicId), ACL_DEV_ATTR_AICPU_CORE_NUM, &coreNum);
      28           22 :     HCCL_INFO(
      29              :         "[GetAicpuBlockNum] deviceLogicId[%d], aclrtGetDeviceInfo ret[%d], coreNum[%lld]", deviceLogicId, ret, coreNum);
      30           22 :     if (ret != ACL_SUCCESS || coreNum <= 0) {
      31            5 :         HCCL_WARNING(
      32              :             "[GetAicpuBlockNum] aclrtGetDeviceInfo failed, ret[%d], coreNum[%lld], use default 1", ret, coreNum);
      33            5 :         return 1U;
      34              :     }
      35           17 :     HCCL_INFO("[GetAicpuBlockNum] success, aicpuCoreNum[%u]", static_cast<u32>(coreNum));
      36           17 :     return static_cast<u32>(coreNum);
      37              : }
      38              : 
      39              : /* ============================ OrderLaunchContextRes ============================ */
      40              : 
      41           12 : void OrderLaunchContextRes::DestroyResources()
      42              : {
      43           12 :     if (opbaseThread != 0) {
      44            3 :         HcommResult ret = HcommThreadFree(&opbaseThread, 1);
      45            3 :         if (ret != HCCL_SUCCESS) {
      46            3 :             HCCL_WARNING(
      47              :                 "[OrderLaunchContextRes] HcommThreadFree opbaseThread[0x%llx] failed, ret[%d]", opbaseThread, ret);
      48              :         }
      49            3 :         opbaseThread = 0;
      50              :     }
      51           12 :     if (aclgraphThread != 0) {
      52            2 :         HcommResult ret = HcommThreadFree(&aclgraphThread, 1);
      53            2 :         if (ret != HCCL_SUCCESS) {
      54            2 :             HCCL_WARNING(
      55              :                 "[OrderLaunchContextRes] HcommThreadFree aclgraphThread[0x%llx] failed, ret[%d]", aclgraphThread, ret);
      56              :         }
      57            2 :         aclgraphThread = 0;
      58              :     }
      59           12 :     resValid = false;
      60           12 :     HCCL_INFO("[OrderLaunchContextRes] resources destroyed, context[0x%llx]", context);
      61           12 : }
      62              : 
      63              : /* ============================ OrderLaunchThreadMgr ============================ */
      64              : 
      65          621 : OrderLaunchThreadMgr::OrderLaunchThreadMgr() {}
      66              : 
      67          621 : OrderLaunchThreadMgr::~OrderLaunchThreadMgr()
      68              : {
      69          621 :     std::unique_lock<std::mutex> lock(mutex_);
      70          621 :     Destroy();
      71          621 : }
      72              : 
      73          621 : void OrderLaunchThreadMgr::Destroy()
      74              : {
      75          633 :     for (auto& entry : contextResMap_) {
      76           12 :         entry.second.DestroyResources();
      77              :     }
      78          621 :     contextResMap_.clear();
      79          621 :     contextGroupsMap_.clear();
      80          621 :     groupCtxMap_.clear();
      81              : 
      82          628 :     for (auto& entry : hcomAttachedThreadMap_) {
      83            7 :         if (entry.second != 0) {
      84            7 :             HcommResult ret = HcommThreadFreeWithStream(&entry.second, 1);
      85            7 :             if (ret != HCCL_SUCCESS) {
      86            0 :                 HCCL_WARNING(
      87              :                     "[OrderLaunchThreadMgr] HcommThreadFreeWithStream hcomAttachedThread[0x%llx] failed, ret[%d]",
      88              :                     entry.second, ret);
      89              :             }
      90            7 :             entry.second = 0;
      91              :         }
      92              :     }
      93          621 :     hcomAttachedThreadMap_.clear();
      94          621 :     groupGraphMap_.clear();
      95              : 
      96          624 :     for (auto& entry : groupDeviceThreadMap_) {
      97            3 :         if (entry.second != 0) {
      98            3 :             HcommResult ret = HcommThreadFree(&entry.second, 1);
      99            3 :             if (ret != HCCL_SUCCESS) {
     100            3 :                 HCCL_WARNING(
     101              :                     "[OrderLaunchThreadMgr] HcommThreadFree deviceOrderThread[0x%llx] failed, ret[%d], group[%s]",
     102              :                     entry.second, ret, entry.first.c_str());
     103              :             }
     104            3 :             entry.second = 0;
     105              :         }
     106              :     }
     107          621 :     groupDeviceThreadMap_.clear();
     108          621 : }
     109              : 
     110          192 : HcclResult OrderLaunchThreadMgr::RegisterOrderLaunch(const std::string& group)
     111              : {
     112          192 :     std::unique_lock<std::mutex> lock(mutex_);
     113          192 :     if (groupCtxMap_.find(group) != groupCtxMap_.end()) {
     114            3 :         HCCL_WARNING("%s skip, group[%s] has already been registered", __func__, group.c_str());
     115            3 :         return HCCL_SUCCESS;
     116              :     }
     117          189 :     groupCtxMap_.insert({group, UINT64_MAX});
     118          189 :     HCCL_INFO("%s success, group[%s]", __func__, group.c_str());
     119          189 :     return HCCL_SUCCESS;
     120          192 : }
     121              : 
     122          165 : HcclResult OrderLaunchThreadMgr::UnRegisterOrderLaunch(const std::string& group)
     123              : {
     124          165 :     std::unique_lock<std::mutex> lock(mutex_);
     125          165 :     auto it = groupCtxMap_.find(group);
     126          165 :     if (it == groupCtxMap_.end()) {
     127            9 :         HCCL_WARNING("%s skip, group[%s] has not been registered", __func__, group.c_str());
     128            9 :         return HCCL_SUCCESS;
     129              :     }
     130              : 
     131          156 :     u64 context = it->second;
     132          156 :     HCCL_INFO("[OrderLaunchThreadMgr][%s] group[%s] context[0x%llx]", __func__, group.c_str(), context);
     133              : 
     134          156 :     auto ctxIt = contextGroupsMap_.find(context);
     135          156 :     if (ctxIt != contextGroupsMap_.end()) {
     136            0 :         ctxIt->second.erase(group);
     137            0 :         if (ctxIt->second.empty()) {
     138            0 :             contextGroupsMap_.erase(ctxIt);
     139            0 :             auto resIt = contextResMap_.find(context);
     140            0 :             if (resIt != contextResMap_.end()) {
     141            0 :                 resIt->second.DestroyResources();
     142            0 :                 contextResMap_.erase(resIt);
     143              :             }
     144            0 :             HCCL_INFO("%s contextGroupsMap_ erase context[0x%llx]", __func__, context);
     145              :         }
     146              :     }
     147              : 
     148          156 :     groupCtxMap_.erase(it);
     149              : 
     150          156 :     auto devIt = groupDeviceThreadMap_.find(group);
     151          156 :     if (devIt != groupDeviceThreadMap_.end() && devIt->second != 0) {
     152            0 :         HcommResult ret = HcommThreadFree(&devIt->second, 1);
     153            0 :         if (ret != HCCL_SUCCESS) {
     154            0 :             HCCL_WARNING(
     155              :                 "[OrderLaunchThreadMgr][%s] HcommThreadFree deviceOrderThread[0x%llx] failed, ret[%d], group[%s]",
     156              :                 __func__, devIt->second, ret, group.c_str());
     157              :         }
     158            0 :         groupDeviceThreadMap_.erase(devIt);
     159              :     }
     160              : 
     161          156 :     HCCL_INFO("%s success, group[%s]", __func__, group.c_str());
     162          156 :     return HCCL_SUCCESS;
     163          165 : }
     164              : 
     165           38 : HcclResult OrderLaunchThreadMgr::GetCurrentContext(u64& currentContext)
     166              : {
     167           38 :     aclrtContext rtCtx = nullptr;
     168           38 :     aclError ret = aclrtGetCurrentContext(&rtCtx);
     169           38 :     CHK_PRT_RET(
     170              :         ret != ACL_SUCCESS, HCCL_ERROR("[%s]aclrtGetCurrentContext failed, ret[%d]", __func__, ret), HCCL_E_RUNTIME);
     171           37 :     currentContext = reinterpret_cast<u64>(rtCtx);
     172           37 :     CHK_PRT_RET(
     173              :         currentContext == UINT64_MAX, HCCL_ERROR("[%s]GetCurrentContext failed, context is INVALID_U64", __func__),
     174              :         HCCL_E_RUNTIME);
     175           37 :     return HCCL_SUCCESS;
     176              : }
     177              : 
     178           19 : HcclResult OrderLaunchThreadMgr::EnsureContextRes(u64 context)
     179              : {
     180           19 :     if (contextResMap_.find(context) == contextResMap_.end()) {
     181           12 :         contextResMap_.emplace(context, OrderLaunchContextRes());
     182           12 :         HCCL_INFO(
     183              :             "[OrderLaunchThreadMgr][%s] created new OrderLaunchContextRes for context[0x%llx]", __func__, context);
     184              :     }
     185           19 :     return HCCL_SUCCESS;
     186              : }
     187              : 
     188           10 : HcclResult OrderLaunchThreadMgr::SetAttachedStream(const std::string& group, u32 graphId, void* stream)
     189              : {
     190           10 :     CHK_PRT_RET(stream == nullptr, HCCL_ERROR("[%s] stream is nullptr, graphId[%u]", __func__, graphId), HCCL_E_PTR);
     191              : 
     192            9 :     std::unique_lock<std::mutex> lock(mutex_);
     193              : 
     194            9 :     ThreadHandle thread = 0;
     195            9 :     HcommResult ret = HcommThreadAllocWithStream(COMM_ENGINE_CPU_TS, stream, ORDER_THREAD_NOTIFY_NUM, &thread);
     196            9 :     CHK_PRT_RET(
     197              :         ret != HCCL_SUCCESS,
     198              :         HCCL_ERROR("[%s] HcommThreadAllocWithStream failed, ret[%d], graphId[%u]", __func__, ret, graphId),
     199              :         static_cast<HcclResult>(ret));
     200              : 
     201            8 :     hcomAttachedThreadMap_[graphId] = thread;
     202            8 :     groupGraphMap_[group] = graphId;
     203            8 :     HCCL_INFO(
     204              :         "%s success, group[%s], graphId[%u], stream[%p], thread[0x%llx]", __func__, group.c_str(), graphId, stream,
     205              :         thread);
     206            8 :     return HCCL_SUCCESS;
     207            9 : }
     208              : 
     209           37 : void OrderLaunchThreadMgr::UpdateGroupContextMapping(const std::string& group, u64 currentContext)
     210              : {
     211           37 :     auto groupIt = groupCtxMap_.find(group);
     212           37 :     if (groupIt != groupCtxMap_.end() && groupIt->second != currentContext) {
     213           16 :         HCCL_INFO(
     214              :             "[OrderLaunchThreadMgr][%s] group[%s] context updated: [0x%llx] -> [0x%llx]", __func__, group.c_str(),
     215              :             groupIt->second, currentContext);
     216           16 :         if (groupIt->second != UINT64_MAX) {
     217            0 :             auto oldCtxIt = contextGroupsMap_.find(groupIt->second);
     218            0 :             if (oldCtxIt != contextGroupsMap_.end()) {
     219            0 :                 oldCtxIt->second.erase(group);
     220            0 :                 if (oldCtxIt->second.empty()) {
     221            0 :                     contextGroupsMap_.erase(oldCtxIt);
     222              :                 }
     223              :             }
     224              :         }
     225           16 :         groupIt->second = currentContext;
     226           16 :         contextGroupsMap_[currentContext].insert(group);
     227           21 :     } else if (groupIt == groupCtxMap_.end()) {
     228           20 :         groupCtxMap_[group] = currentContext;
     229           20 :         contextGroupsMap_[currentContext].insert(group);
     230              :     }
     231           37 : }
     232              : 
     233           37 : bool OrderLaunchThreadMgr::IsOrderLaunchDisabled(u64 currentContext)
     234              : {
     235           37 :     if (blockNum_ == 0U) {
     236           22 :         blockNum_ = GetAicpuBlockNum(static_cast<s32>(Hccl::HrtGetDevice()));
     237              :     }
     238           37 :     if (blockNum_ == 0U) {
     239            0 :         return false;
     240              :     }
     241           37 :     auto ctxGroupsIt = contextGroupsMap_.find(currentContext);
     242           37 :     u32 groupCount = (ctxGroupsIt != contextGroupsMap_.end()) ? static_cast<u32>(ctxGroupsIt->second.size()) : 0U;
     243           37 :     HCCL_INFO(
     244              :         "[OrderLaunchThreadMgr][%s] blockNum[%u] groupCount[%u] context[0x%llx]", __func__, blockNum_, groupCount,
     245              :         currentContext);
     246           37 :     return groupCount <= blockNum_;
     247              : }
     248              : 
     249           20 : HcclResult OrderLaunchThreadMgr::EnsureOrderThread(
     250              :     OrderThreadMode mode, const std::string& group, uint32_t notifyNumPerThread, ThreadHandle& thread)
     251              : {
     252           20 :     std::unique_lock<std::mutex> lock(mutex_);
     253           20 :     thread = 0;
     254              : 
     255           20 :     u64 currentContext = UINT64_MAX;
     256           20 :     CHK_RET(GetCurrentContext(currentContext));
     257           19 :     CHK_RET(EnsureContextRes(currentContext));
     258              : 
     259           19 :     auto& ctxRes = contextResMap_[currentContext];
     260              : 
     261           19 :     UpdateGroupContextMapping(group, currentContext);
     262              : 
     263           19 :     if (IsOrderLaunchDisabled(currentContext)) {
     264           12 :         HCCL_INFO(
     265              :             "[OrderLaunchThreadMgr][%s] order launch disabled, group[%s], context[0x%llx]", __func__, group.c_str(),
     266              :             currentContext);
     267           12 :         thread = 0;
     268           12 :         return HCCL_SUCCESS;
     269              :     }
     270              : 
     271            7 :     ThreadHandle& targetThread = (mode == OrderThreadMode::ACLGRAPH) ? ctxRes.aclgraphThread : ctxRes.opbaseThread;
     272              : 
     273            7 :     if (targetThread == 0) {
     274            6 :         HCCL_INFO(
     275              :             "[OrderLaunchThreadMgr][%s] creating new order thread, context[0x%llx], mode[%u], notifyNumPerThread[%u]",
     276              :             __func__, currentContext, static_cast<u8>(mode), notifyNumPerThread);
     277              : 
     278            6 :         HcommResult ret = HcommThreadAlloc(COMM_ENGINE_CPU_TS, 1, &notifyNumPerThread, &targetThread);
     279            6 :         CHK_PRT_RET(
     280              :             ret != HCCL_SUCCESS,
     281              :             HCCL_ERROR("[%s] HcommThreadAlloc failed, ret[%d], mode[%u]", __func__, ret, static_cast<u8>(mode)),
     282              :             static_cast<HcclResult>(ret));
     283              : 
     284            5 :         ctxRes.resValid = true;
     285            5 :         HCCL_INFO(
     286              :             "[OrderLaunchThreadMgr] Created new order thread[0x%llx], context[0x%llx], mode[%u]", targetThread,
     287              :             currentContext, static_cast<u8>(mode));
     288              :     } else {
     289            1 :         HCCL_INFO(
     290              :             "[OrderLaunchThreadMgr][%s] order thread already exists, context[0x%llx], thread[0x%llx]", __func__,
     291              :             currentContext, targetThread);
     292              :     }
     293              : 
     294            6 :     thread = targetThread;
     295            6 :     return HCCL_SUCCESS;
     296           20 : }
     297              : 
     298           12 : HcclResult OrderLaunchThreadMgr::EnsureDeviceOrderThread(
     299              :     const std::string& group, uint32_t notifyNumPerThread, ThreadHandle& thread)
     300              : {
     301           12 :     std::unique_lock<std::mutex> lock(mutex_);
     302           12 :     thread = 0;
     303              : 
     304           12 :     u64 currentContext = UINT64_MAX;
     305           12 :     CHK_RET(GetCurrentContext(currentContext));
     306           12 :     UpdateGroupContextMapping(group, currentContext);
     307           12 :     if (IsOrderLaunchDisabled(currentContext)) {
     308            8 :         HCCL_INFO(
     309              :             "[OrderLaunchThreadMgr][%s] order launch disabled, group[%s], context[0x%llx]", __func__, group.c_str(),
     310              :             currentContext);
     311            8 :         thread = 0;
     312            8 :         return HCCL_SUCCESS;
     313              :     }
     314              : 
     315            4 :     auto it = groupDeviceThreadMap_.find(group);
     316            4 :     if (it != groupDeviceThreadMap_.end() && it->second != 0) {
     317            0 :         thread = it->second;
     318            0 :         HCCL_INFO(
     319              :             "[OrderLaunchThreadMgr][%s] reuse device order thread[0x%llx], group[%s]", __func__, thread, group.c_str());
     320            0 :         return HCCL_SUCCESS;
     321              :     }
     322              : 
     323            4 :     HCCL_INFO(
     324              :         "[OrderLaunchThreadMgr][%s] creating new device order thread, group[%s], notifyNumPerThread[%u]", __func__,
     325              :         group.c_str(), notifyNumPerThread);
     326              : 
     327            4 :     ThreadHandle targetThread = 0;
     328            4 :     HcommResult ret = HcommThreadAlloc(COMM_ENGINE_AICPU_TS, 1, &notifyNumPerThread, &targetThread);
     329            4 :     CHK_PRT_RET(
     330              :         ret != HCCL_SUCCESS,
     331              :         HCCL_ERROR("[%s] HcommThreadAlloc failed, ret[%d], group[%s]", __func__, ret, group.c_str()),
     332              :         static_cast<HcclResult>(ret));
     333              : 
     334            3 :     thread = targetThread;
     335            3 :     groupDeviceThreadMap_[group] = targetThread;
     336            3 :     HCCL_INFO("[OrderLaunchThreadMgr] Created new device order thread[0x%llx], group[%s]", targetThread, group.c_str());
     337            3 :     return HCCL_SUCCESS;
     338           12 : }
     339              : 
     340            6 : ThreadHandle OrderLaunchThreadMgr::GetHcomAttachedThreadByGroup(const std::string& group)
     341              : {
     342            6 :     std::unique_lock<std::mutex> lock(mutex_);
     343              : 
     344            6 :     u64 currentContext = UINT64_MAX;
     345            6 :     if (GetCurrentContext(currentContext) != HCCL_SUCCESS) {
     346            0 :         HCCL_WARNING("[%s] GetCurrentContext failed, group[%s]", __func__, group.c_str());
     347            0 :         return 0;
     348              :     }
     349            6 :     UpdateGroupContextMapping(group, currentContext);
     350            6 :     if (IsOrderLaunchDisabled(currentContext)) {
     351            3 :         HCCL_INFO(
     352              :             "[OrderLaunchThreadMgr][%s] order launch disabled, group[%s], context[0x%llx]", __func__, group.c_str(),
     353              :             currentContext);
     354            3 :         return 0;
     355              :     }
     356              : 
     357            3 :     auto graphIt = groupGraphMap_.find(group);
     358            3 :     if (graphIt == groupGraphMap_.end()) {
     359            1 :         HCCL_WARNING(
     360              :             "[%s] graphId not found for group[%s], please call HcomSetAttachedStream first", __func__, group.c_str());
     361            1 :         return 0;
     362              :     }
     363            2 :     u32 graphId = graphIt->second;
     364              : 
     365            2 :     auto attachedThreadIt = hcomAttachedThreadMap_.find(graphId);
     366            2 :     if (attachedThreadIt == hcomAttachedThreadMap_.end() || attachedThreadIt->second == 0) {
     367            0 :         HCCL_ERROR(
     368              :             "[%s] hcomThread not found for group[%s], graphId[%u], please call HcomSetAttachedStream first", __func__,
     369              :             group.c_str(), graphId);
     370            0 :         return 0;
     371              :     }
     372            2 :     HCCL_INFO(
     373              :         "[%s] success, group[%s], graphId[%u], thread[0x%llx]", __func__, group.c_str(), graphId,
     374              :         attachedThreadIt->second);
     375            2 :     return attachedThreadIt->second;
     376            6 : }
     377              : 
     378            0 : HcclResult OrderLaunchThreadMgr::RegisterThreadToComm(CollComm* collComm, ThreadHandle thread)
     379              : {
     380            0 :     CommEngineResMgr* engineResMgr = collComm->GetCommEngineResMgr();
     381            0 :     if (engineResMgr != nullptr) {
     382            0 :         CHK_RET(engineResMgr->RegisterOrderLaunchThread(thread));
     383              :     }
     384            0 :     return HCCL_SUCCESS;
     385              : }
     386              : 
     387            0 : HcclResult OrderLaunchThreadMgr::RegisterDfx(
     388              :     CollComm* collComm, HcclDedicatedThreadType useType, ThreadHandle thread, u64 beginTime, const std::string& commId)
     389              : {
     390            0 :     if (useType == HCCL_DED_THREAD_TYPE_AICPU_ORDER_LAUNCH_DEVICE) {
     391            0 :         HcclCommDfx* hcclCommDfx = collComm->GetHcclCommDfx();
     392            0 :         if (hcclCommDfx != nullptr) {
     393            0 :             const std::string kernelName = "RunAicpuThreadInit";
     394            0 :             CHK_RET(hcclCommDfx->ReportKernel(beginTime, commId, kernelName, SalGetTid(), false));
     395            0 :             HCCL_INFO("[%s] DEVICE order launch thread ReportKernel done, comm[%s]", __func__, commId.c_str());
     396            0 :         }
     397              :     } else {
     398              :         std::function<HcclResult(u32, u32, const Hccl::TaskParam&, u64)> dfxCallback
     399            0 :             = [](u32 streamId, u32 taskId, const Hccl::TaskParam& taskParam, u64 handle) {
     400              :                   (void)streamId;
     401              :                   (void)taskId;
     402              :                   (void)taskParam;
     403              :                   (void)handle;
     404            0 :                   return HCCL_SUCCESS;
     405            0 :               };
     406            0 :         int ret = HcommThreadRegisterDfx(thread, dfxCallback);
     407            0 :         if (ret != 0) {
     408            0 :             HCCL_WARNING("[%s] HcommThreadRegisterDfx failed, ret[%d], thread[0x%llx]", __func__, ret, thread);
     409              :         }
     410            0 :     }
     411            0 :     return HCCL_SUCCESS;
     412              : }
     413              : 
     414            6 : HcclResult OrderLaunchThreadMgr::OrderLaunchThreadAcquire(
     415              :     HcclDedicatedThreadType useType, CollComm* collComm, const std::string& group, uint32_t notifyNumPerThread,
     416              :     ThreadHandle& thread)
     417              : {
     418            6 :     thread = 0;
     419              : 
     420            6 :     HCCL_INFO(
     421              :         "[%s] begin, useType[%d], group[%s], notifyNumPerThread[%u]", __func__, static_cast<s32>(useType),
     422              :         group.c_str(), notifyNumPerThread);
     423              : 
     424            6 :     u64 beginTime = Hccl::DlProfFunction::GetInstance().dlMsprofSysCycleTime();
     425              : 
     426            6 :     switch (useType) {
     427            1 :         case HCCL_DED_THREAD_TYPE_AICPU_ORDER_LAUNCH_OPBASE: {
     428            1 :             HcclResult ret = EnsureOrderThread(OrderThreadMode::OPBASE, group, notifyNumPerThread, thread);
     429            1 :             CHK_PRT_RET(
     430              :                 ret != HCCL_SUCCESS, HCCL_ERROR("[%s] EnsureOrderThread OPBASE failed, ret[%d]", __func__, ret), ret);
     431            1 :             break;
     432              :         }
     433            1 :         case HCCL_DED_THREAD_TYPE_AICPU_ORDER_LAUNCH_ACLGRAPH: {
     434            1 :             HcclResult ret = EnsureOrderThread(OrderThreadMode::ACLGRAPH, group, notifyNumPerThread, thread);
     435            1 :             CHK_PRT_RET(
     436              :                 ret != HCCL_SUCCESS, HCCL_ERROR("[%s] EnsureOrderThread ACLGRAPH failed, ret[%d]", __func__, ret), ret);
     437            1 :             break;
     438              :         }
     439            2 :         case HCCL_DED_THREAD_TYPE_AICPU_ORDER_LAUNCH_GE: {
     440            2 :             ThreadHandle th = GetHcomAttachedThreadByGroup(group);
     441            2 :             thread = th;
     442            2 :             CHK_PRT_RET(
     443              :                 th == 0,
     444              :                 HCCL_WARNING(
     445              :                     "[%s] GetHcomAttachedThreadByGroup failed, group[%s], please call HcomSetAttachedStream first",
     446              :                     __func__, group.c_str()),
     447              :                 HCCL_SUCCESS);
     448            1 :             break;
     449              :         }
     450            1 :         case HCCL_DED_THREAD_TYPE_AICPU_ORDER_LAUNCH_DEVICE: {
     451            1 :             HcclResult ret = EnsureDeviceOrderThread(group, notifyNumPerThread, thread);
     452            1 :             CHK_PRT_RET(
     453              :                 ret != HCCL_SUCCESS, HCCL_ERROR("[%s] EnsureDeviceOrderThread failed, ret[%d]", __func__, ret), ret);
     454            1 :             break;
     455              :         }
     456            1 :         default:
     457            1 :             HCCL_ERROR("[%s] invalid useType[%d] for order launch", __func__, static_cast<s32>(useType));
     458            1 :             return HCCL_E_PARA;
     459              :     }
     460              : 
     461            4 :     if (thread != 0 && collComm != nullptr && useType != HCCL_DED_THREAD_TYPE_AICPU_ORDER_LAUNCH_DEVICE) {
     462            0 :         CHK_RET(RegisterThreadToComm(collComm, thread));
     463            0 :         CHK_RET(RegisterDfx(collComm, useType, thread, beginTime, group));
     464              :     }
     465              : 
     466            4 :     HCCL_INFO("[%s] success, useType[%d], thread[0x%llx]", __func__, static_cast<s32>(useType), thread);
     467            4 :     return HCCL_SUCCESS;
     468              : }
     469              : 
     470              : } // namespace hccl
        

Generated by: LCOV version 2.0-1