LCOV - code coverage report
Current view: top level - legacy/ascend910/platform/typical - typical_param_check.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 33.3 % 54 18
Test Date: 2026-08-04 10:52:23 Functions: 33.3 % 6 2

            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 TYPICAL_PARAM_CHECK_H
      11              : #define TYPICAL_PARAM_CHECK_H
      12              : #include "interface_hccl.h"
      13              : namespace hccl {
      14              : 
      15            0 : inline HcclResult CheckDataType(const HcclDataType dataType)
      16              : {
      17            0 :     if ((dataType >= HCCL_DATA_TYPE_RESERVED) || (dataType < HCCL_DATA_TYPE_INT8)) {
      18            0 :         HCCL_ERROR("[Check][DataType]errNo[0x%016llx] data type[%s] not supported",
      19              :             HCOM_ERROR_CODE(HCCL_E_NOT_SUPPORT), GetDataTypeEnumStr(dataType).c_str());
      20            0 :         return HCCL_E_NOT_SUPPORT;
      21              :     }
      22            0 :     return HCCL_SUCCESS;
      23              : }
      24              : 
      25            0 : inline HcclResult CheckCount(const u64 count)
      26              : {
      27            0 :     if (count > SYS_MAX_COUNT) {
      28            0 :         HCCL_ERROR("[Check][Count]errNo[0x%016llx] count[%llu] is invalid(bigger than MAX count[%llu])",
      29              :             HCOM_ERROR_CODE(HCCL_E_PARA), count, SYS_MAX_COUNT);
      30            0 :         return HCCL_E_PARA;
      31              :     }
      32            0 :     return HCCL_SUCCESS;
      33              : }
      34              : 
      35            0 : inline HcclResult CheckSendRecvInfo(AscendSendRecvInfo* sendRecvInfo)
      36              : {
      37            0 :     CHK_PTR_NULL(sendRecvInfo);
      38            0 :     CHK_PTR_NULL(sendRecvInfo->localQPinfo);
      39              : 
      40            0 :     CHK_PTR_NULL(sendRecvInfo->localWindowMem);
      41            0 :     CHK_PTR_NULL(sendRecvInfo->remoteWindowMem);
      42              : 
      43            0 :     CHK_PTR_NULL(sendRecvInfo->localSyncMemPrepare);
      44            0 :     CHK_PTR_NULL(sendRecvInfo->localSyncMemDone);
      45            0 :     CHK_PTR_NULL(sendRecvInfo->localSyncMemAck);
      46              : 
      47            0 :     CHK_PTR_NULL(sendRecvInfo->remoteSyncMemPrepare);
      48            0 :     CHK_PTR_NULL(sendRecvInfo->remoteSyncMemDone);
      49            0 :     CHK_PTR_NULL(sendRecvInfo->remoteSyncMemAck);
      50              : 
      51            0 :     CHK_PTR_NULL(reinterpret_cast<void*>(sendRecvInfo->localWindowMem->addr));
      52            0 :     CHK_PTR_NULL(reinterpret_cast<void*>(sendRecvInfo->remoteWindowMem->addr));
      53              : 
      54            0 :     CHK_PTR_NULL(reinterpret_cast<void*>(sendRecvInfo->localSyncMemPrepare->addr));
      55            0 :     CHK_PTR_NULL(reinterpret_cast<void*>(sendRecvInfo->localSyncMemDone->addr));
      56            0 :     CHK_PTR_NULL(reinterpret_cast<void*>(sendRecvInfo->localSyncMemAck->addr));
      57              : 
      58            0 :     CHK_PTR_NULL(reinterpret_cast<void*>(sendRecvInfo->remoteSyncMemPrepare->addr));
      59            0 :     CHK_PTR_NULL(reinterpret_cast<void*>(sendRecvInfo->remoteSyncMemDone->addr));
      60            0 :     CHK_PTR_NULL(reinterpret_cast<void*>(sendRecvInfo->remoteSyncMemAck->addr));
      61            0 :     return HCCL_SUCCESS;
      62              : }
      63              : 
      64           19 : inline HcclResult CheckSendRecvLinkInfo(AscendSendRecvLinkInfo* sendRecvInfo)
      65              : {
      66           19 :     CHK_PTR_NULL(sendRecvInfo);
      67           19 :     CHK_PTR_NULL(sendRecvInfo->localQPinfo);
      68              : 
      69           19 :     CHK_PTR_NULL(sendRecvInfo->localSyncMemPrepare);
      70           19 :     CHK_PTR_NULL(sendRecvInfo->localSyncMemDone);
      71           19 :     CHK_PTR_NULL(sendRecvInfo->localSyncMemAck);
      72              : 
      73           19 :     CHK_PTR_NULL(sendRecvInfo->remoteSyncMemPrepare);
      74           19 :     CHK_PTR_NULL(sendRecvInfo->remoteSyncMemDone);
      75           19 :     CHK_PTR_NULL(sendRecvInfo->remoteSyncMemAck);
      76           19 :     return HCCL_SUCCESS;
      77              : }
      78              : 
      79           11 : inline HcclResult CheckSendLinkInfo(AscendSendLinkInfo* sendInfo)
      80              : {
      81           11 :     CHK_PTR_NULL(sendInfo);
      82           11 :     CHK_PTR_NULL(sendInfo->localQPinfo);
      83           11 :     CHK_PTR_NULL(sendInfo->localSyncMemAck);
      84           11 :     CHK_PTR_NULL(sendInfo->remoteNotifyValueMem);
      85              :     // 校验sendInfo->remoteNotifyValueMem长度
      86           11 :     const uint32_t NOTIFY_MEM_LEN = 4;
      87           11 :     CHK_PRT_RET(sendInfo->remoteNotifyValueMem->size != NOTIFY_MEM_LEN, HCCL_ERROR("[CheckSendLinkInfo] remoteNotifyValueMem len expect:[%u], actual:[%llu].",
      88              :         NOTIFY_MEM_LEN, sendInfo->remoteNotifyValueMem->size), HCCL_E_PARA);
      89           10 :     return HCCL_SUCCESS;
      90              : }
      91              : 
      92            0 : inline HcclResult CheckParam(void* buf, uint64_t count, HcclDataType dataType, aclrtStream stream)
      93              : {
      94            0 :     CHK_PTR_NULL(buf);
      95            0 :     CHK_RET(CheckCount(count));
      96            0 :     CHK_RET(CheckDataType(dataType));
      97            0 :     CHK_PTR_NULL(stream);
      98            0 :     return HCCL_SUCCESS;
      99              : }
     100              : }
     101              : // namespace hccl
     102              : #endif
        

Generated by: LCOV version 2.0-1