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 : private:
48 : shared_ptr<PrimQueue> OrchestrateWithPrim(const CollAlgOperator &op) const;
49 :
50 : shared_ptr<InsQueue> OrchestrateWithIns(const CollAlgOperator &op) const;
51 :
52 : void AllocNotifies(const vector<LinkData> &links);
53 :
54 : void AllocOneLocCntNotify(const Instruction &ins) const;
55 :
56 : void AllocLocCntNotifies(const InsQueue &insQueue) const;
57 :
58 : void AddNop(const std::string &opTag, const vector<LinkData> &linkDataVec) const;
59 :
60 : void UpdateUbCiIfNeed(const std::string &opTag);
61 :
62 : void LoadWithOpBasedModeNoRegister(CollOperator &op);
63 :
64 : void LoadWithOffloadModeNoRegister(CollOperator &op);
65 :
66 : unique_ptr<PrimTranslator> primTranslator;
67 :
68 : // 创建rmaConnections
69 : unordered_map<std::string, unique_ptr<ConnectionsBuilder>> connectionsBuilders;
70 :
71 : std::set<LinkData> availableLinks;
72 :
73 : std::unique_ptr<UbCiUpdaterManager> ubCiUpdaterMgr;
74 :
75 : std::unique_ptr<MaskEvent> updatingUbCiEvent;
76 : };
77 : } // namespace Hccl
78 :
79 : #endif // HCCLV2_COLL_SERVICE_H
|