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.h"
19 : #include "ccu_res_allocator.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(const uint32_t feId, const uint32_t jettyNum, const uint32_t sqSize,
31 : std::vector<JettyInfo>& jettyInfos) override;
32 : HcclResult Config(const uint32_t feId, const std::vector<JettyInfo> &jettyInfos,
33 : const std::vector<JettyCfg>& jettyCfgs) override;
34 : HcclResult Release(const uint32_t feId, const std::vector<JettyInfo> &jettyInfos) override;
35 :
36 : private:
37 : struct JettyAllocator {
38 : PfeJettyStrategy strategy;
39 : std::unique_ptr<CcuResIdAllocator> idAllocator;
40 :
41 24 : explicit JettyAllocator(PfeJettyStrategy pfeJettyStrategy): strategy(pfeJettyStrategy)
42 : {
43 24 : idAllocator = std::make_unique<CcuResIdAllocator>(strategy.size);
44 24 : }
45 : };
46 :
47 : std::unique_ptr<JettyAllocator> allocator_;
48 : HcclResult GetJettyAllocator(uint32_t feId, JettyAllocator* &allocatorHandle);
49 : };
50 :
51 : }; // namespace Hccl
52 :
53 : #endif
|