Compute Library
 23.05
CPPTypes.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2022 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  */
24 
26 
27 #include "arm_compute/core/Error.h"
30 
31 namespace arm_compute
32 {
33 struct CPUInfo::Impl
34 {
35  cpuinfo::CpuInfo info{};
36  unsigned int L1_cache_size = 32768;
37  unsigned int L2_cache_size = 262144;
38 };
39 
41 {
42  static CPUInfo _cpuinfo;
43  return _cpuinfo;
44 }
45 
46 CPUInfo::CPUInfo()
47  : _impl(std::make_unique<Impl>())
48 {
49  _impl->info = cpuinfo::CpuInfo::build();
50 }
51 
52 CPUInfo::~CPUInfo() = default;
53 
54 unsigned int CPUInfo::get_cpu_num() const
55 {
56  return _impl->info.num_cpus();
57 }
58 
59 bool CPUInfo::has_fp16() const
60 {
61  return _impl->info.has_fp16();
62 }
63 
64 bool CPUInfo::has_bf16() const
65 {
66  return _impl->info.has_bf16();
67 }
68 
70 {
71  return _impl->info.has_svebf16();
72 }
73 
75 {
76  return _impl->info.has_dotprod();
77 }
78 
80 {
81  return _impl->info.has_svef32mm();
82 }
83 
84 bool CPUInfo::has_i8mm() const
85 {
86  return _impl->info.has_i8mm();
87 }
88 
90 {
91  return _impl->info.has_svei8mm();
92 }
93 
94 bool CPUInfo::has_sve() const
95 {
96  return _impl->info.has_sve();
97 }
98 
99 bool CPUInfo::has_sve2() const
100 {
101  return _impl->info.has_sve2();
102 }
103 
104 bool CPUInfo::has_sme() const
105 {
106  return _impl->info.has_sme();
107 }
108 
109 bool CPUInfo::has_sme2() const
110 {
111  return _impl->info.has_sme2();
112 }
113 
115 {
116  return _impl->info.cpu_model();
117 }
118 
119 CPUModel CPUInfo::get_cpu_model(unsigned int cpuid) const
120 {
121  return _impl->info.cpu_model(cpuid);
122 }
123 
125 {
126  return _impl->info.isa();
127 }
128 
129 unsigned int CPUInfo::get_L1_cache_size() const
130 {
131  return _impl->L1_cache_size;
132 }
133 
134 unsigned int CPUInfo::get_L2_cache_size() const
135 {
136  return _impl->L2_cache_size;
137 }
138 } // namespace arm_compute
bool has_sve() const
Checks if the cpu model supports sve.
Definition: CPPTypes.cpp:94
static CpuInfo build()
CpuInfo builder function from system related information.
Definition: CpuInfo.cpp:303
bool has_bf16() const
Checks if the cpu model supports bf16.
Definition: CPPTypes.cpp:64
bool has_sme() const
Checks if the cpu model supports sme.
Definition: CPPTypes.cpp:104
bool has_svei8mm() const
Checks if the cpu model supports integer matrix multiplication.
Definition: CPPTypes.cpp:89
bool has_svef32mm() const
Checks if the cpu model supports floating-point matrix multiplication.
Definition: CPPTypes.cpp:79
bool has_fp16() const
Checks if the cpu model supports fp16.
Definition: CPPTypes.cpp:59
CPUModel
CPU models types.
Definition: CPPTypes.h:59
Copyright (c) 2017-2023 Arm Limited.
CPU ISA (Instruction Set Architecture) information.
Definition: CpuIsaInfo.h:37
bool has_sve2() const
Checks if the cpu model supports sve2.
Definition: CPPTypes.cpp:99
bool has_sme2() const
Checks if the cpu model supports sme2.
Definition: CPPTypes.cpp:109
bool has_dotprod() const
Checks if the cpu model supports dot product.
Definition: CPPTypes.cpp:74
unsigned int get_cpu_num() const
Return the maximum number of CPUs present.
Definition: CPPTypes.cpp:54
unsigned int get_L1_cache_size() const
Gets the L1 cache size.
Definition: CPPTypes.cpp:129
unsigned int get_L2_cache_size() const
Gets the L2 cache size.
Definition: CPPTypes.cpp:134
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
CPUModel get_cpu_model() const
Gets the current thread&#39;s cpu model.
Definition: CPPTypes.cpp:114
static CPUInfo & get()
Access the KernelLibrary singleton.
Definition: CPPTypes.cpp:40
bool has_svebf16() const
Checks if the cpu model supports bf16.
Definition: CPPTypes.cpp:69
bool has_i8mm() const
Checks if the cpu model supports integer matrix multiplication.
Definition: CPPTypes.cpp:84
cpuinfo::CpuIsaInfo get_isa() const
Gets the current cpu&#39;s ISA information.
Definition: CPPTypes.cpp:124