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_RES_REPO_H
12 : #define CCU_RES_REPO_H
13 :
14 : #include <array>
15 : #include <string>
16 : #include <sstream>
17 : #include <vector>
18 :
19 : #include "ccu_common.h"
20 :
21 : namespace hcomm {
22 :
23 : /*
24 : * MissionReqType 申请Mission资源的策略类型,当前只按FUSION_MULTIPLE_DIE处理
25 : * FUSION_MULTIPLE_DIE missionid连续,跨die的missionid相同
26 : * FUSION_ONE_DIE missionid连续,单die
27 : * NO_FUSION_ONE_DIE missionid不要求连续,单die
28 : */
29 : enum class MissionReqType {
30 : COMM_ENGINE_RESERVED = -1,
31 : FUSION_MULTIPLE_DIE = 0,
32 : FUSION_ONE_DIE = 1,
33 : NO_FUSION_ONE_DIE = 2,
34 : };
35 :
36 : class ResInfo {
37 : public:
38 92 : ResInfo() : startId(0), num(0) {};
39 106904 : ResInfo(uint32_t startId, uint32_t num) : startId(startId), num(num) {};
40 : uint32_t startId{0};
41 : uint32_t num{0};
42 :
43 19 : std::string Describe() const
44 : {
45 19 : std::ostringstream oss;
46 19 : oss << "ResInfo[startId=" << startId << ", num=" << num << "]";
47 38 : return oss.str();
48 19 : };
49 : };
50 :
51 : struct MissionResInfo {
52 : MissionReqType reqType;
53 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> mission;
54 : };
55 :
56 : struct CcuResRepository {
57 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> loopEngine{};
58 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> blockLoopEngine{};
59 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> ms{};
60 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> blockMs{};
61 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> cke{};
62 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> blockCke{};
63 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> xn{};
64 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> blockXn{};
65 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> gsa{};
66 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> blockGsa{};
67 : MissionResInfo mission{};
68 : };
69 :
70 : struct MissionReq {
71 : MissionReqType reqType{MissionReqType::FUSION_MULTIPLE_DIE};
72 : std::array<uint32_t, CCU_MAX_IODIE_NUM> req{};
73 : };
74 :
75 : struct CcuResReq {
76 : std::array<uint32_t, CCU_MAX_IODIE_NUM> loopEngineReq{};
77 : std::array<uint32_t, CCU_MAX_IODIE_NUM> blockLoopEngineReq{};
78 : std::array<uint32_t, CCU_MAX_IODIE_NUM> msReq{};
79 : std::array<uint32_t, CCU_MAX_IODIE_NUM> blockMsReq{};
80 : std::array<uint32_t, CCU_MAX_IODIE_NUM> ckeReq{};
81 : std::array<uint32_t, CCU_MAX_IODIE_NUM> blockCkeReq{};
82 : std::array<uint32_t, CCU_MAX_IODIE_NUM> xnReq{};
83 : std::array<uint32_t, CCU_MAX_IODIE_NUM> blockXnReq{};
84 : std::array<uint32_t, CCU_MAX_IODIE_NUM> gsaReq{};
85 : std::array<uint32_t, CCU_MAX_IODIE_NUM> blockGsaReq{};
86 : MissionReq missionReq{};
87 : };
88 :
89 : } // namespace hcomm
90 : #endif // CCU_RES_REPO_H
|