LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/base/communicator - comm_ahc_pub.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 96.0 % 25 24
Test Date: 2026-08-18 17:47:01 Functions: 80.0 % 5 4

            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 COMM_AHC_PUB_H
      12              : #define COMM_AHC_PUB_H
      13              : 
      14              : #include <cmath>
      15              : #include <algorithm>
      16              : #include "device_capacity.h"
      17              : 
      18              : namespace hccl {
      19              : 
      20              : // AHC算法相关
      21              : enum class AHCLevel { AHC_LEVEL_0 = 0, AHC_LEVEL_1, AHC_LEVEL_MAX };
      22              : 
      23              : enum class ConcType { CONC_INTRA = 0, CONC_INTER, CONC_RESERVED };
      24              : 
      25              : enum class AHCOpType {
      26              :     AHC_OP_TYPE_ALLGATHER = 0,
      27              :     AHC_OP_TYPE_ALLREDUCE,
      28              :     AHC_OP_TYPE_REDUCE_SCATTER,
      29              :     AHC_OP_TYPE_RESERVED
      30              : };
      31              : 
      32              : enum class AHCTemplateType {
      33              :     // AHC 内置template类型
      34              :     AHC_TEMPLATE_NB = 0,
      35              :     AHC_TEMPLATE_RING,
      36              :     AHC_TEMPLATE_NHR,
      37              :     AHC_TEMPLATE_RESERVED
      38              : };
      39              : 
      40              : // AHC prepare 扩展参数定义
      41              : using OXCPreparePara = struct OXCPrepareParaDef {
      42              :     u32 netPlaneId;
      43              :     u32 netPlaneNum;
      44              :     OXCPrepareParaDef(u32 netPlaneId, u32 netPlaneNum) : netPlaneId(netPlaneId), netPlaneNum(netPlaneNum) {}
      45              : };
      46              : 
      47              : union AHCExtendPreparePara {
      48              :     OXCPreparePara oxcPreparePara;
      49            0 :     AHCExtendPreparePara() {}
      50              : };
      51              : 
      52              : using AHCConcOpType = struct AHCConcOpTypeDef {
      53              :     AHCLevel ahcLevel;
      54              :     ConcType concType;
      55              :     AHCOpType ahcOpType;
      56              : 
      57           11 :     AHCConcOpTypeDef()
      58           11 :         : ahcLevel(AHCLevel::AHC_LEVEL_0),
      59           11 :           concType(ConcType::CONC_INTRA),
      60           11 :           ahcOpType(AHCOpType::AHC_OP_TYPE_RESERVED)
      61           11 :     {}
      62              : 
      63         6348 :     AHCConcOpTypeDef(AHCLevel ahcLevel, ConcType concType, AHCOpType ahcOpType)
      64         6333 :         : ahcLevel(ahcLevel),
      65         6333 :           concType(concType),
      66         6333 :           ahcOpType(ahcOpType)
      67         6333 :     {}
      68              : 
      69              :     // 重载 == 运算符,用于比较两个 MyKey 对象是否相等
      70              :     bool operator==(const AHCConcOpTypeDef& other) const
      71              :     {
      72              :         return ahcLevel == other.ahcLevel && concType == other.concType && ahcOpType == other.ahcOpType;
      73              :     }
      74              : 
      75              :     // 重载 < 运算符,用于排序
      76        28760 :     bool operator<(const AHCConcOpTypeDef& other) const
      77              :     {
      78        28760 :         if (ahcLevel != other.ahcLevel) {
      79         7029 :             return ahcLevel < other.ahcLevel;
      80              :         }
      81        21731 :         if (concType != other.concType) {
      82         9756 :             return concType < other.concType;
      83              :         }
      84        11975 :         return ahcOpType < other.ahcOpType;
      85              :     }
      86              : };
      87              : constexpr double AHC_SYM_THRESHOLD = 0.05;
      88              : using AHCAlgSelectParam = struct AHCAlgSelectParamDef {
      89              :     bool enableOXC;
      90              :     bool enableAlgAutoSelect;
      91              :     bool enableSubGroupsSplit;
      92              :     u64 dataSize;
      93              :     AHCOpType opType;
      94              :     float symThreshold;
      95              : 
      96           11 :     AHCAlgSelectParamDef()
      97           11 :         : enableOXC(false),
      98           11 :           enableAlgAutoSelect(true),
      99           11 :           enableSubGroupsSplit(true),
     100           11 :           dataSize(0),
     101           11 :           opType(AHCOpType::AHC_OP_TYPE_RESERVED),
     102           11 :           symThreshold(AHC_SYM_THRESHOLD)
     103           11 :     {}
     104              : };
     105              : 
     106              : } // namespace hccl
     107              : 
     108              : #endif /* COMM_AHC_PUB_H */
        

Generated by: LCOV version 2.0-1