LCOV - code coverage report
Current view: top level - legacy/ascend910/platform/common/unfold_cache - op_unfold_key.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 60 60
Test Date: 2026-07-28 12:11:00 Functions: 100.0 % 6 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              : 
      11              : #include <sstream>
      12              : 
      13              : #include "op_unfold_key.h"
      14              : 
      15              : #include "log.h"
      16              : 
      17              : namespace hccl {
      18          466 :     OpUnfoldKey::OpUnfoldKey()
      19          466 :         : opType(HcclCMDType::HCCL_CMD_INVALID), dataType(HcclDataType::HCCL_DATA_TYPE_RESERVED), reduceType(HcclReduceOp::HCCL_REDUCE_RESERVED), isZeroCopy(false), inputSize(0), isInplacePreSync(false), workflowMode(HcclWorkflowMode::HCCL_WORKFLOW_MODE_RESERVED), isCapture(false), root(0) {
      20          466 :     }
      21              : 
      22            1 :     OpUnfoldKey::OpUnfoldKey(const OpUnfoldKey& other)
      23            1 :         : opType(other.opType), dataType(other.dataType), reduceType(other.reduceType), isZeroCopy(other.isZeroCopy), inputSize(other.inputSize), isInplacePreSync(other.isInplacePreSync), workflowMode(other.workflowMode), isCapture(other.isCapture), root(other.root) {
      24            1 :         CHK_PRT_CONT(opType == HcclCMDType::HCCL_CMD_INVALID, HCCL_ERROR("[OpUnfoldKey][OpUnfoldKey] opType is invalid"));
      25            1 :         if (opType != HcclCMDType::HCCL_CMD_ALLTOALLV && opType != HcclCMDType::HCCL_CMD_ALLTOALLVC) { // 非V类算子, dataType一定不是RESERVED; 如果是alltoallv类算子 (alltoallv/alltoallvc), dataType一定是RESERVED
      26            1 :             CHK_PRT_CONT(dataType == HcclDataType::HCCL_DATA_TYPE_RESERVED, HCCL_ERROR("[OpUnfoldKey][OpUnfoldKey] dataType is reserved"));
      27              :         }
      28            1 :         CHK_PRT_CONT(workflowMode == HcclWorkflowMode::HCCL_WORKFLOW_MODE_RESERVED, HCCL_ERROR("[[OpUnfoldKey][OpUnfoldKey]] workflowMode is reserved"));
      29              : 
      30              :         // 注意: 当算子不涉及reduce操作时, reduceType为HcclReduceOp::HCCL_REDUCE_RESERVED
      31            1 :     }
      32              : 
      33           19 :     HcclResult OpUnfoldKey::Init(const HcclCMDType curOpType, const HcclDataType curDataType, const HcclReduceOp curReduceType, const bool curIsZeroCopy,
      34              :         const uint64_t curInputSize, const bool curIsInplacePreSync, const HcclWorkflowMode curWorkflowMode, const bool curIsCapture,
      35              :         const uint32_t curRoot) {
      36           19 :         CHK_PRT_RET(curOpType == HcclCMDType::HCCL_CMD_INVALID, HCCL_ERROR("[OpUnfoldKey][OpUnfoldKey] opType is invalid"), HCCL_E_INTERNAL);
      37           19 :         if (curOpType != HcclCMDType::HCCL_CMD_ALLTOALLV && curOpType != HcclCMDType::HCCL_CMD_ALLTOALLVC) { // 非V类算子, dataType一定不是RESERVED; 如果是alltoallv类算子 (alltoallv/alltoallvc), dataType一定是RESERVED
      38           19 :             CHK_PRT_RET(curDataType == HcclDataType::HCCL_DATA_TYPE_RESERVED, HCCL_ERROR("[OpUnfoldKey][OpUnfoldKey] dataType is reserved"), HCCL_E_INTERNAL);
      39              :         }
      40           19 :         CHK_PRT_RET(curWorkflowMode == HcclWorkflowMode::HCCL_WORKFLOW_MODE_RESERVED, HCCL_ERROR("[[OpUnfoldKey][Init]] workflowMode is reserved"), HCCL_E_INTERNAL);
      41              : 
      42              :         // 注意: 当算子不涉及reduce操作时, reduceType为HcclReduceOp::HCCL_REDUCE_RESERVED
      43              : 
      44           19 :         opType = curOpType;
      45           19 :         dataType = curDataType;
      46           19 :         reduceType = curReduceType;
      47           19 :         isZeroCopy = curIsZeroCopy;
      48           19 :         inputSize = curInputSize;
      49           19 :         isInplacePreSync = curIsInplacePreSync;
      50           19 :         workflowMode = curWorkflowMode;
      51           19 :         isCapture = curIsCapture;
      52              :         // 注意: curRoot 默认值为 0, 对非root类算子无影响; 对 scatter/broadcast/reduce 会区分不同 root
      53           19 :         root = curRoot;
      54              : 
      55           19 :         return HCCL_SUCCESS;
      56              :     }
      57              : 
      58            5 :     std::string OpUnfoldKey::GetKeyString() const {
      59            5 :         std::ostringstream oss;
      60            5 :         oss << "opType" << static_cast<uint32_t>(opType)
      61            5 :             << "-dataType" << static_cast<uint32_t>(dataType)
      62            5 :             << "-reduceType" << static_cast<uint32_t>(reduceType)
      63            5 :             << "-isZeroCopy" << isZeroCopy
      64            5 :             << "-inputSize" << inputSize
      65            5 :             << "-isInplacePreSync" << isInplacePreSync
      66            5 :             << "-workflowMode" << static_cast<uint32_t>(workflowMode)
      67            5 :             << "-isCapture" << isCapture
      68            5 :             << "-root" << root;
      69           10 :         return oss.str();
      70            5 :     }
      71              : 
      72            4 :     bool OpUnfoldKey::operator==(const OpUnfoldKey& other) const {
      73            8 :         return opType == other.opType &&
      74            4 :             dataType == other.dataType &&
      75            4 :             reduceType == other.reduceType &&
      76            4 :             isZeroCopy == other.isZeroCopy &&
      77            4 :             inputSize == other.inputSize &&
      78            4 :             isInplacePreSync == other.isInplacePreSync &&
      79            4 :             workflowMode == other.workflowMode &&
      80           11 :             isCapture == other.isCapture &&
      81            7 :             root == other.root;
      82              :     }
      83              : 
      84            1 :     const OpUnfoldKey& OpUnfoldKey::operator=(const OpUnfoldKey& other) {
      85            1 :         if (this != &other) {
      86            1 :             this->opType = other.opType;
      87            1 :             this->dataType = other.dataType;
      88            1 :             this->reduceType = other.reduceType;
      89            1 :             this->isZeroCopy = other.isZeroCopy;
      90            1 :             this->inputSize = other.inputSize;
      91            1 :             this->isInplacePreSync = other.isInplacePreSync;
      92            1 :             this->workflowMode = other.workflowMode;
      93            1 :             this->isCapture = other.isCapture;
      94            1 :             this->root = other.root;
      95              :         }
      96            1 :         return *this;
      97              :     }
      98              : 
      99              : }; // namespace hccl
        

Generated by: LCOV version 2.0-1