LCOV - code coverage report
Current view: top level - coll_communicator_mgr/api_c_adpt - coll_comm_ccu_c_adpt.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 7.4 % 27 2
Test Date: 2026-07-28 12:11:00 Functions: 50.0 % 2 1

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 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              : 
      11              : #include "hccl_ccu_res.h"
      12              : 
      13              : #include "hccl_comm_pub.h"
      14              : 
      15              : #include "exception_handler.h"
      16              : 
      17              : /**
      18              :  * @note 职责:集合通信的通信域CCU管理的C接口的C到C++适配
      19              :  */
      20            1 : HcclResult HcclCommAssignCcuIns([[maybe_unused]] HcclComm comm, [[maybe_unused]] CcuInsHandle insHandle)
      21              : {
      22            1 :     return HcclResult::HCCL_E_NOT_SUPPORT;
      23              : }
      24              : 
      25            0 : HcclResult HcclCommQueryCcuIns(HcclComm comm,
      26              :     CcuInsHandle *insHandles, uint32_t *insNum)
      27              : {
      28              :     EXCEPTION_HANDLE_BEGIN
      29              : 
      30            0 :     HcclUs startut = TIME_NOW();
      31              : 
      32            0 :     CHK_PTR_NULL(comm);
      33            0 :     auto *hcclComm = static_cast<hccl::hcclComm *>(comm);
      34            0 :     const auto &commId = hcclComm->GetIdentifier();
      35            0 :     HCCL_INFO("[%s] CommId[%s] query ccu instance.", __func__, commId.c_str());
      36              : 
      37            0 :     CHK_PTR_NULL(insHandles);
      38            0 :     CHK_PTR_NULL(insNum);
      39              : 
      40              :     // CCU不支持A5之前代际
      41            0 :     if (!hcclComm->IsCommunicatorV2()) {
      42            0 :         HCCL_WARNING("[%s] is not supported.", __func__);
      43            0 :         return HcclResult::HCCL_E_NOT_SUPPORT;
      44              :     }
      45              : 
      46            0 :     auto *collComm = hcclComm->GetCollComm();
      47            0 :     CHK_PTR_NULL(collComm);
      48            0 :     auto *myRank = collComm->GetMyRank();
      49            0 :     CHK_PTR_NULL(myRank);
      50              : 
      51              :     // 非CCU通信域允许查询,不认为是错误
      52            0 :     auto ccuInsHandle = myRank->GetCcuInstance();
      53            0 :     if (ccuInsHandle == 0) {
      54            0 :         auto opExpansionMode = myRank->GetOpExpansionMode();
      55            0 :         HCCL_WARNING("[%s] failed to get ccu instance, commId[%s] op expansion mode[%d].",
      56              :             __func__, commId.c_str(), opExpansionMode);
      57            0 :         return HcclResult::HCCL_E_UNAVAIL;
      58              :     }
      59              : 
      60            0 :     insHandles[0] = ccuInsHandle;
      61            0 :     *insNum = 1;
      62            0 :     HCCL_INFO("[%s] success, take time [%lld]us.",
      63              :         __func__, DURATION_US(TIME_NOW() - startut));
      64              :     
      65            0 :     EXCEPTION_HANDLE_END
      66            0 :     return HcclResult::HCCL_SUCCESS;
      67              : }
        

Generated by: LCOV version 2.0-1