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_ALG_COMPONENT_LITE
12 : #define HCCLV2_COLL_ALG_COMPONENT_LITE
13 :
14 : #include <string>
15 : #include "dev_type.h"
16 : #include "connected_link_mgr.h"
17 : #include "base_config.h"
18 : #include "coll_alg_params.h"
19 : #include "coll_operator.h"
20 : #include "prim_queue.h"
21 : #include "coll_alg_component.h"
22 : #include "rmt_data_buffer_mgr.h"
23 :
24 : namespace Hccl {
25 :
26 : using PrimQuePtr = std::shared_ptr<PrimQueue>;
27 :
28 : class CollAlgComponentLite {
29 : public:
30 0 : CollAlgComponentLite(
31 : RankId myRank, u32 rankSize, DevType devType, u64 scratchBufferSize, ConnectedLinkMgr* linkMgr,
32 : RmtDataBufferMgr* rmaDataBufferMgr)
33 0 : : myRank_(myRank),
34 0 : rankSize_(rankSize),
35 0 : devType_(devType),
36 0 : scratchBufferSize_(scratchBufferSize),
37 0 : linkMgr_(linkMgr),
38 0 : rmaDataBufferMgr_(rmaDataBufferMgr)
39 0 : {}
40 0 : virtual ~CollAlgComponentLite() = default;
41 :
42 : void EnableDetour(bool enableDetour);
43 : void EnableDataAllign(bool enableAllign);
44 : void SetAllignSize(u64 allignSize);
45 : void SetDmaMode(const DmaMode dmaMode);
46 : void UpdateScratchBufferSize(u64 bufferSize);
47 :
48 : HcclResult ParsePackedData(std::vector<char> packedData);
49 :
50 : virtual HcclResult Orchestrate(
51 : const CollAlgOperator& op, const std::string& algName, const AlgTopoInfo& algTopoInfo, PrimQuePtr queue);
52 : virtual HcclResult
53 : Orchestrate(const CollAlgOperator& op, const std::string& algName, const AlgTopoInfo& algTopoInfo, InsQuePtr queue);
54 :
55 : protected:
56 : u32 myRank_ = INVALID_RANKID;
57 : u32 rankSize_ = 0;
58 : DevType devType_ = DevType::DEV_TYPE_NOSOC;
59 : u64 scratchBufferSize_ = 0;
60 : ConnectedLinkMgr* linkMgr_ = nullptr;
61 : RmtDataBufferMgr* rmaDataBufferMgr_{nullptr};
62 :
63 : bool enableDetour_ = false;
64 : bool enableAllign_ = false;
65 : u64 allignSize_ = 0;
66 :
67 : DmaMode dmaMode_ = DmaMode::DEFAULT;
68 : };
69 :
70 : using CollAlgComponentLitePtr = std::shared_ptr<CollAlgComponentLite>;
71 : } // namespace Hccl
72 : #endif
|