LCOV - code coverage report
Current view: top level - legacy/ascend950/framework/resource_manager/notify - queue_bcast_post_cnt_notify_manager.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 97.3 % 37 36
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 8 8

            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 "queue_bcast_post_cnt_notify_manager.h"
      12              : 
      13              : namespace Hccl {
      14              : 
      15              : constexpr u32 CNTNOTIFY_MAX_NUM = 128;
      16              : 
      17          727 : QueueBcastPostCntNotifyManager::QueueBcastPostCntNotifyManager() {}
      18              : 
      19          727 : QueueBcastPostCntNotifyManager::~QueueBcastPostCntNotifyManager()
      20              : {
      21          727 :     DECTOR_TRY_CATCH("QueueBcastPostCntNotifyManager", Destroy());
      22          727 : }
      23              : 
      24            8 : void QueueBcastPostCntNotifyManager::ApplyFor(QId qid, u32 topicId)
      25              : {
      26           24 :     HCCL_INFO("[QueueBcastPostCntNotifyManager][%s] start, qid[%u] topicId[%u]", __func__, qid, topicId);
      27            8 :     if (notifyPool.size() >= CNTNOTIFY_MAX_NUM) {
      28            0 :         THROW<NotSupportException>(StringFormat(
      29              :             "Bcast counter notify pool size[%u] reach max size[%u] qid[%u] topicId[%u].", notifyPool.size(),
      30              :             CNTNOTIFY_MAX_NUM, qid, topicId));
      31              :     }
      32              : 
      33            8 :     const auto& pair = make_pair(qid, topicId);
      34            8 :     if (notifyPool[pair] == nullptr) {
      35            8 :         notifyPool[pair] = make_unique<Rts1ToNCntNotify>();
      36              :     }
      37            8 : }
      38              : 
      39           10 : Rts1ToNCntNotify* QueueBcastPostCntNotifyManager::Get(QId qid, u32 topicId)
      40              : {
      41           10 :     if (!IsExist(qid, topicId)) {
      42            9 :         HCCL_WARNING("Bcast Post count Notify for qid[%u] and topic Id[%u] does not exist", qid, topicId);
      43            3 :         return nullptr;
      44              :     }
      45              : 
      46            7 :     return notifyPool[make_pair(qid, topicId)].get();
      47              : }
      48              : 
      49            1 : bool QueueBcastPostCntNotifyManager::Release(QId qid, u32 topicId)
      50              : {
      51            1 :     if (!IsExist(qid, topicId)) {
      52            3 :         HCCL_WARNING("Bcast Post count Notify for qid[%u] and topic Id[%u] does not exist.", qid, topicId);
      53              :     }
      54            1 :     notifyPool.erase(make_pair(qid, topicId));
      55            1 :     return true;
      56              : }
      57              : 
      58           11 : bool QueueBcastPostCntNotifyManager::IsExist(QId qid, u32 topicId)
      59              : {
      60           11 :     return notifyPool.count(make_pair(qid, topicId)) != 0;
      61              : }
      62              : 
      63          728 : void QueueBcastPostCntNotifyManager::Destroy() { notifyPool.clear(); }
      64              : 
      65            4 : std::vector<char> QueueBcastPostCntNotifyManager::GetPackedData()
      66              : {
      67            4 :     std::vector<char> result;
      68            4 :     BinaryStream binaryStream;
      69              : 
      70            4 :     u32 poolSize = notifyPool.size();
      71            4 :     binaryStream << poolSize;
      72              : 
      73            8 :     for (auto& it : notifyPool) {
      74            4 :         binaryStream << it.first.first;
      75            4 :         binaryStream << it.first.second;
      76            4 :         binaryStream << it.second->GetUniqueId();
      77              :     }
      78            4 :     binaryStream.Dump(result);
      79            4 :     return result;
      80            4 : }
      81              : 
      82              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1