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 PLATFORM_INFO_DEF_H
12 : #define PLATFORM_INFO_DEF_H
13 :
14 : #include <map>
15 : #include <string>
16 : #include <vector>
17 : #include <cstdint>
18 :
19 : using std::map;
20 : using std::string;
21 : using std::vector;
22 :
23 : namespace fe {
24 : enum MemoryType { DDR = 0, HBM };
25 :
26 : enum L2Type { Cache = 0, Buff };
27 :
28 : enum JitCompileMode { REUSE_BINARY = 0, COMPILE_ONLINE, AUTO };
29 :
30 : typedef struct tag_str_info {
31 : std::string aic_version;
32 : std::string ccec_aic_version;
33 : std::string ccec_aiv_version;
34 : std::string is_support_ai_cpu_compiler;
35 : std::string short_soc_version;
36 : } StrInfo;
37 :
38 : typedef struct tag_so_c_info {
39 : uint32_t ai_core_cnt;
40 : uint32_t vector_core_cnt;
41 : uint32_t ai_cpu_cnt;
42 : MemoryType memory_type;
43 : uint64_t memory_size;
44 : L2Type l2_type;
45 : uint64_t l2_size;
46 : uint32_t l2PageNum;
47 : uint32_t task_num;
48 : int32_t arch_type;
49 : int32_t chip_type;
50 124 : tag_so_c_info()
51 124 : : ai_core_cnt(0),
52 124 : vector_core_cnt(0),
53 124 : memory_size(0),
54 124 : l2_size(0),
55 124 : l2PageNum(0),
56 124 : task_num(0),
57 124 : arch_type(-1),
58 124 : chip_type(-1)
59 124 : {}
60 : } SoCInfo;
61 :
62 : typedef struct tag_ai_core_spec {
63 : double cube_freq;
64 : uint64_t cube_m_size;
65 : uint64_t cube_n_size;
66 : uint64_t cube_k_size;
67 : uint64_t vec_calc_size;
68 : uint64_t l0_a_size;
69 : uint64_t l0_b_size;
70 : uint64_t l0_c_size;
71 : uint64_t l1_size;
72 : uint64_t smask_buffer;
73 : uint64_t ub_size;
74 : uint64_t ubblock_size;
75 : uint64_t ubbank_size;
76 : uint64_t ubbank_num;
77 : uint64_t ubburst_in_one_block;
78 : uint64_t ubbank_group_num;
79 : uint32_t unzip_engines;
80 : uint32_t unzip_max_ratios;
81 : uint32_t unzip_channels;
82 : uint8_t unzip_is_tight;
83 : uint8_t cube_vector_split;
84 : uint8_t sparsity;
85 : } AiCoreSpec;
86 :
87 : typedef struct tag_ai_core_memory_rates {
88 : double ddr_rate;
89 : double ddr_read_rate;
90 : double ddr_write_rate;
91 : double l2_rate;
92 : double l2_read_rate;
93 : double l2_write_rate;
94 : double l1_to_l0_a_rate;
95 : double l1_to_l0_b_rate;
96 : double l1_to_ub_rate;
97 : double l0_c_to_ub_rate;
98 : double ub_to_l2_rate;
99 : double ub_to_ddr_rate;
100 : double ub_to_l1_rate;
101 : } AiCoreMemoryRates;
102 :
103 : typedef struct tag_vector_core_spec {
104 : double vec_freq;
105 : uint64_t vec_calc_size;
106 : uint64_t smask_buffer;
107 : uint64_t ub_size;
108 : uint64_t ubblock_size;
109 : uint64_t ubbank_size;
110 : uint64_t ubbank_num;
111 : uint64_t ubburst_in_one_block;
112 : uint64_t ubbank_group_num;
113 : uint64_t vector_reg_size;
114 : uint64_t predicate_reg_size;
115 : uint64_t address_reg_size;
116 : uint64_t alignment_reg_size;
117 : } VectorCoreSpec;
118 :
119 : typedef struct tag_vector_core_memory_rates {
120 : double ddr_rate;
121 : double ddr_read_rate;
122 : double ddr_write_rate;
123 : double l2_rate;
124 : double l2_read_rate;
125 : double l2_write_rate;
126 : double ub_to_l2_rate;
127 : double ub_to_ddr_rate;
128 : } VectorCoreMemoryRates;
129 :
130 : typedef struct tag_cpu_cache {
131 : uint32_t AICPUSyncBySW;
132 : uint32_t TSCPUSyncBySW;
133 : } CPUCache;
134 :
135 : typedef struct tag_software_spec {
136 : bool jit_compile_default_value;
137 : JitCompileMode jit_compile_mode;
138 124 : tag_software_spec()
139 124 : {
140 124 : jit_compile_default_value = false;
141 124 : jit_compile_mode = AUTO;
142 124 : }
143 : } SoftwareSpec;
144 :
145 : typedef struct tag_platform_info {
146 : StrInfo str_info;
147 : SoCInfo soc_info;
148 : AiCoreSpec ai_core_spec;
149 : AiCoreMemoryRates ai_core_memory_rates;
150 : std::map<std::string, std::vector<std::string>> ai_core_intrinsic_dtype_map;
151 : VectorCoreSpec vector_core_spec;
152 : VectorCoreMemoryRates vector_core_memory_rates;
153 : CPUCache cpucache;
154 : std::map<std::string, std::vector<std::string>> vector_core_intrinsic_dtype_map;
155 : SoftwareSpec software_spec;
156 : } PlatformInfo;
157 :
158 : typedef struct tag_optional_info {
159 : std::string soc_version;
160 : std::string core_type;
161 : uint32_t ai_core_num;
162 : std::string l1_fusion_flag;
163 : } OptionalInfo;
164 : } // namespace fe
165 : #endif
|