LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/resource/connection/aicpu - ub_conn_lite.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-08-04 10:52:23 Functions: - 0 0

            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_UB_CONN_LITE_H_
      12              : #define HCCLV2_UB_CONN_LITE_H_
      13              : 
      14              : #include <queue>
      15              : #include "data_type.h"
      16              : #include "reduce_op.h"
      17              : #include "rma_buf_slice_lite.h"
      18              : #include "rmt_rma_buf_slice_lite.h"
      19              : #include "rma_conn_lite.h"
      20              : #include "udma_data_struct.h"
      21              : #include "kernel_param_lite.h"
      22              : #include "stream_lite.h"
      23              : 
      24              : namespace Hccl {
      25              : 
      26              : enum class SlicePosition { ONLY = 0, FIRST = 1, MIDDLE = 2, LAST = 3 };
      27              : struct UbConnLiteParam {
      28              :     u32 dieId;
      29              :     u32 funcId;
      30              :     u32 jettyId;
      31              : 
      32              :     u64  dbAddr;
      33              :     u64  sqVa;
      34              :     u32  sqDepth;
      35              :     u32  tpn;
      36              :     bool dwqeCacheLocked;
      37              :     u32  jfcPollMode; // 0代表STARS POLL, 1代表软件Poll
      38              :     u64  sqCiAddr;    // 预留给 软件poll CQ 的Jetty使用
      39              : 
      40              :     Eid rmtEid;
      41              :     Eid locEid;
      42              :     uint64_t jettyHandle{0};
      43              : 
      44              :     u32 maxReadSize;
      45              :     u32 maxWriteSize;
      46              : 
      47              :     UbConnLiteParam(std::vector<char> &uniqueId);
      48              : 
      49              :     std::string Describe() const;
      50              : };
      51              : 
      52              : class UbConnLite : public RmaConnLite {
      53              : public:
      54              :     UbConnLite(const UbJettyLiteId &id, const UbJettyLiteAttr &attr, const Eid &rmtInfo);
      55              : 
      56              :     explicit UbConnLite(const UbConnLiteParam &liteParam);
      57              : 
      58              :     std::string Describe() final;
      59              : 
      60              :     void FillCommSqe(UdmaSqeCommon *sqe, const RmtRmaBufSliceLite &rmt, const SqeConfigLite &cfg, u32 opCode,
      61              :                      SlicePosition slicePos = SlicePosition::ONLY);
      62              : 
      63              :     void Read(const RmaBufSliceLite &loc, const RmtRmaBufSliceLite &rmt, const SqeConfigLite &cfg,
      64              :               const StreamLite &stream, ConnLiteOperationOut &out) override;
      65              : 
      66              :     void ReadReduce(ReduceIn reduceIn, const RmaBufSliceLite &loc, const RmtRmaBufSliceLite &rmt,
      67              :                     const StreamLite &stream, const SqeConfigLite &cfg, ConnLiteOperationOut &out) override;
      68              : 
      69              :     void Write(const RmaBufSliceLite &loc, const RmtRmaBufSliceLite &rmt, const SqeConfigLite &cfg,
      70              :                const StreamLite &stream, ConnLiteOperationOut &out) override;
      71              : 
      72              :     void InlineWrite(const u8 *data, u16 size, const RmtRmaBufSliceLite &rmt, const SqeConfigLite &cfg,
      73              :                      const StreamLite &stream, ConnLiteOperationOut &out) override;
      74              : 
      75              :     void WriteReduce(DataType dataType, ReduceOp reduceOp, const RmaBufSliceLite &loc, const StreamLite &stream,
      76              :                      const RmtRmaBufSliceLite &rmt, const SqeConfigLite &cfg, ConnLiteOperationOut &out) override;
      77              : 
      78              :     void FillNotifySqe(struct UdmaSqeNotify *sqe, const RmtRmaBufSliceLite &notify, u64 notifyData) const;
      79              :     void FillLocalSgeSqe(UdmaNormalSge *sqe, const RmaBufSliceLite &loc) const;
      80              : 
      81              :     void WriteWithNotify(const RmaBufSliceLite &loc, const RmtRmaBufSliceLite &rmt, const SqeConfigLite &cfg,
      82              :                          ConnLiteOperationOut &out, const RmtRmaBufSliceLite &notify, const StreamLite &stream,
      83              :                          u64 notifyData) override;
      84              : 
      85              :     void WriteReduceWithNotify(DataType dataType, ReduceOp reduceOp, const RmaBufSliceLite &loc,
      86              :                                const RmtRmaBufSliceLite &rmt, const SqeConfigLite &cfg, const StreamLite &stream,
      87              :                                ConnLiteOperationOut &out, const RmtRmaBufSliceLite &notify, u64 notifyData) override;
      88              : 
      89              :     void CustomizeSqeByOneSidedComm(UdmaSqeCommon *sqe, bool isLastWqe) const;
      90              : 
      91              :     void FillBatchOneWqe(const RmaBufSliceLite &loc, const RmtRmaBufSliceLite &rmt, const SqeConfigLite &cfg,
      92              :                          bool isLastWqe, u32 opCode, const StreamLite &stream);
      93              : 
      94              :     void BatchProcessOneSlice(const RmaBufSliceLite &loc, const RmtRmaBufSliceLite &rmt, const SqeConfigLite &cfg,
      95              :                               u32 maxSliceSize, bool isLastSlice, u32 opCode, const StreamLite &stream);
      96              : 
      97              :     void BatchCommDataProcess(const vector<RmaBufSliceLite> &loc, const vector<RmtRmaBufSliceLite> &rmt,
      98              :                               const SqeConfigLite &cfg, u32 maxSliceSize, u32 opCode, const StreamLite &stream);
      99              : 
     100              :     void BatchOneSidedRead(const vector<RmaBufSliceLite> &loc, const vector<RmtRmaBufSliceLite> &rmt,
     101              :                            const SqeConfigLite &cfg, const StreamLite &stream, ConnLiteOperationOut &out) override;
     102              :     void BatchOneSidedWrite(const vector<RmaBufSliceLite> &loc, const vector<RmtRmaBufSliceLite> &rmt,
     103              :                             const SqeConfigLite &cfg, const StreamLite &stream, ConnLiteOperationOut &out) override;
     104              : private:
     105              :     u16  pi{0};
     106              :     u16  ci{0};
     107              :     u32  piDetourCount{0};
     108              :     u32  ciDetourCount{0};
     109              :     u32  maxReadSize{0};
     110              :     u32  maxWriteSize{0};
     111              :     void ProcessSlices(const RmaBufSliceLite &loc, const RmtRmaBufSliceLite &rmt, u32 maxSliceSize,
     112              :         std::function<void(const RmaBufSliceLite &, const RmtRmaBufSliceLite &, SlicePosition)> processOneSlice,
     113            6 :         DataType dataType = DataType::INVALID) const;
     114              :     void ProcessSlicesWithNotify(
     115              :         const RmaBufSliceLite &loc, const RmtRmaBufSliceLite &rmt, u32 maxSliceSize,
     116              :         std::function<void(const RmaBufSliceLite &, const RmtRmaBufSliceLite &, SlicePosition)> processOneSlice,
     117              :         std::function<void(const RmaBufSliceLite &, const RmtRmaBufSliceLite &, SlicePosition)> processOneSliceWithNotify,
     118            6 :         DataType                                                                 dataType = DataType::INVALID) const;
     119              :     void ProcessOneWqe(UdmaSqeWrite *sqe, UdmaSqOpcode opCode, const StreamLite &stream);
     120              :     void ProcessOneWqeWithNotify(const RmaBufSliceLite &loc, const RmtRmaBufSliceLite &rmt, const SqeConfigLite &cfg,
     121              :                                  UdmaSqeWriteWithNotify *sqe, const RmtRmaBufSliceLite &notify, u64 notifyData,
     122              :                                  u32 opCode, SlicePosition slicePos, const StreamLite &stream);
     123              :     void FillCommSqeReduceInfo(UdmaSqeCommon &sqeComm, ReduceOp reduceOp, DataType dataType, u32 udfType = 0) const;
     124              :     void FillOneSqeWrite(const RmaBufSliceLite &loc, const RmtRmaBufSliceLite &rmt, const SqeConfigLite &cfg,
     125              :                          UdmaSqeWrite *sqe, UdmaSqOpcode opCode, SlicePosition slicePos);
     126              :     void MemorySetAndCopy(u8 *va, u32 sqeSize, void *sqe);
     127              : };
     128              : } // namespace Hccl
     129              : 
     130              : #endif // HCCLV2_UB_CONN_LITE_H_
        

Generated by: LCOV version 2.0-1