LCOV - code coverage report
Current view: top level - coll_communicator_mgr/team/hcomm - hcomm_team_c_adpt.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 86.0 % 43 37
Test Date: 2026-08-17 10:19:35 Functions: 88.9 % 9 8

            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              : 
      11              : #include "hcomm_team_c_adpt.h"
      12              : #include "hcomm_team.h"
      13              : #include "hcomm_team_mgr.h"
      14              : #include "hcomm_result_defs.h"
      15              : #include "hcomm_team_entity_defs.h"
      16              : #include "log.h"
      17              : 
      18              : using namespace hcomm;
      19              : 
      20           64 : HcommResult HcommTeamCreate(
      21              :     HcommTeamHandle worldTeam, const HcommTeamCreateDesc* desc, HcommTeamHandle* team, uint64_t* outSyncMemSize)
      22              : {
      23           64 :     CHK_PRT_RET(
      24              :         (desc == nullptr || team == nullptr || outSyncMemSize == nullptr),
      25              :         HCCL_ERROR("[%s] nullptr parameter", __func__), HCOMM_E_PTR);
      26           61 :     CHK_PRT_RET(
      27              :         (desc->memberNum == 0 || desc->memberNum == 1), HCCL_ERROR("[%s] memberNum cannot be 0 or 1", __func__),
      28              :         HCOMM_E_PARA);
      29           59 :     CHK_PRT_RET(
      30              :         desc->selfMemberId >= desc->memberNum,
      31              :         HCCL_ERROR("[%s] selfMemberId[%u] >= memberNum[%u]", __func__, desc->selfMemberId, desc->memberNum),
      32              :         HCOMM_E_PARA);
      33           58 :     CHK_PRT_RET(
      34              :         (desc->requirement.signalCount != 0 || desc->requirement.counterCount != 0),
      35              :         HCCL_ERROR(
      36              :             "[%s] signalCount[%u] and counterCount[%u] must be 0", __func__, desc->requirement.signalCount,
      37              :             desc->requirement.counterCount),
      38              :         HCOMM_E_PARA);
      39           58 :     CHK_PRT_RET(
      40              :         desc->requirement.barrierCount == 0, HCCL_ERROR("[%s] barrierCount must be >= 1", __func__), HCOMM_E_PARA);
      41           56 :     CHK_PRT_RET(
      42              :         worldTeam != nullptr && desc->worldMemberIds == nullptr,
      43              :         HCCL_ERROR("[%s] sub team worldMemberIds is null", __func__), HCOMM_E_PTR);
      44           55 :     return HcommTeamMgr::GetInstance().TeamCreate(worldTeam, desc, team, outSyncMemSize);
      45              : }
      46              : 
      47           15 : HcommResult HcommTeamDestroy(HcommTeamHandle team)
      48              : {
      49           15 :     CHK_PRT_RET(team == nullptr, HCCL_ERROR("[%s] team is nullptr", __func__), HCOMM_E_PTR);
      50           14 :     return HcommTeamMgr::GetInstance().TeamDestroy(team);
      51              : }
      52              : 
      53           12 : HcommResult HcommTeamBindChannels(HcommTeamHandle team, const HcommTeamBindChannelsDesc* desc)
      54              : {
      55           12 :     if (team == nullptr || desc == nullptr || desc->channelNumPerMember == nullptr
      56            9 :         || desc->channelsByMemberId == nullptr) {
      57            4 :         HCCL_ERROR("[%s] nullptr parameter", __func__);
      58            4 :         return HCOMM_E_PTR;
      59              :     }
      60            8 :     return HcommTeamMgr::GetInstance().BindChannels(team, desc);
      61              : }
      62              : 
      63           15 : HcommResult HcommTeamBindRemoteSyncMem(HcommTeamHandle team, const HcommTeamBindSyncMemDesc* desc)
      64              : {
      65           15 :     CHK_PRT_RET((team == nullptr || desc == nullptr), HCCL_ERROR("[%s] nullptr parameter", __func__), HCOMM_E_PTR);
      66           13 :     CHK_PRT_RET(desc->remoteMems == nullptr, HCCL_ERROR("[%s] remoteMems is nullptr", __func__), HCOMM_E_PTR);
      67           12 :     CHK_PRT_RET(desc->remoteMemNum == 0, HCCL_ERROR("[%s] remoteMemNum is zero", __func__), HCOMM_E_PARA);
      68           12 :     return HcommTeamMgr::GetInstance().BindSyncMem(team, desc);
      69              : }
      70              : 
      71           22 : HcommResult HcommTeamWindowRegister(
      72              :     HcommTeamHandle worldTeam, const HcommTeamWindowDesc* desc, HcommWindowHandle* handle, HcommTeamWindowFlag flag)
      73              : {
      74           22 :     CHK_PRT_RET(
      75              :         (worldTeam == nullptr || handle == nullptr), HCCL_ERROR("[%s] nullptr parameter", __func__), HCOMM_E_PTR);
      76           20 :     CHK_PRT_RET(
      77              :         flag != HCOMM_TEAM_WINDOW_FLAG_SYMMETRIC,
      78              :         HCCL_ERROR("[%s] flag[%d] is not supported, only support 0", __func__, flag), HCOMM_E_PARA);
      79              :     /* desc 当前由后续 HcommTeamWindowBindRemoteMems 单独绑定 window 的 mems,注册阶段不消费,允许为 nullptr。 */
      80              :     (void)desc;
      81           20 :     return HcommTeamMgr::GetInstance().WindowRegister(worldTeam, handle);
      82              : }
      83              : 
      84              : HcommResult
      85           17 : HcommTeamWindowBindRemoteMems(HcommTeamHandle team, HcommWindowHandle handle, const HcommTeamWindowDesc* desc)
      86              : {
      87           17 :     if (team == nullptr || handle == nullptr || desc == nullptr || desc->mems == nullptr) {
      88            4 :         HCCL_ERROR("[%s] nullptr parameter", __func__);
      89            4 :         return HCOMM_E_PTR;
      90              :     }
      91           13 :     return HcommTeamMgr::GetInstance().BindWindow(team, handle, desc);
      92              : }
      93              : 
      94            7 : HcommResult HcommTeamWindowDeregister(HcommTeamHandle worldTeam, HcommWindowHandle handle)
      95              : {
      96            7 :     CHK_PRT_RET(
      97              :         (worldTeam == nullptr || handle == nullptr), HCCL_ERROR("[%s] nullptr parameter", __func__), HCOMM_E_PTR);
      98            6 :     return HcommTeamMgr::GetInstance().WindowDeregister(worldTeam, handle);
      99              : }
     100              : 
     101            4 : HcommResult HcommTeamGetNetLayer(HcommTeamHandle team, uint32_t* netLayer)
     102              : {
     103            4 :     CHK_PRT_RET((team == nullptr || netLayer == nullptr), HCCL_ERROR("[%s] nullptr parameter", __func__), HCOMM_E_PTR);
     104            2 :     return HcommTeamMgr::GetInstance().GetNetLayer(team, netLayer);
     105              : }
     106              : 
     107            0 : HcommResult HcommTeamIsSubBelongToWorld(HcommTeamHandle worldTeam, HcommTeamHandle subTeam, bool* isBelong)
     108              : {
     109            0 :     CHK_PTR_NULL(worldTeam);
     110            0 :     CHK_PTR_NULL(subTeam);
     111            0 :     CHK_PTR_NULL(isBelong);
     112            0 :     HCCL_ERROR("[%s] not support", __func__);
     113            0 :     return HCOMM_E_NOT_SUPPORT;
     114              : }
        

Generated by: LCOV version 2.0-1