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_JETTY_CTX_MGR_V1_H
12 : #define CCU_JETTY_CTX_MGR_V1_H
13 :
14 : #include <memory>
15 : #include <vector>
16 : #include <unordered_map>
17 :
18 : #include "ccu_jetty_ctx_mgr.h"
19 : #include "ccu_res_allocator.h"
20 : #include "ccu_wqebb_mgr_v1.h"
21 :
22 : namespace hcomm {
23 :
24 : class CcuJettyCtxMgrV1 : public CcuJettyCtxMgr {
25 : public:
26 142 : CcuJettyCtxMgrV1(const int32_t devLogicId, const uint8_t dieId, const uint32_t devPhyId)
27 142 : : CcuJettyCtxMgr(devLogicId, dieId, devPhyId) {};
28 :
29 : CcuJettyCtxMgrV1() = default;
30 142 : ~CcuJettyCtxMgrV1() override final = default;
31 :
32 : HcclResult Init() override final;
33 :
34 : HcclResult Alloc(const uint32_t feId, const uint32_t jettyNum, const uint32_t sqSize,
35 : std::vector<JettyInfo>& jettyInfos) override final;
36 : HcclResult Config(const uint32_t feId, const std::vector<JettyInfo> &jettyInfos,
37 : const std::vector<JettyCfg>& jettyCfgs) override final;
38 : HcclResult Release(const uint32_t feId, const std::vector<JettyInfo> &jettyInfos) override final;
39 :
40 : private:
41 : struct JettyAllocator {
42 : PfeJettyStrategy strategy{};
43 : std::unique_ptr<CcuResIdAllocator> idAllocator{nullptr};
44 :
45 142 : explicit JettyAllocator(PfeJettyStrategy pfeJettyStrategy): strategy(pfeJettyStrategy)
46 : {
47 : // 外部对空指针进行校验
48 142 : idAllocator.reset(new (std::nothrow) CcuResIdAllocator(strategy.size));
49 142 : }
50 : };
51 :
52 : HcclResult GetJettyAllocator(uint32_t feId, JettyAllocator* &allocatorHandle);
53 :
54 : private:
55 : std::unique_ptr<JettyAllocator> allocator_; // 所有FE的Jetty统一打平分配
56 : };
57 :
58 : }; // namespace hcomm
59 :
60 : #endif
|