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 74 : ResInfo(): startId(0), num(0){};
39 45173 : 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 19 : std::ostringstream oss;
45 19 : oss << "ResInfo[startId=" << startId << ", num=" << num << "]";
46 38 : return oss.str();
47 19 : };
48 : };
49 :
50 : struct MissionResInfo {
51 : MissionReqType reqType;
52 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> mission;
53 : };
54 :
55 : struct CcuResRepository {
56 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> loopEngine{};
57 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> blockLoopEngine{};
58 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> ms{};
59 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> blockMs{};
60 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> cke{};
61 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> blockCke{};
62 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> continuousXn{};
63 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> xn{};
64 : std::array<std::vector<ResInfo>, CCU_MAX_IODIE_NUM> gsa{};
65 : MissionResInfo mission{};
66 : };
67 :
68 : struct MissionReq {
69 : MissionReqType reqType{MissionReqType::FUSION_MULTIPLE_DIE};
70 : std::array<uint32_t, CCU_MAX_IODIE_NUM> req{};
71 : };
72 :
73 : struct CcuResReq {
74 : std::array<uint32_t, CCU_MAX_IODIE_NUM> loopEngineReq{};
75 : std::array<uint32_t, CCU_MAX_IODIE_NUM> blockLoopEngineReq{};
76 : std::array<uint32_t, CCU_MAX_IODIE_NUM> msReq{};
77 : std::array<uint32_t, CCU_MAX_IODIE_NUM> blockMsReq{};
78 : std::array<uint32_t, CCU_MAX_IODIE_NUM> ckeReq{};
79 : std::array<uint32_t, CCU_MAX_IODIE_NUM> blockCkeReq{};
80 : std::array<uint32_t, CCU_MAX_IODIE_NUM> continuousXnReq{};
81 : std::array<uint32_t, CCU_MAX_IODIE_NUM> xnReq{};
82 : std::array<uint32_t, CCU_MAX_IODIE_NUM> gsaReq{};
83 : MissionReq missionReq{};
84 : };
85 :
86 : } // namespace hcomm
87 : #endif // CCU_RES_REPO_H
|