blob: 9980db42f353240f5f6698a18ed9ae8be3ac0100 [file] [log] [blame]
Pablo Tello7fad9b12018-03-14 17:55:27 +00001/*
Giorgio Arena5ae8d802021-11-18 18:02:13 +00002 * Copyright (c) 2018-2022 Arm Limited.
Pablo Tello7fad9b12018-03-14 17:55:27 +00003 *
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
25#include "arm_compute/core/CPP/CPPTypes.h"
26
27#include "arm_compute/core/Error.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010028
Georgios Pinitas08302c12021-06-09 10:08:27 +010029#include "src/common/cpuinfo/CpuInfo.h"
Giorgio Arena5ae8d802021-11-18 18:02:13 +000030#include "src/common/cpuinfo/CpuIsaInfo.h"
Pablo Tello7fad9b12018-03-14 17:55:27 +000031
Georgios Pinitas08302c12021-06-09 10:08:27 +010032namespace arm_compute
Pablo Tello7fad9b12018-03-14 17:55:27 +000033{
Georgios Pinitas08302c12021-06-09 10:08:27 +010034struct CPUInfo::Impl
35{
36 cpuinfo::CpuInfo info{};
37 unsigned int L1_cache_size = 32768;
38 unsigned int L2_cache_size = 262144;
39};
40
Michalis Spyrou20fca522021-06-07 14:23:57 +010041CPUInfo &CPUInfo::get()
42{
43 static CPUInfo _cpuinfo;
44 return _cpuinfo;
45}
46
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010047CPUInfo::CPUInfo() : _impl(std::make_unique<Impl>())
Georgios Pinitas08302c12021-06-09 10:08:27 +010048{
49 _impl->info = cpuinfo::CpuInfo::build();
Pablo Tello7fad9b12018-03-14 17:55:27 +000050}
51
Georgios Pinitas08302c12021-06-09 10:08:27 +010052CPUInfo::~CPUInfo() = default;
Pablo Tello7fad9b12018-03-14 17:55:27 +000053
Anthony Barbier8914e322018-08-10 15:28:25 +010054unsigned int CPUInfo::get_cpu_num() const
55{
Georgios Pinitas08302c12021-06-09 10:08:27 +010056 return _impl->info.num_cpus();
Anthony Barbier8914e322018-08-10 15:28:25 +010057}
Pablo Marquez Telloa50f1932021-03-08 17:27:05 +000058
Pablo Tello7fad9b12018-03-14 17:55:27 +000059bool CPUInfo::has_fp16() const
60{
Georgios Pinitas08302c12021-06-09 10:08:27 +010061 return _impl->info.has_fp16();
62}
63
64bool CPUInfo::has_bf16() const
65{
66 return _impl->info.has_bf16();
Pablo Tello7fad9b12018-03-14 17:55:27 +000067}
68
Michalis Spyrou20fca522021-06-07 14:23:57 +010069bool CPUInfo::has_svebf16() const
70{
71 return _impl->info.has_svebf16();
72}
73
Pablo Tello7fad9b12018-03-14 17:55:27 +000074bool CPUInfo::has_dotprod() const
75{
Georgios Pinitas08302c12021-06-09 10:08:27 +010076 return _impl->info.has_dotprod();
Pablo Tello7fad9b12018-03-14 17:55:27 +000077}
78
Michalis Spyrou20fca522021-06-07 14:23:57 +010079bool CPUInfo::has_svef32mm() const
80{
81 return _impl->info.has_svef32mm();
82}
83
84bool CPUInfo::has_i8mm() const
85{
86 return _impl->info.has_i8mm();
87}
88
89bool CPUInfo::has_svei8mm() const
90{
91 return _impl->info.has_svei8mm();
92}
93
94bool CPUInfo::has_sve() const
95{
96 return _impl->info.has_sve();
97}
98
99bool CPUInfo::has_sve2() const
100{
101 return _impl->info.has_sve2();
102}
103
ramelg01a1f78512022-06-29 16:28:10 +0100104bool CPUInfo::has_sme() const
105{
Viet-Hoa Do03b29712022-06-01 11:47:14 +0100106 return _impl->info.has_sme();
ramelg01a1f78512022-06-29 16:28:10 +0100107}
108
109bool CPUInfo::has_sme2() const
110{
Viet-Hoa Do03b29712022-06-01 11:47:14 +0100111 return _impl->info.has_sme2();
ramelg01a1f78512022-06-29 16:28:10 +0100112}
113
Pablo Tello7fad9b12018-03-14 17:55:27 +0000114CPUModel CPUInfo::get_cpu_model() const
115{
Georgios Pinitas08302c12021-06-09 10:08:27 +0100116 return _impl->info.cpu_model();
Pablo Tello7fad9b12018-03-14 17:55:27 +0000117}
Georgios Pinitas08302c12021-06-09 10:08:27 +0100118
119CPUModel CPUInfo::get_cpu_model(unsigned int cpuid) const
120{
121 return _impl->info.cpu_model(cpuid);
122}
123
Giorgio Arena5ae8d802021-11-18 18:02:13 +0000124cpuinfo::CpuIsaInfo CPUInfo::get_isa() const
125{
126 return _impl->info.isa();
127}
128
Georgios Pinitas08302c12021-06-09 10:08:27 +0100129unsigned int CPUInfo::get_L1_cache_size() const
130{
131 return _impl->L1_cache_size;
132}
133
134unsigned int CPUInfo::get_L2_cache_size() const
135{
136 return _impl->L2_cache_size;
137}
138} // namespace arm_compute