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