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

Generated by: LCOV version 2.0-1