Compute Library
 22.08
CpuModel.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 Arm Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
25 
26 namespace arm_compute
27 {
28 namespace cpuinfo
29 {
30 std::string cpu_model_to_string(CpuModel model)
31 {
32  switch(model)
33  {
34 #define X(MODEL) \
35 case CpuModel::MODEL: \
36  return #MODEL;
38 #undef X
39  default:
40  {
41  return std::string("GENERIC");
42  }
43  };
44 }
45 
47 {
48  switch(model)
49  {
52  case CpuModel::A55r1:
53  case CpuModel::A510:
54  case CpuModel::X1:
55  case CpuModel::V1:
56  case CpuModel::A64FX:
57  return true;
58  default:
59  return false;
60  }
61 }
62 
64 {
65  switch(model)
66  {
68  case CpuModel::A55r1:
69  case CpuModel::A510:
70  case CpuModel::X1:
71  case CpuModel::V1:
72  return true;
73  default:
74  return false;
75  }
76 }
77 
78 CpuModel midr_to_model(uint32_t midr)
79 {
81 
82  // Unpack variant and CPU ID
83  const int implementer = (midr >> 24) & 0xFF;
84  const int variant = (midr >> 20) & 0xF;
85  const int cpunum = (midr >> 4) & 0xFFF;
86 
87  // Only CPUs we have code paths for are detected. All other CPUs can be safely classed as "GENERIC"
88  if(implementer == 0x41) // Arm CPUs
89  {
90  switch(cpunum)
91  {
92  case 0xd03: // A53
93  case 0xd04: // A35
94  model = CpuModel::A53;
95  break;
96  case 0xd05: // A55
97  if(variant != 0)
98  {
99  model = CpuModel::A55r1;
100  }
101  else
102  {
103  model = CpuModel::A55r0;
104  }
105  break;
106  case 0xd09: // A73
107  model = CpuModel::A73;
108  break;
109  case 0xd0a: // A75
110  if(variant != 0)
111  {
113  }
114  else
115  {
116  model = CpuModel::GENERIC_FP16;
117  }
118  break;
119  case 0xd06: // A65
120  case 0xd0b: // A76
121  case 0xd0c: // N1
122  case 0xd0d: // A77
123  case 0xd0e: // A76AE
124  case 0xd41: // A78
125  case 0xd42: // A78AE
126  case 0xd4a: // E1
128  break;
129  case 0xd40: // V1
130  model = CpuModel::V1;
131  break;
132  case 0xd44: // X1
133  model = CpuModel::X1;
134  break;
135  case 0xd46:
136  model = CpuModel::A510;
137  break;
138  default:
139  model = CpuModel::GENERIC;
140  break;
141  }
142  }
143  else if(implementer == 0x46)
144  {
145  switch(cpunum)
146  {
147  case 0x001: // A64FX
148  model = CpuModel::A64FX;
149  break;
150  default:
151  model = CpuModel::GENERIC;
152  break;
153  }
154  }
155  else if(implementer == 0x48)
156  {
157  switch(cpunum)
158  {
159  case 0xd40: // A76
161  break;
162  default:
163  model = CpuModel::GENERIC;
164  break;
165  }
166  }
167  else if(implementer == 0x51)
168  {
169  switch(cpunum)
170  {
171  case 0x800: // A73
172  model = CpuModel::A73;
173  break;
174  case 0x801: // A53
175  model = CpuModel::A53;
176  break;
177  case 0x803: // A55r0
178  model = CpuModel::A55r0;
179  break;
180  case 0x804: // A76
182  break;
183  case 0x805: // A55r1
184  model = CpuModel::A55r1;
185  break;
186  default:
187  model = CpuModel::GENERIC;
188  break;
189  }
190  }
191 
192  return model;
193 }
194 } // namespace cpuinfo
195 } // namespace arm_compute
CPUModel
CPU models types.
Definition: CPPTypes.h:58
Copyright (c) 2017-2022 Arm Limited.
bool model_supports_fp16(CpuModel model)
Check if a model supports half-precision floating point arithmetic.
Definition: CpuModel.cpp:46
bool model_supports_dot(CpuModel model)
Check if a model supports dot product.
Definition: CpuModel.cpp:63
std::string cpu_model_to_string(CpuModel model)
Convert a CPU model value to a string.
Definition: CpuModel.cpp:30
#define ARM_COMPUTE_CPU_MODEL_LIST
Definition: CPPTypes.h:38
CpuModel midr_to_model(uint32_t midr)
Extract the model type from the MIDR value.
Definition: CpuModel.cpp:78