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_CCU_INSTRUCTION_HALF_ALL_TO_ALL_V_MESH_1D_H_
12 : #define HCCLV2_CCU_INSTRUCTION_HALF_ALL_TO_ALL_V_MESH_1D_H_
13 :
14 : #include "template_utils.h"
15 : #include "instruction.h"
16 : #include "ins_queue.h"
17 : #include "ccu_context_utils.h"
18 : #include "ccu_ctx_signature.h"
19 : #include "ccu_ins.h"
20 : #include "ccu_rank_group.h"
21 :
22 : namespace Hccl {
23 :
24 : // 为AllToAllVMesh1D实现的CCUIns、CCUCtxArg与CCUTaskArg
25 : class CcuCtxArgHalfAllToAllVMesh1D : public CcuCtxArg {
26 : public:
27 0 : explicit CcuCtxArgHalfAllToAllVMesh1D(const std::vector<uint64_t> &dSize, uint32_t rId, const CollAlgOperator &op,
28 0 : uint32_t mId, uint64_t cclBufferAddr, const std::vector<std::vector<RankId>> &tempVTopo) :
29 0 : dimSize(dSize), rankId(rId), op(op), missionId(mId), cclBufferAddr(cclBufferAddr), tempVTopo(tempVTopo) {}
30 0 : CcuCtxSignature GetCtxSignature() const override
31 : {
32 0 : CcuCtxSignature signature;
33 0 : GenerateCcuCtxSignature(signature, CcuInstType::CCU_HALF_ALLTOALLV_MESH_1D, op, tempVTopo);
34 0 : return signature;
35 0 : }
36 : std::vector<uint64_t> dimSize;
37 : uint32_t rankId;
38 : CollAlgOperator op;
39 : uint32_t missionId;
40 : uint64_t cclBufferAddr;
41 : std::vector<std::vector<RankId>> tempVTopo;
42 : };
43 :
44 : class CcuTaskArgHalfAllToAllVMesh1D : public CcuTaskArg {
45 : public:
46 0 : explicit CcuTaskArgHalfAllToAllVMesh1D() {}
47 : };
48 :
49 : class CcuInstructionHalfAllToAllVMesh1D : public CcuInstruction {
50 : public:
51 0 : CcuInstructionHalfAllToAllVMesh1D() : CcuInstruction()
52 : {
53 0 : }
54 :
55 0 : void Init(uint32_t mId, uint32_t rankId, uint64_t scratchAddr, CollAlgOperator &op,
56 : std::vector<std::vector<RankId>> &tempVTopo)
57 : {
58 0 : u32 maxDimNum = 1;
59 0 : if (tempVTopo.size() != maxDimNum) {
60 0 : THROW<InvalidParamsException>(StringFormat(
61 : "[CcuInstructionHalfAllToAllVMesh1D] tempVTopo size is not 1, size is [%zu].", tempVTopo.size()));
62 : }
63 0 : dimSize_.push_back(tempVTopo[0].size());
64 0 : missionId_ = mId;
65 0 : rankId_ = rankId;
66 0 : cclBufferAddr_ = scratchAddr;
67 0 : op_ = op;
68 0 : tempVTopo_ = tempVTopo;
69 0 : return;
70 : }
71 :
72 0 : CcuInstType GetInstType() const override
73 : {
74 0 : HCCL_INFO("CcuInstructionHalfAllToAllVMesh1D instype is CCU_HALF_ALLTOALLV_MESH_1D.");
75 0 : return instType_;
76 : }
77 :
78 0 : std::string Describe() const override
79 : {
80 : return StringFormat("CcuInstructionHalfAllToAllVMesh1D rankId [%u], instType[%s]",
81 0 : rankId_, instType_.Describe().c_str());
82 : }
83 :
84 : void SetInstType(CcuInstType instType)
85 : {
86 : instType_ = instType;
87 : }
88 :
89 0 : std::unique_ptr<CcuCtxArg> GetCtxArg() const override
90 : {
91 0 : return std::make_unique<CcuCtxArgHalfAllToAllVMesh1D>(
92 0 : dimSize_, rankId_, op_, missionId_, cclBufferAddr_, tempVTopo_);
93 : }
94 :
95 0 : std::unique_ptr<CcuTaskArg> GetTaskArg() const override
96 : {
97 0 : return std::make_unique<CcuTaskArgHalfAllToAllVMesh1D>();
98 : }
99 :
100 : private:
101 : CcuInstType instType_ = CcuInstType::CCU_HALF_ALLTOALLV_MESH_1D;
102 : std::vector<uint64_t> dimSize_;
103 : uint32_t rankId_{0};
104 : uint32_t missionId_{0};
105 : uint64_t cclBufferAddr_{0};
106 : CollAlgOperator op_;
107 : std::vector<std::vector<RankId>> tempVTopo_;
108 : };
109 :
110 : }
111 : #endif // HCCLV2_CCU_INSTRUCTION_HALF_ALL_TO_ALL_V_MESH_1D_H_
|