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_CONTEXT_SCATTER_MESH_2D_H_
12 : #define HCCLV2_CCU_CONTEXT_SCATTER_MESH_2D_H_
13 :
14 : #include <vector>
15 :
16 : #include <ios>
17 : #include "log.h"
18 : #include "ccu_context_alg_base.h"
19 : #include "ccu_datatype.h"
20 :
21 : namespace Hccl {
22 :
23 : class CcuContextScatterMesh2D : public CcuContextAlgBase {
24 : public:
25 : CcuContextScatterMesh2D(const CcuCtxArg &arg, const std::vector<CcuTransport*> &transports,
26 : const CcuTransportGroup &group);
27 0 : ~CcuContextScatterMesh2D() override {}
28 :
29 : void Algorithm() override;
30 : std::vector<uint64_t> GeneArgs(const CcuTaskArg &arg) override;
31 : private:
32 : uint64_t root_{0};
33 : std::vector<uint64_t> dimSize_;
34 : uint64_t axisId_{0};
35 : std::vector<uint64_t> dimId_;
36 : std::vector<uint64_t> rootDimId_;
37 : uint64_t localId_{0};
38 : uint64_t localSize_{0};
39 :
40 : CcuRep::Variable input_;
41 : std::vector<CcuRep::Variable> scratch_;
42 : std::vector<CcuRep::Variable> output_;
43 : std::vector<CcuRep::Variable> token_;
44 : CcuRep::Variable sliceSize_;
45 : CcuRep::Variable stride_;
46 : std::vector<CcuRep::Variable> axisSliceSize_;
47 : GroupOpSize curGoSize_;
48 :
49 : std::string localAxisSignalName_;
50 : std::string anotherAxisSignalName_;
51 : CcuRep::MaskSignal localAxisSignal_;
52 : CcuRep::MaskSignal anotherAxisSignal_;
53 :
54 : bool SameRowWithRoot();
55 : bool SameColumnWithRoot();
56 : void PrepareVariables();
57 : void LoadArgs();
58 : void PreSync();
59 : void Sync(uint32_t ckeId);
60 : void AxisSync(uint32_t signalIndex);
61 : void CcuWrite1DMesh(std::vector<CcuRep::Memory> &src, std::vector<CcuRep::Memory> &dst, CcuRep::Variable &size);
62 : uint64_t CoordinateToGlobalId(uint32_t x, uint32_t y);
63 : void CcuMultiply(CcuRep::Memory &a, CcuRep::Variable &b, uint64_t i) const;
64 :
65 : void PrepareAndTransferRootRelayInfo(std::vector<CcuRep::Memory> &relaySrc, std::vector<CcuRep::Memory> &relayDst);
66 : void RelaySendFor1D(std::vector<CcuRep::Memory> &relaySrc, std::vector<CcuRep::Memory> &relayDst, uint64_t j);
67 : void PrepareAndTransferRootDirectInfo(std::vector<CcuRep::Memory> &directSrc, std::vector<CcuRep::Memory> &directDst);
68 : void RelaySend(std::vector<CcuRep::Memory> &relaySrc, std::vector<CcuRep::Memory> &relayDst);
69 : void LocalTransfer();
70 :
71 : void RootSendAlgorithm();
72 : void RelaySendAlgorithm();
73 : void NonDirectRecvAlgorithm();
74 : };
75 : } // namespace Hccl
76 : #endif // HCCLV2_CCU_CONTEXT_SCATTER_MESH_2D_H_
|