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 "calc_transport_req_base.h"
12 :
13 : namespace hccl {
14 172 : CalcTransportReqBase::CalcTransportReqBase(const std::vector<std::vector<u32>> &subCommPlaneVector,
15 172 : const std::vector<bool> &isBridgeVector, u32 userRank)
16 172 : : subCommPlaneVector_(subCommPlaneVector), isBridgeVector_(isBridgeVector),
17 172 : userRank_(userRank)
18 : {
19 172 : }
20 :
21 172 : CalcTransportReqBase::~CalcTransportReqBase()
22 : {
23 172 : }
24 :
25 0 : HcclResult CalcTransportReqBase::CalcTransportRequest(const std::string &tag, TransportMemType inputMemType,
26 : TransportMemType outputMemType, const CommParaInfo &commParaInfo,
27 : std::vector<SingleSubCommTransport> &commTransport, u32 subUserRankRoot)
28 : {
29 0 : return HCCL_SUCCESS;
30 : }
31 :
32 206 : u32 CalcTransportReqBase::GetSubCollectiveRank(const std::vector<u32> &vecPara) const
33 : {
34 : // 在vecPara数据中,查询本user rank,查询到的vec下标就是rank值
35 206 : u32 tmpRank = INVALID_VALUE_RANKID;
36 :
37 324 : for (u32 rankIndex = 0; rankIndex < vecPara.size(); rankIndex++) {
38 324 : if (userRank_ == vecPara[rankIndex]) {
39 203 : tmpRank = rankIndex;
40 203 : break;
41 : }
42 : }
43 :
44 202 : return tmpRank;
45 : }
46 :
47 0 : HcclResult CalcTransportReqBase::GetRankByUserRank(const std::vector<u32> &vecPara,
48 : const u32 userRank, u32 &rank) const
49 : {
50 : // 在vecPara数据中,查询指定userRank,查询到的vec下标就是rank值
51 0 : rank = INVALID_VALUE_RANKID;
52 :
53 0 : for (u32 rankIndex = 0; rankIndex < vecPara.size(); rankIndex++) {
54 0 : if (userRank == vecPara[rankIndex]) {
55 0 : rank = rankIndex;
56 0 : break;
57 : }
58 : }
59 0 : HCCL_INFO("[Get][RankByUserRank]userRank[%u] --> rank[%u]", userRank, rank);
60 0 : return HCCL_SUCCESS;
61 : }
62 :
63 : } // namespace hccl
|