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