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 : #ifndef HCCLV2_INS_TEMP_ALL_GATHER_MESH
12 : #define HCCLV2_INS_TEMP_ALL_GATHER_MESH
13 :
14 : #include "string_util.h"
15 : #include "executor_utils.h"
16 : #include "ins_alg_template_base.h"
17 :
18 : namespace Hccl {
19 :
20 : class InsTempAllGatherMesh1DOpt : public InsAlgTemplateBase {
21 : public:
22 : explicit InsTempAllGatherMesh1DOpt(
23 : const RankId virtualRank, const u32 tempRankSize, const std::vector<std::vector<RankId>>& tempVTopo,
24 : const std::map<RankId, u32>& tempVirtRankMap);
25 : ~InsTempAllGatherMesh1DOpt() override;
26 :
27 0 : std::string Describe() const override
28 : {
29 0 : return StringFormat("Instruction based Template of all gather mesh with tempRankSize [%u].", tempRankSize_);
30 : }
31 :
32 : HcclResult GenExtIns(
33 : const TempFuncs& tempFuncs, const TemplateDataParams& tempAlgParams, const ResLinks& tempLinks,
34 : std::vector<InsQuePtr>& tempInsQues);
35 : HcclResult CalcSliceInfo(const AllignInfo& allignInfo, const u64 dataSize, RankSliceInfo& sliceInfoVec) override;
36 : HcclResult CalcRes(AlgTempResReq& tempResReq) override;
37 : u32 CalcScratchMultiple(const BufferType& inBufferTpye, const BufferType& outBufferTpye) const
38 : {
39 : (void)inBufferTpye;
40 : (void)outBufferTpye;
41 : HCCL_INFO("[InsTempAllGatherMesh1DOpt][CalcScratchMultiple] templateScratchMultiplier[%llu]", tempRankSize_);
42 : return tempRankSize_;
43 : }
44 :
45 : private:
46 : HcclResult LocalCopyToScratch(InsQuePtr tempInsQue);
47 : HcclResult LocalCopyToUsrOut(InsQuePtr tempInsQue);
48 : HcclResult RunMesh(const u32 myAlgRank, const std::vector<RankId>& vTopo, std::vector<InsQuePtr>& tempInsQues);
49 :
50 : u32 majorQueNum_ = 0;
51 : u32 queNumPerNeighbor_ = 1;
52 : bool enableInterRankCounterNotify_ = false;
53 : TemplateDataParams tempAlgParams_;
54 : ResLinks tempLinks_;
55 : };
56 :
57 : } // namespace Hccl
58 :
59 : #endif // !HCCLV2_INS_TEMP_ALL_GATHER_MESH
|