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 <chrono>
14 : namespace Hccl {
15 :
16 : class RtsqA5 : public RtsqBase {
17 : public:
18 : RtsqA5(u32 devPhyId, u32 streamId, u32 sqId);
19 :
20 : RtsqA5(u32 devPhyId, u32 streamId, u32 sqId, bool launchFlag);
21 :
22 : void Reset() override;
23 :
24 : void LaunchTask() override;
25 :
26 : void TryLaunchTask() override;
27 :
28 : void NotifyWait(u32 notifyId) override;
29 :
30 : void NotifyWait(u32 notifyId, u32 timeout);
31 :
32 : void NotifyRecordLoc(u32 notifyId) override;
33 :
34 : void Cnt1toNNotifyWait(u32 notifyId, u32 value) override;
35 :
36 : void Cnt1toNNotifyRecord(u32 notifyId, u32 value) override;
37 :
38 : void CntNto1NotifyWait(u32 notifyId, u32 value) override;
39 :
40 : void CntNto1NotifyRecord(u32 notifyId, u32 value) override;
41 :
42 : void SdmaCopy(u64 srcAddr, u64 dstAddr, u32 size, u32 partId) override;
43 :
44 : void SdmaReduce(u64 srcAddr, u64 dstAddr, u32 size, u32 partId, const ReduceIn &reduceIn) override;
45 :
46 : void P2PWriteValue(u64 remoteAddr, u32 writeValue) override;
47 :
48 : void UbDbSend(const UbJettyLiteId &jettyLiteId, u16 piValue) override;
49 :
50 : void RdmaDbSend(const uint64_t &dbAddr, const uint64_t &dbValue) override;
51 :
52 1 : void UbDirectSend(const UbJettyLiteId &jettyLiteId, u32 dwqeSize, const u8 *wqe) override
53 : {
54 : // 构造UBDMA的command,这个里面,SQE可能占用 128Byte 或者 192Byte
55 : (void)jettyLiteId;
56 : (void)dwqeSize;
57 : (void)wqe;
58 1 : }
59 :
60 1 : void UbWriteValue(u64 dbAddr, u32 piValue) override
61 : {
62 : (void)dbAddr;
63 : (void)piValue;
64 1 : }
65 :
66 : bool IsRtsqQueueSpaceSufficient() override;
67 :
68 : void CCoreNotifyWait(u64 waitAddr, u64 curTurnCntAddr, bool last) override;
69 :
70 : void CCoreNotifyRecord(u64 recordAddr, u64 curTurnCntAddr) override;
71 :
72 : HcclResult SetPreStreamSyncReady() override;
73 :
74 : HcclResult SetPreStreamSyncFin() override;
75 :
76 : bool GetPreStreamSyncStatus() override;
77 :
78 : private:
79 : u32 pendingSqeCnt{0};
80 :
81 : u32 sqFullTimeout_ = RTSQ_FULL_TIMEOUT_DEFAULT;
82 :
83 : bool isPreStreamSync = false;
84 :
85 : bool launchFlag_ = false;
86 :
87 : u8 locBuf[RTSQ_SQE_SIZE * PER_LAUNCH_SQE_CNT]{0};
88 :
89 : u8 *GetCurrSqeBuffer();
90 :
91 : void RefreshInfo();
92 :
93 : void CopyLocBufToSq();
94 :
95 : void MakeSureAvailableSpace();
96 :
97 : u32 GetTailToHeadDist() const;
98 :
99 : void CheckLaunchTaskStatus(const std::chrono::steady_clock::time_point &startTime,
100 : const std::chrono::steady_clock::time_point &curTime);
101 : };
102 :
103 : } // namespace Hccl
104 :
105 : #endif
|