LCOV - code coverage report
Current view: top level - coll_communicator_mgr/api_c_adpt - hccl_channel_config.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 94.7 % 38 36
Test Date: 2026-08-29 17:38:31 Functions: 100.0 % 4 4

            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_channel_config.h"
      12              : #include "hccl/hccl_channel.h"
      13              : #include "log.h"
      14              : #include "exception_handler.h"
      15              : 
      16           10 : HcclResult HcclChannelConfigCreate(HcclChannelConfig* config)
      17              : {
      18           10 :     CHK_PTR_NULL(config);
      19            9 :     NEW_NOTHROW(*config, hccl::HcclChannelConfigData(), return HCCL_E_PTR);
      20            9 :     return HCCL_SUCCESS;
      21              : }
      22              : 
      23           10 : HcclResult HcclChannelConfigDestroy(HcclChannelConfig config)
      24              : {
      25           10 :     CHK_PTR_NULL(config);
      26            9 :     auto* cfg = static_cast<hccl::HcclChannelConfigData*>(config);
      27            9 :     if (cfg->destroyed_.exchange(true)) {
      28            0 :         HCCL_WARNING("[%s] config[%p] is already destroyed, skip to avoid double-free.", __func__, config);
      29            0 :         return HCCL_SUCCESS;
      30              :     }
      31            9 :     delete cfg;
      32            9 :     return HCCL_SUCCESS;
      33              : }
      34              : 
      35            4 : HcclResult HcclChannelConfigSetInt(HcclChannelConfig config, HcclChannelConfigType type, uint32_t value)
      36              : {
      37            4 :     CHK_PTR_NULL(config);
      38            3 :     auto* cfg = static_cast<hccl::HcclChannelConfigData*>(config);
      39            3 :     switch (type) {
      40            2 :         case HCCL_CHANNEL_CONFIG_TYPE_IS_SHARED_QUEUE:
      41            2 :             cfg->isSharedQueue = (value != 0);
      42            2 :             HCCL_INFO("[%s] set IS_SHARED_QUEUE=%d.", __func__, static_cast<int>(cfg->isSharedQueue));
      43            2 :             break;
      44            1 :         default:
      45            1 :             HCCL_ERROR("[%s] invalid int config type[%d].", __func__, static_cast<int>(type));
      46            1 :             return HCCL_E_PARA;
      47              :     }
      48            2 :     return HCCL_SUCCESS;
      49              : }
      50              : 
      51            6 : HcclResult HcclChannelConfigSetStr(HcclChannelConfig config, HcclChannelConfigType type, const char* value)
      52              : {
      53            6 :     CHK_PTR_NULL(config);
      54            5 :     CHK_PTR_NULL(value);
      55            4 :     auto* cfg = static_cast<hccl::HcclChannelConfigData*>(config);
      56            4 :     switch (type) {
      57            3 :         case HCCL_CHANNEL_CONFIG_TYPE_SHARED_QUEUE_TAG:
      58            3 :             CHK_PRT_RET(
      59              :                 strlen(value) == 0 || strlen(value) > HCCL_CHANNEL_CONFIG_SHARED_QUEUE_TAG_MAX_LEN,
      60              :                 HCCL_ERROR(
      61              :                     "[%s] SHARED_QUEUE_TAG length[%zu] must be in (0, %u].", __func__, strlen(value),
      62              :                     HCCL_CHANNEL_CONFIG_SHARED_QUEUE_TAG_MAX_LEN),
      63              :                 HCCL_E_PARA);
      64            2 :             cfg->sharedQueueTag = std::string(value);
      65            2 :             HCCL_INFO("[%s] set SHARED_QUEUE_TAG=%s.", __func__, cfg->sharedQueueTag.c_str());
      66            2 :             break;
      67            1 :         default:
      68            1 :             HCCL_ERROR("[%s] invalid str config type[%d].", __func__, static_cast<int>(type));
      69            1 :             return HCCL_E_PARA;
      70              :     }
      71            2 :     return HCCL_SUCCESS;
      72              : }
        

Generated by: LCOV version 2.0-1