LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/resource/notify - rts_cnt_notify.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 91.1 % 45 41
Test Date: 2026-07-28 12:11:00 Functions: 77.8 % 9 7

            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 "rts_cnt_notify.h"
      12              : #include "exception_util.h"
      13              : #include "task.h"
      14              : #include "dev_capability.h"
      15              : 
      16              : namespace Hccl {
      17              : 
      18           64 : RtsCntNotify::RtsCntNotify() : deviceId(HrtGetDevice()), devPhyId(HrtGetDevicePhyIdByIndex(HrtGetDevice())),
      19           64 :                                 handle(HrtCntNotifyCreate(deviceId)), id(HrtGetCntNotifyId(handle))
      20              : {
      21           64 :     HrtDevResInfo devResInfo;
      22           64 :     devResInfo.dieId    = 0;
      23           64 :     devResInfo.procType = HrtDevResProcType::PROCESS_HCCP;
      24           64 :     devResInfo.resType  = HrtDevResType::RES_TYPE_STARS_CNT_NOTIFY_BIT_WR;
      25           64 :     devResInfo.resId    = id;
      26           64 :     devResInfo.flag     = 0;
      27           64 :     auto resAddrInfo    = HrtGetDevResAddress(devResInfo);
      28           64 :     addr                = resAddrInfo.address;
      29           64 :     size                = DevCapability::GetInstance().GetNotifySize();
      30           64 : }
      31              : 
      32           64 : RtsCntNotify::~RtsCntNotify()
      33              : {
      34           64 :     HrtDevResInfo devResInfo;
      35           64 :     devResInfo.dieId    = 0;
      36           64 :     devResInfo.procType = HrtDevResProcType::PROCESS_HCCP;
      37           64 :     devResInfo.resType  = HrtDevResType::RES_TYPE_STARS_CNT_NOTIFY_BIT_WR;
      38           64 :     devResInfo.resId    = id;
      39           64 :     devResInfo.flag     = 0;
      40           64 :     DECTOR_TRY_CATCH("RtsCntNotify", HrtReleaseDevResAddress(devResInfo));
      41           64 :     DECTOR_TRY_CATCH("RtsCntNotify", HrtCntNotifyDestroy(handle));
      42           64 : }
      43              : 
      44            0 : std::unique_ptr<BaseTask> RtsCntNotify::PostBits(u32 bitValue)
      45              : {
      46            0 :     return std::make_unique<TaskPostBits>(this, bitValue);
      47              : }
      48              : 
      49            0 : std::unique_ptr<BaseTask> RtsCntNotify::WaitValue(u32 value)
      50              : {
      51            0 :     return std::make_unique<TaskWaitValue>(this, value);
      52              : }
      53              : 
      54           12 : void RtsCntNotify::PostBits(u32 bitValue, const Stream &stream) const
      55              : {
      56           12 :     HrtCntNotifyRecord(handle, stream.GetPtr(), HrtCntNotifyRecordMode::WRITE_BIT, bitValue);
      57           12 : }
      58              : 
      59            7 : void RtsCntNotify::WaitValue(u32 value, u32 timeout, const aclrtStream &rtStream) const
      60              : {
      61            7 :     HrtCntNotifyWaitWithTimeOut(handle, rtStream, HrtCntNotifyWaitMode::EQUAL, value, timeout);
      62            7 : }
      63              : 
      64            4 : void RtsCntNotify::WaitValue(u32 value, u32 timeout, const Stream &stream) const
      65              : {
      66            4 :     WaitValue(value, timeout, stream.GetPtr());
      67            4 : }
      68              : 
      69            1 : std::string RtsCntNotify::Describe() const
      70              : {
      71            1 :     return StringFormat("RtsCntNotify[handle=%p, id=%u, addr=0x%llx, size=%u]", handle, id, addr, size);
      72              : }
      73              : 
      74            5 : std::vector<char> RtsCntNotify::GetUniqueId() const
      75              : {
      76            5 :     BinaryStream binaryStream;
      77            5 :     binaryStream << id;
      78            5 :     binaryStream << devPhyId;
      79            5 :     std::vector<char> result;
      80            5 :     binaryStream.Dump(result);
      81            5 :     return result;
      82            5 : }
      83              : 
      84              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1