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_COLL_SERVICE_DEFAULT_IMPL_H
12 : #define HCCLV2_COLL_SERVICE_DEFAULT_IMPL_H
13 :
14 : #include <set>
15 : #include <vector>
16 : #include <string>
17 : #include "coll_service_base.h"
18 : #include "hccl_params_pub.h"
19 : #include "coll_operator.h"
20 : #include "stream.h"
21 : #include "virtual_topo.h"
22 : #include "prim_queue.h"
23 : #include "ins_queue.h"
24 : #include "instruction.h"
25 : #include "prim_translator.h"
26 : #include "interpreter.h"
27 : #include "connections_builder.h"
28 : #include "mask_event.h"
29 : #include "ub_ci_updater_manager.h"
30 : #include "trace.h"
31 : namespace Hccl {
32 :
33 : class CollServiceDefaultImpl : public CollServiceBase {
34 : public:
35 216 : explicit CollServiceDefaultImpl(CommunicatorImpl* comm) : CollServiceBase(comm) {};
36 :
37 : void Init() override;
38 :
39 : void LoadWithOpBasedMode(CollOperator& op, unique_ptr<Stream> stream) override;
40 :
41 : void LoadWithOffloadMode(CollOperator& op, std::unique_ptr<Stream> stream) override;
42 :
43 : void RecoverTransport(vector<LinkData>& links, vector<std::pair<LinkGroup, u32>> linkGroupPair) override;
44 :
45 : void ReLoadWithOpBasedMode(CollOperator& op) override;
46 :
47 : void ReLoadWithOffloadMode(CollOperator& op) override;
48 :
49 : private:
50 : shared_ptr<PrimQueue> OrchestrateWithPrim(const CollAlgOperator& op) const;
51 :
52 : shared_ptr<InsQueue> OrchestrateWithIns(const CollAlgOperator& op) const;
53 :
54 : void AllocNotifies(const vector<LinkData>& links);
55 :
56 : void AllocOneLocCntNotify(const Instruction& ins) const;
57 :
58 : void AllocLocCntNotifies(const InsQueue& insQueue) const;
59 :
60 : void AddNop(const std::string& opTag, const vector<LinkData>& linkDataVec) const;
61 :
62 : void UpdateUbCiIfNeed(const std::string& opTag);
63 :
64 : void LoadWithOpBasedModeNoRegister(CollOperator& op);
65 :
66 : void LoadWithOffloadModeNoRegister(CollOperator& op);
67 :
68 : unique_ptr<PrimTranslator> primTranslator;
69 :
70 : // 创建rmaConnections
71 : unordered_map<std::string, unique_ptr<ConnectionsBuilder>> connectionsBuilders;
72 :
73 : std::set<LinkData> availableLinks;
74 :
75 : std::unique_ptr<UbCiUpdaterManager> ubCiUpdaterMgr;
76 :
77 : std::unique_ptr<MaskEvent> updatingUbCiEvent;
78 : };
79 : } // namespace Hccl
80 :
81 : #endif // HCCLV2_COLL_SERVICE_H
|