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 CCU_PFE_CFG_GENERATOR_H
12 : #define CCU_PFE_CFG_GENERATOR_H
13 :
14 : #include <array>
15 : #include <vector>
16 : #include "hccl/hccl_types.h"
17 : #include "ccu_device_manager.h"
18 :
19 : namespace Hccl {
20 :
21 : constexpr uint8_t MAX_CCU_INNER_FE_IDX = 7; // 框内最大FE Index
22 : constexpr uint8_t INNER_MAX_CCU_PFE_NUM = 6; // 2D fullmesh组网框内x/y轴最大FE个数
23 : constexpr uint8_t ONE_CCU_PFE_USE_JETTY_NUM
24 : = 23; // 框内每个FE使用的Jetty个数
25 : // 优先分配框内FE,每个FE按最大数量分配,剩余Jetty分配个出框,每个die仅支持1个出框FE
26 : constexpr uint8_t INNER_MAX_TA_JETTY_ID_OFFSET = (INNER_MAX_CCU_PFE_NUM - 2) * ONE_CCU_PFE_USE_JETTY_NUM;
27 :
28 : struct PfeJettyCtxCfg {
29 : uint32_t feId{0};
30 : uint32_t startJettyCtxId{0};
31 : uint32_t startTaJettyId{0};
32 : uint8_t size{0};
33 :
34 : PfeJettyCtxCfg() = default;
35 5 : PfeJettyCtxCfg(uint32_t feId, uint32_t startJettyCtxId, uint32_t startTaJettyId, uint8_t size)
36 5 : : feId(feId),
37 5 : startJettyCtxId(startJettyCtxId),
38 5 : startTaJettyId(startTaJettyId),
39 5 : size(size)
40 5 : {}
41 : };
42 :
43 : class CcuPfeCfgGenerator {
44 : public:
45 : CcuPfeCfgGenerator(const CcuPfeCfgGenerator& that) = delete;
46 :
47 : CcuPfeCfgGenerator& operator=(const CcuPfeCfgGenerator& that) = delete;
48 :
49 : static CcuPfeCfgGenerator& GetInstance(const int32_t deviceLogicId);
50 : std::vector<PfeJettyCtxCfg> GetPfeJettyCtxCfg(const uint8_t dieId);
51 :
52 : private:
53 : bool initFlag{false};
54 : int32_t devLogicId{0};
55 : std::array<std::vector<PfeJettyCtxCfg>, MAX_CCU_IODIE_NUM> pfeJettyCtxCfgs; // 每个iodie上PfeJettyCtxCfg的映射关系
56 :
57 66 : explicit CcuPfeCfgGenerator() = default;
58 66 : ~CcuPfeCfgGenerator() = default;
59 :
60 : void Init(const int32_t deviceLogicId);
61 : HcclResult SetPfeJettyCtxCfgMap(const int32_t logicDeviceId);
62 : };
63 :
64 : }; // namespace Hccl
65 :
66 : #endif // CCU_PFE_CFG_GENERATOR_H
|