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(RankId myRank, u32 rankSize, DevType devType, u64 scratchBufferSize, ConnectedLinkMgr *linkMgr,
31 0 : RmtDataBufferMgr *rmaDataBufferMgr) : myRank_(myRank), rankSize_(rankSize), devType_(devType),
32 0 : scratchBufferSize_(scratchBufferSize), linkMgr_(linkMgr), rmaDataBufferMgr_(rmaDataBufferMgr)
33 : {
34 0 : }
35 0 : virtual ~CollAlgComponentLite() = default;
36 :
37 : void EnableDetour(bool enableDetour);
38 : void EnableDataAllign(bool enableAllign);
39 : void SetAllignSize(u64 allignSize);
40 : void SetDmaMode(const DmaMode dmaMode);
41 : void UpdateScratchBufferSize(u64 bufferSize);
42 :
43 : HcclResult ParsePackedData(std::vector<char> packedData);
44 :
45 : virtual HcclResult Orchestrate(const CollAlgOperator &op, const std::string &algName,
46 : const AlgTopoInfo &algTopoInfo, PrimQuePtr queue);
47 : virtual HcclResult Orchestrate(const CollAlgOperator &op, const std::string &algName,
48 : const AlgTopoInfo &algTopoInfo, InsQuePtr queue);
49 :
50 : protected:
51 : u32 myRank_ = INVALID_RANKID;
52 : u32 rankSize_ = 0;
53 : DevType devType_ = DevType::DEV_TYPE_NOSOC;
54 : u64 scratchBufferSize_ = 0;
55 : ConnectedLinkMgr *linkMgr_ = nullptr;
56 : RmtDataBufferMgr *rmaDataBufferMgr_{ nullptr };
57 :
58 : bool enableDetour_ = false;
59 : bool enableAllign_ = false;
60 : u64 allignSize_ = 0;
61 :
62 : DmaMode dmaMode_ = DmaMode::DEFAULT;
63 : };
64 :
65 : using CollAlgComponentLitePtr = std::shared_ptr<CollAlgComponentLite>;
66 : } // namespace Hccl
67 : #endif
|