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