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 "coll_reduce_scatter_v_ring_for_910_93_executor.h"
12 : #include <numeric>
13 :
14 : namespace hccl {
15 :
16 0 : CollReduceScatterVRingFor91093Executor::CollReduceScatterVRingFor91093Executor(const HcclDispatcher dispatcher,
17 0 : std::unique_ptr<TopoMatcher> &topoMatcher)
18 0 : : CollReduceScatterRingFor91093Executor(dispatcher, topoMatcher)
19 : {
20 0 : isReduceScatterV_ = true;
21 0 : desc_.level1SupportedAlgos = {
22 : AlgTypeLevel1::ALG_LEVEL1_NHR,
23 : AlgTypeLevel1::ALG_LEVEL1_NB,
24 : AlgTypeLevel1::ALG_LEVEL1_RING
25 0 : };
26 0 : }
27 :
28 0 : u64 CollReduceScatterVRingFor91093Executor::CalcLoopMaxCount(const u32 unitSize)
29 : {
30 : // 中转内存单次最多能够接受的output count,这里不除以RankSize,因为每次循环可能会减少需要参与通信的Rank
31 0 : return inCCLbufferSize_ / HCCL_MIN_SLICE_ALIGN * HCCL_MIN_SLICE_ALIGN / unitSize;
32 : }
33 :
34 0 : bool CollReduceScatterVRingFor91093Executor::IsHugeData(const u64 curSize, OpParam *param)
35 : {
36 : u32 level2RankSize;
37 0 : if (algType_.algoLevel1 == AlgTypeLevel1::ALG_LEVEL1_AHC ||
38 0 : algType_.algoLevel1 == AlgTypeLevel1::ALG_LEVEL1_AHC_BROKE) {
39 : // AHC非对称场景下没有L2
40 0 : level2RankSize = 1;
41 : } else {
42 : // 多QP哈希散列开启且RDMA通信下,强制刷新子图
43 : // 这里如果CheckCommSize返回ERROR,相当于HugeData true,防止GetSubCommInfo越界
44 0 : CHK_RET(CheckCommSize(COMM_LEVEL2, COMM_INDEX_0 + 1));
45 0 : SubCommInfo level2CommInfo = GetSubCommInfo(COMM_LEVEL2, COMM_INDEX_0);
46 0 : level2RankSize = level2CommInfo.localRankSize;
47 0 : }
48 :
49 0 : const HcclDataType dataType = param->GetDataType();
50 0 : const u64 TBE_REDUCE_MAX_COUNT = INT32_MAX;
51 0 : u64 curCount = curSize / SIZE_TABLE[dataType];
52 0 : bool issupportRDMAInlineReduce = IsSupportRDMAReduce(dataType, param->reduceType);
53 0 : bool hugeData = (curSize * level2RankSize > RDMA_SEND_MAX_SIZE) || (curSize > SDMA_SEND_MAX_SIZE) ||
54 0 : ((!isSupportSDMAReduce_) && (curCount > TBE_REDUCE_MAX_COUNT)) ||
55 0 : ((!issupportRDMAInlineReduce) && (curCount * level2RankSize > TBE_REDUCE_MAX_COUNT));
56 0 : return hugeData;
57 : }
58 :
59 : REGISTER_EXEC("ReduceScatterVRingFor91093Executor", ReduceScatterVRingFor91093, CollReduceScatterVRingFor91093Executor);
60 : }
|