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 = 23; // 框内每个FE使用的Jetty个数
24 : // 优先分配框内FE,每个FE按最大数量分配,剩余Jetty分配个出框,每个die仅支持1个出框FE
25 : constexpr uint8_t INNER_MAX_TA_JETTY_ID_OFFSET =
26 : (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), startJettyCtxId(startJettyCtxId), startTaJettyId(startTaJettyId), size(size) {}
37 : };
38 :
39 : class CcuPfeCfgGenerator {
40 : public:
41 : CcuPfeCfgGenerator(const CcuPfeCfgGenerator &that) = delete;
42 :
43 : CcuPfeCfgGenerator &operator=(const CcuPfeCfgGenerator &that) = delete;
44 :
45 : static CcuPfeCfgGenerator &GetInstance(const int32_t deviceLogicId);
46 : std::vector<PfeJettyCtxCfg> GetPfeJettyCtxCfg(const uint8_t dieId);
47 :
48 : private:
49 : bool initFlag{false};
50 : int32_t devLogicId{0};
51 : std::array<std::vector<PfeJettyCtxCfg>, MAX_CCU_IODIE_NUM> pfeJettyCtxCfgs; // 每个iodie上PfeJettyCtxCfg的映射关系
52 :
53 66 : explicit CcuPfeCfgGenerator() = default;
54 66 : ~CcuPfeCfgGenerator() = default;
55 :
56 : void Init(const int32_t deviceLogicId);
57 : HcclResult SetPfeJettyCtxCfgMap(const int32_t logicDeviceId);
58 : };
59 :
60 : }; // Hccl
61 :
62 : #endif // CCU_PFE_CFG_GENERATOR_H
|