LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/resource/stream/aicpu - rtsq_a5.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 94.1 % 17 16
Test Date: 2026-08-17 10:19:35 Functions: 83.3 % 6 5

            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              : #ifndef HCCLV2_RTSQ_A5_H
      11              : #define HCCLV2_RTSQ_A5_H
      12              : #include "rtsq_base.h"
      13              : #include "sqe_v82.h"
      14              : #include "log.h"
      15              : #include <chrono>
      16              : 
      17              : namespace hccl {
      18              : class AicpuTsThread;
      19              : }
      20              : 
      21              : namespace Hccl {
      22              : 
      23              : class RtsqA5 : public RtsqBase {
      24              : public:
      25              :     RtsqA5(u32 devPhyId, u32 streamId, u32 sqId);
      26              : 
      27              :     RtsqA5(u32 devPhyId, u32 streamId, u32 sqId, bool launchFlag);
      28              : 
      29              :     void Reset() override;
      30              : 
      31              :     void LaunchTask() override;
      32              : 
      33              :     void TryLaunchTask() override;
      34              : 
      35              :     void NotifyWait(u32 notifyId) override;
      36              : 
      37              :     void NotifyWait(u32 notifyId, u32 timeout);
      38              : 
      39              :     void NotifyRecordLoc(u32 notifyId) override;
      40              : 
      41              :     void Cnt1toNNotifyWait(u32 notifyId, u32 value) override;
      42              : 
      43              :     void Cnt1toNNotifyRecord(u32 notifyId, u32 value) override;
      44              : 
      45              :     void CntNto1NotifyWait(u32 notifyId, u32 value) override;
      46              : 
      47              :     void CntNto1NotifyRecord(u32 notifyId, u32 value) override;
      48              : 
      49              :     void SdmaCopy(u64 srcAddr, u64 dstAddr, u32 size, u32 partId) override;
      50              : 
      51              :     void SdmaReduce(u64 srcAddr, u64 dstAddr, u32 size, u32 partId, const ReduceIn& reduceIn) override;
      52              : 
      53              :     void P2PWriteValue(u64 remoteAddr, u32 writeValue) override;
      54              : 
      55              :     void UbDbSend(const UbJettyLiteId& jettyLiteId, u16 piValue) override;
      56              : 
      57              :     void RdmaDbSend(const uint64_t& dbAddr, const uint64_t& dbValue) override;
      58              : 
      59            1 :     void UbDirectSend(const UbJettyLiteId& jettyLiteId, u32 dwqeSize, const u8* wqe) override
      60              :     {
      61              :         // 构造UBDMA的command,这个里面,SQE可能占用 128Byte 或者 192Byte
      62              :         (void)jettyLiteId;
      63              :         (void)dwqeSize;
      64              :         (void)wqe;
      65            1 :     }
      66              : 
      67            1 :     void UbWriteValue(u64 dbAddr, u32 piValue) override
      68              :     {
      69              :         (void)dbAddr;
      70              :         (void)piValue;
      71            1 :     }
      72              : 
      73              :     bool IsRtsqQueueSpaceSufficient() override;
      74              : 
      75              :     void CCoreNotifyWait(u64 waitAddr, u64 curTurnCntAddr, bool last) override;
      76              : 
      77              :     void CCoreNotifyRecord(u64 recordAddr, u64 curTurnCntAddr) override;
      78              : 
      79              :     HcclResult SetPreStreamSyncReady() override;
      80              : 
      81              :     HcclResult SetPreStreamSyncFin() override;
      82              : 
      83              :     bool GetPreStreamSyncStatus() override;
      84              : 
      85              :     // 用于aicpu task cache
      86            0 :     uint32_t GetPendingSqeCnt() const override { return pendingSqeCnt; }
      87              : 
      88            1 :     inline HcclResult SetAicpuTsThreadPtr(hccl::AicpuTsThread* threadPtr)
      89              :     {
      90            1 :         CHK_PTR_NULL(threadPtr);
      91            1 :         aicpuTsThreadPtr_ = threadPtr;
      92            1 :         return HCCL_SUCCESS;
      93              :     }
      94              : 
      95            1 :     inline HcclResult SetNeedCacheTaskCallback(std::function<bool()> callback)
      96              :     {
      97            1 :         CHK_PTR_NULL(callback);
      98            1 :         needCacheTaskCallback_ = callback;
      99            1 :         return HCCL_SUCCESS;
     100              :     }
     101              : 
     102            1 :     inline HcclResult SetAddSqeArrayCallback(
     103              :         std::function<HcclResult(Hccl::RtsqA5*, hccl::AicpuTsThread*, uint64_t, const uint8_t*, const uint32_t)>
     104              :             callback)
     105              :     {
     106            1 :         CHK_PTR_NULL(callback);
     107            1 :         addSqeArrayCallback_ = callback;
     108            1 :         return HCCL_SUCCESS;
     109              :     }
     110              : 
     111              :     void RefreshSqeHeaderTaskField(Rt91095StarsSqeHeader* sqeHeaderPtr);
     112              : 
     113              :     void LaunchNewTask(uint8_t* sqeArray, uint32_t sqeCount);
     114              :     u64 GetSqeAddr() const override;
     115              : 
     116              : private:
     117              :     u32 pendingSqeCnt{0};
     118              : 
     119              :     u32 sqFullTimeout_ = RTSQ_FULL_TIMEOUT_DEFAULT;
     120              : 
     121              :     bool isPreStreamSync = false;
     122              : 
     123              :     bool launchFlag_ = false;
     124              : 
     125              :     u64 lastSqeAddr_{0};
     126              : 
     127              :     u8 locBuf[RTSQ_SQE_SIZE * PER_LAUNCH_SQE_CNT]{0};
     128              : 
     129              :     std::function<bool()> needCacheTaskCallback_{nullptr};
     130              :     std::function<HcclResult(Hccl::RtsqA5*, hccl::AicpuTsThread*, uint64_t, const uint8_t*, const uint32_t)>
     131              :         addSqeArrayCallback_{nullptr};
     132              :     hccl::AicpuTsThread* aicpuTsThreadPtr_{nullptr};
     133              : 
     134              :     u8* GetCurrSqeBuffer();
     135              : 
     136              :     void RefreshInfo();
     137              : 
     138              :     void CopySqeBufToSq(u8* sqeBuf);
     139              : 
     140              :     void MakeSureAvailableSpace();
     141              : 
     142              :     u32 GetTailToHeadDist() const;
     143              : 
     144              :     void CheckLaunchTaskStatus(
     145              :         const std::chrono::steady_clock::time_point& startTime, const std::chrono::steady_clock::time_point& curTime);
     146              : 
     147              :     void PreLaunchSqeForCache(bool& needCacheTask);
     148              : 
     149              :     void PostLaunchSqeForCache();
     150              : };
     151              : 
     152              : } // namespace Hccl
     153              : 
     154              : #endif
        

Generated by: LCOV version 2.0-1