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