LCOV - code coverage report
Current view: top level - base_comm/common/debug - aicpu_task_utils.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 83 83
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 7 7

            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              : #include "aicpu_task_utils.h"
      12              : 
      13              : using Hccl::Rt91095StarsMemcpySqe;
      14              : using Hccl::Rt91095StarsNotifySqe;
      15              : using Hccl::Rt91095StarsSqeHeader;
      16              : using Hccl::Rt91095StarsSqeType;
      17              : using Hccl::Rt91095StarsUbdmaDBmodeSqe;
      18              : using Hccl::UdmaSqeCommon;
      19              : using Hccl::UdmaSqeWrite;
      20              : using Hccl::UdmaSqeWriteWithNotify;
      21              : using Hccl::UdmaSqOpcode;
      22              : 
      23              : namespace hcomm {
      24              : 
      25           24 : HcclResult AicpuTaskUtils::DumpSqeContent(const uint8_t* sqePtr)
      26              : {
      27           24 :     if ((UNLIKELY(GetPlfDebugConfigValue() & PLF_TASK)) || UNLIKELY(HcclCheckLogLevel(HCCL_LOG_DEBUG))) {
      28           24 :         CHK_PTR_NULL(sqePtr);
      29           23 :         Rt91095StarsSqeHeader* sqeHeaderPtr = (Rt91095StarsSqeHeader*)sqePtr;
      30           23 :         const Rt91095StarsSqeType sqeType = static_cast<Rt91095StarsSqeType>(sqeHeaderPtr->type);
      31           23 :         switch (sqeType) {
      32            3 :             case Rt91095StarsSqeType::RT_91095_SQE_TYPE_UBDMA:
      33            3 :                 CHK_RET(DumpUbdmaSqe_(sqePtr));
      34            3 :                 break;
      35            8 :             case Rt91095StarsSqeType::RT_91095_SQE_TYPE_NOTIFY_RECORD:
      36              :             case Rt91095StarsSqeType::RT_91095_SQE_TYPE_NOTIFY_WAIT:
      37            8 :                 CHK_RET(DumpNotifySqe_(sqePtr));
      38            8 :                 break;
      39            6 :             case Rt91095StarsSqeType::RT_91095_SQE_TYPE_SDMA:
      40            6 :                 CHK_RET(DumpSdmaSqe_(sqePtr));
      41            6 :                 break;
      42            6 :             default:
      43           12 :                 HCCL_WARNING("[AicpuTaskUtils][DumpSqeContent] sqeType[%u] is unsupported", sqeType);
      44            6 :                 break;
      45              :         }
      46              :     }
      47           23 :     return HCCL_SUCCESS;
      48              : }
      49              : 
      50            3 : inline HcclResult AicpuTaskUtils::DumpUbdmaSqe_(const uint8_t* sqePtr)
      51              : {
      52            3 :     Rt91095StarsUbdmaDBmodeSqe* ubDmaSqe = (Rt91095StarsUbdmaDBmodeSqe*)sqePtr;
      53            3 :     PLF_CONFIG_INFO(
      54              :         PLF_TASK,
      55              :         "[AicpuTaskUtils][DumpSqeContent] type[%u] "
      56              :         "rtStreamId[%u] taskId[%u] mode[%u] doorbellNum[%u] kernelCredit[%u] jettyId1[%u] funcId1[%u] "
      57              :         "piValue1[%u] dieId1[%u]",
      58              :         ubDmaSqe->header.type, ubDmaSqe->header.rtStreamId, ubDmaSqe->header.taskId, ubDmaSqe->mode,
      59              :         ubDmaSqe->doorbellNum, ubDmaSqe->kernelCredit, ubDmaSqe->jettyId1, ubDmaSqe->funcId1, ubDmaSqe->piValue1,
      60              :         ubDmaSqe->dieId1);
      61            3 :     return HCCL_SUCCESS;
      62              : }
      63              : 
      64            8 : inline HcclResult AicpuTaskUtils::DumpNotifySqe_(const uint8_t* sqePtr)
      65              : {
      66            8 :     Rt91095StarsNotifySqe* notifySqe = (Rt91095StarsNotifySqe*)sqePtr;
      67            8 :     PLF_CONFIG_INFO(
      68              :         PLF_TASK,
      69              :         "[AicpuTaskUtils][DumpSqeContent] type[%u] rtStreamId[%u] taskId[%u] wrCqe[%u] "
      70              :         "notifyId[%u] subType[%u] kernelCredit[%u] cntFlag[%u] clrFlag[%u] cntValue[%u] waitModeBit[%u] "
      71              :         "recordModeBit[%u] bitmap[%u] timeout[%u]",
      72              :         notifySqe->header.type, notifySqe->header.rtStreamId, notifySqe->header.taskId, notifySqe->header.wrCqe,
      73              :         notifySqe->notifyId, notifySqe->subType, notifySqe->kernelCredit, notifySqe->cntFlag, notifySqe->clrFlag,
      74              :         notifySqe->cntValue, notifySqe->waitModeBit, notifySqe->recordModeBit, notifySqe->bitmap, notifySqe->timeout);
      75            8 :     return HCCL_SUCCESS;
      76              : }
      77              : 
      78            6 : inline HcclResult AicpuTaskUtils::DumpSdmaSqe_(const uint8_t* sqePtr)
      79              : {
      80            6 :     Rt91095StarsMemcpySqe* sdmaSqe = (Rt91095StarsMemcpySqe*)sqePtr;
      81            6 :     constexpr uint64_t UINT32_BIT_WIDTH = 32;
      82            6 :     const uint64_t srcAddr = (static_cast<uint64_t>(sdmaSqe->u.strideMode0.srcAddrHigh) << UINT32_BIT_WIDTH)
      83            6 :                              | sdmaSqe->u.strideMode0.srcAddrLow;
      84            6 :     const uint64_t dstAddr = (static_cast<uint64_t>(sdmaSqe->u.strideMode0.dstAddrHigh) << UINT32_BIT_WIDTH)
      85            6 :                              | sdmaSqe->u.strideMode0.dstAddrLow;
      86            6 :     PLF_CONFIG_INFO(
      87              :         PLF_TASK,
      88              :         "[AicpuTaskUtils][DumpSqeContent] type[%u] "
      89              :         "rtStreamId[%u] taskId[%u] wrCqe[%u] opcode[%u] kernelCredit[%u] sssv[%u] dssv[%u] sns[%u] dns[%u] "
      90              :         "mapamPartId[%u] length[%u] srcAddr[0x%016llx] dstAddr[0x%016llx]",
      91              :         sdmaSqe->header.type, sdmaSqe->header.rtStreamId, sdmaSqe->header.taskId, sdmaSqe->header.wrCqe,
      92              :         sdmaSqe->opcode, sdmaSqe->kernelCredit, sdmaSqe->sssv, sdmaSqe->dssv, sdmaSqe->sns, sdmaSqe->dns,
      93              :         sdmaSqe->mapamPartId, sdmaSqe->u.strideMode0.lengthMove, static_cast<unsigned long long>(srcAddr),
      94              :         static_cast<unsigned long long>(dstAddr));
      95            6 :     return HCCL_SUCCESS;
      96              : }
      97              : 
      98            8 : HcclResult AicpuTaskUtils::DumpWqeContent(const uint8_t* wqePtr)
      99              : {
     100              :     // 注意: UdmaSqOpcode::UDMA_OPC_READ/UDMA_OPC_WRITE均使用UdmaSqeWrite
     101            8 :     if ((UNLIKELY(GetPlfDebugConfigValue() & PLF_TASK)) || UNLIKELY(HcclCheckLogLevel(HCCL_LOG_DEBUG))) {
     102            8 :         CHK_PTR_NULL(wqePtr);
     103            7 :         UdmaSqeCommon* wqeCommonPtr = (UdmaSqeCommon*)(wqePtr);
     104            7 :         const uint8_t wqeCode = static_cast<uint8_t>(wqeCommonPtr->opcode);
     105            7 :         switch (wqeCode) {
     106            5 :             case UdmaSqOpcode::UDMA_OPC_READ:
     107              :             case UdmaSqOpcode::UDMA_OPC_WRITE:
     108            5 :                 CHK_RET(DumpReadWriteWqe_(wqePtr));
     109            5 :                 break;
     110            1 :             case UdmaSqOpcode::UDMA_OPC_WRITE_WITH_IMM:
     111            1 :                 CHK_RET(DumpWriteWithNotifyWqe_(wqePtr));
     112            1 :                 break;
     113            1 :             default: {
     114            1 :                 HCCL_WARNING("[AicpuTaskUtils][DumpWqeContent] wqeCode[%u] is unsupported", wqeCode);
     115            1 :                 break;
     116              :             }
     117              :         }
     118              :     }
     119              : 
     120            7 :     return HCCL_SUCCESS;
     121              : }
     122              : 
     123            5 : inline HcclResult AicpuTaskUtils::DumpReadWriteWqe_(const uint8_t* wqePtr)
     124              : {
     125            5 :     UdmaSqeCommon* wqeCommonPtr = (UdmaSqeCommon*)wqePtr;
     126            5 :     UdmaSqeWrite* udmaSqeWrite = (UdmaSqeWrite*)wqePtr;
     127            5 :     constexpr uint64_t UINT32_BIT_WIDTH = 32;
     128            5 :     const uint64_t rmtAddr
     129            5 :         = (static_cast<uint64_t>(wqeCommonPtr->rmtAddrHigh) << UINT32_BIT_WIDTH) | wqeCommonPtr->rmtAddrLow;
     130            9 :     const char* wqeType = wqeCommonPtr->inlineEn != 0 ?
     131              :                               "InlineWrite" :
     132            4 :                               ((wqeCommonPtr->opcode == UdmaSqOpcode::UDMA_OPC_READ) ? "Read" : "Write");
     133            5 :     if (wqeCommonPtr->inlineEn != 0) {
     134            1 :         PLF_CONFIG_INFO(
     135              :             PLF_TASK,
     136              :             "[AicpuTaskUtils][DumpWqeContent] type[%s] placeOdr[%u] "
     137              :             "compOrder[%u] fence[%u] cqe[%u] opcode[%u] "
     138              :             "tpn[%u] rmtObjId[%u] rmtEid[%u,%u,%u,%u] rmtTokenValue[%u] rmtAddr[0x%016llx] "
     139              :             "inlineEn[%u] inlineMsgLen[%u]",
     140              :             wqeType, wqeCommonPtr->placeOdr, wqeCommonPtr->compOrder, wqeCommonPtr->fence, wqeCommonPtr->cqe,
     141              :             wqeCommonPtr->opcode, wqeCommonPtr->tpn, wqeCommonPtr->rmtObjId, wqeCommonPtr->rmtEid[0],
     142              :             wqeCommonPtr->rmtEid[1], wqeCommonPtr->rmtEid[2], wqeCommonPtr->rmtEid[3], wqeCommonPtr->rmtTokenValue,
     143              :             static_cast<unsigned long long>(rmtAddr), wqeCommonPtr->inlineEn, wqeCommonPtr->inlineMsgLen);
     144              :     } else {
     145            4 :         const uint64_t locAddr = (static_cast<uint64_t>(udmaSqeWrite->u.sge.dataAddrHigh) << UINT32_BIT_WIDTH)
     146            4 :                                  | udmaSqeWrite->u.sge.dataAddrLow;
     147            4 :         PLF_CONFIG_INFO(
     148              :             PLF_TASK,
     149              :             "[AicpuTaskUtils][DumpWqeContent] type[%s] placeOdr[%u] "
     150              :             "compOrder[%u] fence[%u] cqe[%u] opcode[%u] tpn[%u] rmtObjId[%u] rmtEid[%u,%u,%u,%u] "
     151              :             "rmtTokenValue[%u] rmtAddr[0x%016llx] length[%u] locTokenId[%u] locAddr[0x%016llx] "
     152              :             "udfFlag[%u] udfType[%u] reduceType[%u] reduceOp[%u]",
     153              :             wqeType, wqeCommonPtr->placeOdr, wqeCommonPtr->compOrder, wqeCommonPtr->fence, wqeCommonPtr->cqe,
     154              :             wqeCommonPtr->opcode, wqeCommonPtr->tpn, wqeCommonPtr->rmtObjId, wqeCommonPtr->rmtEid[0],
     155              :             wqeCommonPtr->rmtEid[1], wqeCommonPtr->rmtEid[2], wqeCommonPtr->rmtEid[3], wqeCommonPtr->rmtTokenValue,
     156              :             static_cast<unsigned long long>(rmtAddr), udmaSqeWrite->u.sge.length, udmaSqeWrite->u.sge.tokenId,
     157              :             static_cast<unsigned long long>(locAddr), wqeCommonPtr->udfFlag, wqeCommonPtr->inlinedata.udfData.udfType,
     158              :             wqeCommonPtr->inlinedata.udfData.reduceType, wqeCommonPtr->inlinedata.udfData.reduceOp);
     159              :     }
     160            5 :     return HCCL_SUCCESS;
     161              : }
     162              : 
     163            1 : inline HcclResult AicpuTaskUtils::DumpWriteWithNotifyWqe_(const uint8_t* wqePtr)
     164              : {
     165            1 :     UdmaSqeCommon* wqeCommonPtr = (UdmaSqeCommon*)wqePtr;
     166            1 :     UdmaSqeWriteWithNotify* udmaSqeWriteWithNotify = (UdmaSqeWriteWithNotify*)wqePtr;
     167            1 :     constexpr uint64_t UINT32_BIT_WIDTH = 32;
     168            1 :     const uint64_t rmtAddr
     169            1 :         = (static_cast<uint64_t>(wqeCommonPtr->rmtAddrHigh) << UINT32_BIT_WIDTH) | wqeCommonPtr->rmtAddrLow;
     170            1 :     const uint64_t locAddr
     171            1 :         = (static_cast<uint64_t>(udmaSqeWriteWithNotify->localU.sge.dataAddrHigh) << UINT32_BIT_WIDTH)
     172            1 :           | udmaSqeWriteWithNotify->localU.sge.dataAddrLow;
     173            1 :     const uint64_t notifyAddr
     174            1 :         = (static_cast<uint64_t>(udmaSqeWriteWithNotify->notify.notifyAddrHigh) << UINT32_BIT_WIDTH)
     175            1 :           | udmaSqeWriteWithNotify->notify.notifyAddrLow;
     176            1 :     const uint64_t notifyData
     177            1 :         = (static_cast<uint64_t>(udmaSqeWriteWithNotify->notify.notifyDataHigh) << UINT32_BIT_WIDTH)
     178            1 :           | udmaSqeWriteWithNotify->notify.notifyDataLow;
     179            1 :     PLF_CONFIG_INFO(
     180              :         PLF_TASK,
     181              :         "[AicpuTaskUtils][DumpWqeContent] type[WriteWithNotify] placeOdr[%u] "
     182              :         "compOrder[%u] fence[%u] cqe[%u] opcode[%u] tpn[%u] rmtObjId[%u] rmtEid[%u,%u,%u,%u] "
     183              :         "rmtTokenValue[%u] rmtAddr[0x%016llx] length[%u] locTokenId[%u] locAddr[0x%016llx] "
     184              :         "notifyTokenId[%u] notifyTokenValue[%u] notifyAddr[0x%016llx] notifyData[0x%016llx] "
     185              :         "udfFlag[%u] udfType[%u] reduceType[%u] reduceOp[%u]",
     186              :         wqeCommonPtr->placeOdr, wqeCommonPtr->compOrder, wqeCommonPtr->fence, wqeCommonPtr->cqe, wqeCommonPtr->opcode,
     187              :         wqeCommonPtr->tpn, wqeCommonPtr->rmtObjId, wqeCommonPtr->rmtEid[0], wqeCommonPtr->rmtEid[1],
     188              :         wqeCommonPtr->rmtEid[2], wqeCommonPtr->rmtEid[3], wqeCommonPtr->rmtTokenValue,
     189              :         static_cast<unsigned long long>(rmtAddr), udmaSqeWriteWithNotify->localU.sge.length,
     190              :         udmaSqeWriteWithNotify->localU.sge.tokenId, static_cast<unsigned long long>(locAddr),
     191              :         udmaSqeWriteWithNotify->notify.notifyTokenId, udmaSqeWriteWithNotify->notify.notifyTokenValue,
     192              :         static_cast<unsigned long long>(notifyAddr), static_cast<unsigned long long>(notifyData), wqeCommonPtr->udfFlag,
     193              :         wqeCommonPtr->inlinedata.udfData.udfType, wqeCommonPtr->inlinedata.udfData.reduceType,
     194              :         wqeCommonPtr->inlinedata.udfData.reduceOp);
     195            1 :     return HCCL_SUCCESS;
     196              : }
     197              : 
     198              : } // namespace hcomm
        

Generated by: LCOV version 2.0-1