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_all_to_all_v_aiv_direct_executor.h"
12 :
13 : namespace hccl {
14 :
15 0 : CollRunAlltoAllAivDirect::CollRunAlltoAllAivDirect(const HcclDispatcher dispatcher,
16 0 : std::unique_ptr<TopoMatcher> &topoMatcher)
17 0 : : CollAlltoAllExecutor(dispatcher, topoMatcher)
18 : {
19 0 : }
20 :
21 : // 超节点内建SDMA链路;超节点间建RDMA链路
22 0 : HcclResult CollRunAlltoAllAivDirect::CalcLevel0CommInfo(TransportMemType inputType, TransportMemType outputType,
23 : std::vector<LevelNSubCommTransport>& opTransport)
24 : {
25 0 : CommParaInfo commCombinePara(COMM_LEVEL0, CommType::COMM_TAG_MESH);
26 0 : CHK_RET(CalcCommPlaneInfo(tag_, commCombinePara, opTransport[COMM_LEVEL0], inputType, outputType));
27 :
28 0 : LevelNSubCommTransport &commTransportLevel0 = opTransport[COMM_LEVEL0];
29 0 : for (u32 subCommIndex = 0; subCommIndex < commTransportLevel0.size(); subCommIndex++) {
30 0 : for (auto &transportRequest : commTransportLevel0[subCommIndex].transportRequests) {
31 0 : transportRequest.isUsedRdma = topoAttr_.isUsedRdmaMap.at(transportRequest.remoteUserRank);
32 : }
33 : }
34 0 : return HCCL_SUCCESS;
35 0 : }
36 :
37 0 : HcclResult CollRunAlltoAllAivDirect::CalcLevel1CommInfo(TransportMemType inputType, TransportMemType outputType,
38 : std::vector<LevelNSubCommTransport>& opTransport)
39 : {
40 0 : CommParaInfo commCombinePara(COMM_MESH_L1, CommType::COMM_TAG_MESH);
41 0 : CHK_RET(CalcCommPlaneInfo(tag_, commCombinePara, opTransport[COMM_MESH_L1], inputType, outputType));
42 :
43 0 : LevelNSubCommTransport &commTransportLevel0 = opTransport[COMM_MESH_L1];
44 0 : for (u32 subCommIndex = 0; subCommIndex < commTransportLevel0.size(); subCommIndex++) {
45 0 : for (auto &transportRequest : commTransportLevel0[subCommIndex].transportRequests) {
46 0 : transportRequest.isUsedRdma = true;
47 : }
48 : }
49 0 : return HCCL_SUCCESS;
50 0 : }
51 :
52 0 : HcclResult CollRunAlltoAllAivDirect::CalcTransportMemType(TransportMemType &inputType, TransportMemType &outputType) const
53 : {
54 0 : inputType = TransportMemType::CCL_INPUT;
55 0 : outputType = TransportMemType::CCL_OUTPUT;
56 :
57 0 : HCCL_INFO("[CollRunAlltoAllAivDirect][CalcTransportMemType] tag[%s] inputType[%d], outputType[%d]",
58 : tag_.c_str(), inputType, outputType);
59 0 : return HCCL_SUCCESS;
60 : }
61 :
62 0 : HcclResult CollRunAlltoAllAivDirect::CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport)
63 : {
64 0 : TransportMemType inputType = TransportMemType::RESERVED;
65 0 : TransportMemType outputType = TransportMemType::RESERVED;
66 :
67 0 : CHK_RET(CalcTransportMemType(inputType, outputType));
68 : // level0 hccs 全连接通信域
69 0 : CHK_RET(CalcLevel0CommInfo(inputType, outputType, opTransport));
70 : // level1 roce deviceid通信域
71 0 : CHK_RET(CalcLevel1CommInfo(inputType, outputType, opTransport));
72 :
73 0 : return HCCL_SUCCESS;
74 : }
75 :
76 : REGISTER_EXEC("RunAlltoAllAivDirect", AlltoAllVAivDirect, CollRunAlltoAllAivDirect);
77 : } // namespace hccl
|