LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/resource/connection/aicpu - udma_data_struct.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 42.9 % 7 3
Test Date: 2026-08-17 10:19:35 Functions: 75.0 % 8 6

            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_AICPU_WQEMGR_WQE_H
      11              : #define HCCLV2_AICPU_WQEMGR_WQE_H
      12              : 
      13              : #include <string>
      14              : #include "string_util.h"
      15              : #include "hccl/base.h"
      16              : #include "enum_factory_legacy.h"
      17              : #include "task_param.h"
      18              : #include "ip_address.h"
      19              : 
      20              : namespace Hccl {
      21              : 
      22              : #define UDMA_SQE_RMT_EID_SIZE 4
      23              : 
      24          312 : MAKE_ENUM(
      25              :     UdmaSqOpcode, UDMA_OPC_SEND, UDMA_OPC_SEND_WITH_IMM, UDMA_OPC_SEND_WITH_INVALID, UDMA_OPC_WRITE,
      26              :     UDMA_OPC_WRITE_WITH_IMM, UDMA_OPC_READ = 0x6, UDMA_OPC_CAS, UDMA_OPC_FAA = 0xb, UDMA_OPC_NOP = 0x11,
      27              :     UDMA_OPC_INVALID = 0x12)
      28              : 
      29              : MAKE_ENUM(
      30              :     UdmaDataOp, REDUCE_OP_MAX = 0x8, REDUCE_OP_MIN = 0x9, REDUCE_OP_ADD = 0xA, REDUCE_OP_EQUAL = 0xB,
      31              :     REDUCE_OP_RESEVERD = 0xC)
      32              : 
      33              : MAKE_ENUM(
      34              :     UdmaDataType, REDUCE_TYPE_INT8 = 0x0, REDUCE_TYPE_INT16 = 0X1, REDUCE_TYPE_INT32 = 0x2, REDUCE_TYPE_UINT32 = 0X5,
      35              :     REDUCE_TYPE_FP16_NORMAL = 0X6, REDUCE_TYPE_FP32 = 0X7, REDUCE_TYPE_FP16 = 0X8, REDUCE_TYPE_FP16_SAT = 0X9,
      36              :     REDUCE_TYPE_RESEVERD = 0XA)
      37              : 
      38              : struct UdmaNormalSge {
      39              :     uint32_t length;
      40              :     uint32_t tokenId;
      41              :     uint32_t dataAddrLow;
      42              :     uint32_t dataAddrHigh;
      43              : 
      44              :     std::string Desc() const
      45              :     {
      46              :         constexpr uint64_t UINT32_BIT_WIDTH = 32;
      47              :         const uint64_t dataAddr
      48              :             = (static_cast<uint64_t>(dataAddrHigh) << UINT32_BIT_WIDTH) | static_cast<uint64_t>(dataAddrLow);
      49              :         return StringFormat(
      50              :             "length = %u dataAddrLow = %u dataAddrHigh = %u dataAddr = 0x%016llx", length, dataAddrLow, dataAddrHigh,
      51              :             static_cast<unsigned long long>(dataAddr));
      52              :     }
      53              : };
      54              : 
      55              : struct UdmaInlineData {
      56              :     u8 data[16];
      57              : };
      58              : 
      59              : struct UdfExtDate { // UDF扩展数据
      60              :     uint32_t udfType : 8;
      61              :     uint32_t reduceType : 4;
      62              :     uint32_t reduceOp : 4;
      63              :     uint32_t rsv : 16;
      64              : };
      65              : 
      66              : struct UdmaSqe {
      67              :     uint32_t sqeBbIdx : 16;
      68              :     uint32_t placeOdr : 2;
      69              :     uint32_t compOrder : 1;
      70              :     uint32_t fence : 1;
      71              :     uint32_t se : 1;
      72              :     uint32_t cqe : 1;
      73              :     uint32_t inlineEn : 1;
      74              :     uint32_t rsv : 5;
      75              :     uint32_t tokenEn : 1;
      76              :     uint32_t rmtJettyType : 2;
      77              :     uint32_t owner : 1;
      78              :     uint32_t targetHint : 8;
      79              :     uint32_t opcode : 8;
      80              :     uint32_t rsv1 : 6;
      81              :     uint32_t inlineMsgLen : 10;
      82              :     uint32_t tpn : 24;
      83              :     uint32_t sgeNum : 8;
      84              :     uint32_t rmtObjId : 20;
      85              :     uint32_t rsv2 : 12;
      86              :     uint32_t rmtEid[UDMA_SQE_RMT_EID_SIZE];
      87              :     uint32_t rmtTokenValue;
      88              :     union {
      89              :         uint32_t rsv3;
      90              :         UdfExtDate udfData;
      91              :     } inlinedata;
      92              : 
      93              :     uint32_t rmtAddrLow;
      94              :     uint32_t rmtAddrHigh;
      95              :     union {
      96              :         UdmaNormalSge sge;
      97              :         UdmaInlineData inlineData;
      98              :     } u;
      99              : };
     100              : 
     101              : union LocalValueU {
     102              :     UdmaNormalSge sge;
     103              :     UdmaInlineData inlineData;
     104              : };
     105              : 
     106              : struct UdmaSqeNotify {
     107              :     uint32_t notifyTokenId : 20;
     108              :     uint32_t rsv : 12;
     109              :     uint32_t notifyTokenValue;
     110              :     uint32_t notifyAddrLow;
     111              :     uint32_t notifyAddrHigh;
     112              :     uint32_t notifyDataLow;
     113              :     uint32_t notifyDataHigh;
     114              :     std::string Desc() const
     115              :     {
     116              :         return StringFormat(
     117              :             "notifyAddrLow = %u notifyAddrHigh %u notifyDataLow = %u "
     118              :             "notifyDataHigh %u",
     119              :             notifyAddrLow, notifyAddrHigh, notifyDataLow, notifyDataHigh);
     120              :     }
     121              : };
     122              : 
     123              : struct UdmaSqeCommon {
     124              :     uint32_t sqeBbIdx : 16;
     125              :     uint32_t placeOdr : 2;
     126              :     uint32_t compOrder : 1;
     127              :     uint32_t fence : 1;
     128              :     uint32_t se : 1;
     129              :     uint32_t cqe : 1;
     130              :     uint32_t inlineEn : 1;
     131              :     uint32_t udfFlag : 1;
     132              :     uint32_t rsv : 4;
     133              :     uint32_t tokenEn : 1;
     134              :     uint32_t rmtJettyType : 2;
     135              :     uint32_t owner : 1;
     136              :     uint32_t targetHint : 8;
     137              :     uint32_t opcode : 8;
     138              :     uint32_t rsv1 : 6;
     139              :     uint32_t inlineMsgLen : 10;
     140              :     uint32_t tpn : 24;
     141              :     uint32_t sgeNum : 8;
     142              :     uint32_t rmtObjId : 20;
     143              :     uint32_t rsv2 : 12;
     144              :     uint32_t rmtEid[UDMA_SQE_RMT_EID_SIZE];
     145              :     uint32_t rmtTokenValue;
     146              :     union {
     147              :         uint32_t rsv3;
     148              :         UdfExtDate udfData;
     149              :     } inlinedata;
     150              : 
     151              :     uint32_t rmtAddrLow;
     152              :     uint32_t rmtAddrHigh;
     153              : };
     154              : 
     155              : struct UdmaSqeWriteWithNotify {
     156              :     struct UdmaSqeCommon comm;
     157              :     struct UdmaSqeNotify notify;
     158              :     uint32_t rsv1;
     159              :     uint32_t rsv2;
     160              :     union LocalValueU localU;
     161              : };
     162              : 
     163              : struct UdmaSqeWrite {
     164              :     struct UdmaSqeCommon comm;
     165              :     union LocalValueU u;
     166              : };
     167              : 
     168              : struct UdmaSqeRead {
     169              :     struct UdmaSqeCommon comm;
     170              :     union LocalValueU u;
     171              : };
     172              : 
     173              : // 定义WqeTask用于aicpu task cache
     174              : // 注意: 不需要额外维护wqeType指定struct, 因为所有struct开头都是UdmaSqeCommon, 可以利用opCode判断wqe类型
     175              : union WqeTask {
     176              :     struct UdmaSqeRead wqeRead;                       // 64B (48 + 16); ub_conn_lite.cc中暂不使用UdmaSqeRead
     177              :     struct UdmaSqeWrite wqeWrite;                     // 64B (48 + 16)
     178              :     struct UdmaSqeWriteWithNotify wqeWriteWithNotify; // 96B (48 + 32 + 16)
     179              : 
     180           18 :     WqeTask() {}
     181           48 :     ~WqeTask() {}
     182              : 
     183              :     explicit WqeTask(const struct UdmaSqeRead& tmpWqeRead) : wqeRead(tmpWqeRead) {}
     184            0 :     explicit WqeTask(const struct UdmaSqeWrite& tmpWqeWrite) : wqeWrite(tmpWqeWrite) {}
     185            0 :     explicit WqeTask(const struct UdmaSqeWriteWithNotify& tmpWqeWriteWithNotify)
     186            0 :         : wqeWriteWithNotify(tmpWqeWriteWithNotify)
     187            0 :     {}
     188              : };
     189              : 
     190              : // 记录DbSqe TaskParam中, 与WQE相关的profiling信息, 用于aicpu task cache适配profiling
     191              : struct DbSqeProfInfo {
     192              :     bool isValid = false;
     193              :     TaskParamType taskParamType;
     194              :     uint64_t srcAddr;        // TASK_UB, TASK_UB_REDUCE_INLINE, TASK_WRITE_WITH_NOTIFY, TASK_WRITE_REDUCE_WITH_NOTIFY
     195              :     uint64_t dstAddr;        // TASK_UB_INLINE_WRITE, TASK_UB, TASK_UB_REDUCE_INLINE, TASK_WRITE_WITH_NOTIFY,
     196              :                              // TASK_WRITE_REDUCE_WITH_NOTIFY
     197              :     uint64_t size;           // TASK_UB_INLINE_WRITE, TASK_UB, TASK_UB_REDUCE_INLINE, TASK_WRITE_WITH_NOTIFY,
     198              :                              // TASK_WRITE_REDUCE_WITH_NOTIFY
     199              :     Eid locEid;              // TASK_UB_INLINE_WRITE, TASK_UB, TASK_UB_REDUCE_INLINE, TASK_WRITE_WITH_NOTIFY,
     200              :                              // TASK_WRITE_REDUCE_WITH_NOTIFY
     201              :     Eid rmtEid;              // TASK_UB_INLINE_WRITE, TASK_UB, TASK_UB_REDUCE_INLINE, TASK_WRITE_WITH_NOTIFY,
     202              :                              // TASK_WRITE_REDUCE_WITH_NOTIFY
     203              :     DmaOp dmaOp;             // TASK_UB
     204              :     HcclReduceOp reduceOp;   // TASK_UB_REDUCE_INLINE, TASK_WRITE_REDUCE_WITH_NOTIFY
     205              :     HcclDataType dataType;   // TASK_UB_REDUCE_INLINE, TASK_WRITE_REDUCE_WITH_NOTIFY
     206              :     u64 notifyId;            // TASK_UB_INLINE_WRITE, TASK_WRITE_WITH_NOTIFY, TASK_WRITE_REDUCE_WITH_NOTIFY
     207              :     uint64_t jettyHandle{0}; // TASK_UB_INLINE_WRITE
     208              :     uint32_t jettyId{0};     // TASK_UB_INLINE_WRITE, TASK_UB, TASK_UB_REDUCE_INLINE, TASK_WRITE_WITH_NOTIFY,
     209              :                              // TASK_WRITE_REDUCE_WITH_NOTIFY
     210              : };
     211              : 
     212              : } // namespace Hccl
     213              : #endif // HCCL_AICPU_RESOURCE_AI_CPU_RESOUCES_H_
        

Generated by: LCOV version 2.0-1