LCOV - code coverage report
Current view: top level - legacy/ascend950/framework/resource_manager/transport - cnt_notify_res_helper.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 55.9 % 34 19
Test Date: 2026-08-17 10:19:35 Functions: 100.0 % 2 2

            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              : #include "cnt_notify_res_helper.h"
      11              : #include "binary_stream.h"
      12              : namespace Hccl {
      13              : BaseMemTransport::LocCntNotifyRes
      14            5 : CntNotifyResHelper::GetCntNotifyRes(const unordered_map<u32, vector<LocalCntNotify*>>& topicIdCntNotifyVecMap) const
      15              : {
      16            5 :     u32 cntNotifyNum = 0;
      17            5 :     for (auto& it : topicIdCntNotifyVecMap) {
      18            0 :         cntNotifyNum += it.second.size();
      19              :     }
      20              : 
      21            5 :     BinaryStream binaryStream;
      22            5 :     BaseMemTransport::LocCntNotifyRes result;
      23            5 :     binaryStream << cntNotifyNum;
      24              : 
      25            5 :     u32 cntNotifyIndex = 0;
      26            5 :     for (auto& it : topicIdCntNotifyVecMap) {
      27            0 :         auto topicId = it.first;
      28            0 :         u32 pos = 0;
      29            0 :         for (auto& notify : it.second) {
      30            0 :             binaryStream << topicId;
      31            0 :             binaryStream << pos;
      32            0 :             binaryStream << cntNotifyIndex;
      33            0 :             result.vec.push_back(notify);
      34            0 :             cntNotifyIndex++;
      35            0 :             pos++;
      36              :         }
      37              :     }
      38            5 :     binaryStream.Dump(result.desc);
      39            5 :     return result;
      40            5 : }
      41              : 
      42            4 : u32 CntNotifyResHelper::GetIndex(vector<char>& desc, u32 topicId, u32 pos) const
      43              : {
      44            4 :     BinaryStream binaryStream(desc);
      45            4 :     u32 cntNotifyNum = 0;
      46            4 :     binaryStream >> cntNotifyNum;
      47            4 :     for (u32 index = 0; index < cntNotifyNum; index++) {
      48              :         u32 theTopicId;
      49              :         u32 thePos;
      50              :         u32 theCntNotifyIndex;
      51            0 :         binaryStream >> theTopicId;
      52            0 :         binaryStream >> thePos;
      53            0 :         binaryStream >> theCntNotifyIndex;
      54            0 :         if (theTopicId == topicId && thePos == pos) {
      55            0 :             return theCntNotifyIndex;
      56              :         }
      57              :     }
      58           12 :     HCCL_ERROR("cannot find topicId=%u, pos=%u in desc=%s", topicId, pos, Bytes2hex(desc.data(), desc.size()).c_str());
      59            4 :     return 0;
      60            4 : }
      61              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1