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 HCCL_CCU_JETTY_CTX_MGR_V1_H
12 : #define HCCL_CCU_JETTY_CTX_MGR_V1_H
13 :
14 : #include <memory>
15 : #include <vector>
16 : #include <unordered_map>
17 :
18 : #include "ccu_jetty_ctx_mgr_legacy.h"
19 : #include "ccu_res_allocator_legacy.h"
20 :
21 : namespace Hccl {
22 :
23 : class CcuJettyCtxMgrV1 : public CcuJettyCtxMgr {
24 : public:
25 : CcuJettyCtxMgrV1(const int32_t devLogicId, const uint8_t dieId, const uint32_t devPhyId);
26 :
27 : CcuJettyCtxMgrV1() = default;
28 24 : ~CcuJettyCtxMgrV1() override = default;
29 :
30 : HcclResult Alloc(
31 : const uint32_t feId, const uint32_t jettyNum, const uint32_t sqSize,
32 : std::vector<JettyInfo>& jettyInfos) override;
33 : HcclResult Config(
34 : const uint32_t feId, const std::vector<JettyInfo>& jettyInfos, const std::vector<JettyCfg>& jettyCfgs) override;
35 : HcclResult Release(const uint32_t feId, const std::vector<JettyInfo>& jettyInfos) override;
36 :
37 : private:
38 : struct JettyAllocator {
39 : PfeJettyStrategy strategy;
40 : std::unique_ptr<CcuResIdAllocator> idAllocator;
41 :
42 24 : explicit JettyAllocator(PfeJettyStrategy pfeJettyStrategy) : strategy(pfeJettyStrategy)
43 : {
44 24 : idAllocator = std::make_unique<CcuResIdAllocator>(strategy.size);
45 24 : }
46 : };
47 :
48 : std::unique_ptr<JettyAllocator> allocator_;
49 : HcclResult GetJettyAllocator(uint32_t feId, JettyAllocator*& allocatorHandle);
50 : };
51 :
52 : }; // namespace Hccl
53 :
54 : #endif
|