blob: c197932a13b030cb49c44b8d8c0fc8359b70f2e3 [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"
Georgios Pinitas08302c12021-06-09 10:08:27 +010028#include "src/common/cpuinfo/CpuInfo.h"
Giorgio Arena5ae8d802021-11-18 18:02:13 +000029#include "src/common/cpuinfo/CpuIsaInfo.h"
Pablo Tello7fad9b12018-03-14 17:55:27 +000030
Georgios Pinitas08302c12021-06-09 10:08:27 +010031namespace arm_compute
Pablo Tello7fad9b12018-03-14 17:55:27 +000032{
Georgios Pinitas08302c12021-06-09 10:08:27 +010033struct CPUInfo::Impl
34{
35 cpuinfo::CpuInfo info{};
36 unsigned int L1_cache_size = 32768;
37 unsigned int L2_cache_size = 262144;
38};
39
Michalis Spyrou20fca522021-06-07 14:23:57 +010040CPUInfo &CPUInfo::get()
41{
42 static CPUInfo _cpuinfo;
43 return _cpuinfo;
44}
45
Georgios Pinitas08302c12021-06-09 10:08:27 +010046CPUInfo::CPUInfo()
47 : _impl(std::make_unique<Impl>())
48{
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
Pablo Tello7fad9b12018-03-14 17:55:27 +0000104CPUModel CPUInfo::get_cpu_model() const
105{
Georgios Pinitas08302c12021-06-09 10:08:27 +0100106 return _impl->info.cpu_model();
Pablo Tello7fad9b12018-03-14 17:55:27 +0000107}
Georgios Pinitas08302c12021-06-09 10:08:27 +0100108
109CPUModel CPUInfo::get_cpu_model(unsigned int cpuid) const
110{
111 return _impl->info.cpu_model(cpuid);
112}
113
Giorgio Arena5ae8d802021-11-18 18:02:13 +0000114cpuinfo::CpuIsaInfo CPUInfo::get_isa() const
115{
116 return _impl->info.isa();
117}
118
Georgios Pinitas08302c12021-06-09 10:08:27 +0100119unsigned int CPUInfo::get_L1_cache_size() const
120{
121 return _impl->L1_cache_size;
122}
123
124unsigned int CPUInfo::get_L2_cache_size() const
125{
126 return _impl->L2_cache_size;
127}
128} // namespace arm_compute