LCOV - code coverage report
Current view: top level - legacy/ascend910/framework/group - hccl_group_utils.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 1 1
Test Date: 2026-08-04 10:52:23 Functions: - 0 0

            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 HCCL_GROUP_UTILS_H
      11              : #define HCCL_GROUP_UTILS_H
      12              : 
      13              : #include <mutex>
      14              : #include <string>
      15              : #include <hccl/hccl_types.h>
      16              : #include <hccl_inner.h>
      17              : #include "op_base.h"
      18              : #include "hccl_comm_pub.h"
      19              : 
      20              : namespace hccl{
      21              : 
      22              : using hcclGroupJobState_t = enum hcclGroupJobState {
      23              :     hcclGroupJobRunning = 0,
      24              :     hcclGroupJobDone = 1,
      25              :     hcclGroupJobJoined = 2,
      26              : };
      27              : 
      28            1 : struct hcclAsyncJob {
      29              :     struct hcclAsyncJob *next;
      30              :     std::unique_ptr<std::thread> thread; /*记录该job异步执行pthread_create 创建的thread句柄*/
      31              :     HcclResult result;                   /* 用于记录job->func的执行结果,job->result = job->func(job) */
      32              :     HcclResult (*func)(struct hcclAsyncJob *);
      33              :     hcclGroupJobState state;
      34              :     std::mutex mtx;
      35              :     HcclComm *comm;
      36              : };
      37              : 
      38              : struct hcclCommInitAsyncJob : public hcclAsyncJob {
      39              :     u32 nRanks;
      40              :     const HcclRootInfo *rootInfo;
      41              :     u32 rank;
      42              :     s32 devId;
      43              :     HcclComm *initComm;
      44              :     std::string identifier;
      45              : };
      46              : 
      47              : struct hcclCommInitConfigAsyncJob : public hcclAsyncJob {
      48              :     u32 nRanks;
      49              :     const HcclRootInfo *rootInfo;
      50              :     u32 rank;
      51              :     s32 devId;
      52              :     HcclComm *initComm;
      53              :     std::string identifier;
      54              :     const HcclCommConfig *config;
      55              : };
      56              : 
      57              : struct hcclCommInitRankTableAsyncJob : public hcclAsyncJob {
      58              :     const char *clusterInfo;
      59              :     u32 rank;
      60              :     HcclComm *initComm;
      61              :     s32 devId;
      62              : };
      63              : 
      64              : struct hcclCommInitRankTableConfigAsyncJob : public hcclAsyncJob {
      65              :     const char *clusterInfo;
      66              :     u32 rank;
      67              :     HcclComm *initComm;
      68              :     HcclCommConfig *config;
      69              :     s32 devId;
      70              : };
      71              : 
      72              : struct hcclCommDestroyAsyncJob : public hcclAsyncJob {
      73              :     HcclComm initComm;
      74              :     s32 devId;
      75              : };
      76              : 
      77              : struct hcclOpInfo {/*用于保存算子的入参。所有算子用同个结构体保存info */
      78              :     HcclCMDType coll;
      79              :     void* sendbuff;
      80              :     void* recvbuff;
      81              :     u64 sendCount; // for non-V operators
      82              :     u64 recvCount; // for non-V operators
      83              :     const void *sendCounts;
      84              :     const void *recvCounts;
      85              :     const void *sdispls;
      86              :     const void *rdispls;
      87              :     HcclDataType sendType;
      88              :     HcclDataType recvType;
      89              :     HcclReduceOp op;
      90              :     u32 root; // dstRank或root rank
      91              :     HcclComm comm;
      92              :     HcclRtStream stream;
      93              : };
      94              : 
      95              : struct hcclTaskP2p {
      96              :     struct hcclTaskP2p *next;
      97              :     HcclCMDType func;
      98              :     void *buff;
      99              :     u64 count;
     100              :     HcclDataType datatype;
     101              :     s32 root;       /*即peer或dstRank*/
     102              :     u64 bytes; /*即count*dataTypeSize*/
     103              :     HcclComm comm;
     104              :     HcclRtStream stream;
     105              : };
     106              :  
     107              : struct hcclKernelPlanner {
     108              :     s32 nTasksColl = -1;
     109              :     s32 nTasksP2p = -1;//该plan中Coll和P2p task的个数
     110              :     u32 rankSize = 0;
     111              : 
     112              :     std::set<HcclRtStream> collStreams;
     113              :     HcclRtStream sendRecvMainStream; // sendRecv的主流,用于跟从流同步
     114              : 
     115              :     std::vector<HcclSendRecvItem> sendRecvInfo;
     116              : 
     117              :     std::deque<struct hcclOpInfo> collTaskQueue;
     118              : };
     119              : 
     120              : }// namespace hccl
     121              : #endif
        

Generated by: LCOV version 2.0-1