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