blob: edcb9cb1ba85b79a32bd885f842da2a20e18971b [file] [log] [blame]
Pablo Tello7fad9b12018-03-14 17:55:27 +00001/*
Georgios Pinitas45514032020-12-30 00:03:09 +00002 * Copyright (c) 2018-2021 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"
Pablo Tello7fad9b12018-03-14 17:55:27 +000029
Georgios Pinitas08302c12021-06-09 10:08:27 +010030namespace arm_compute
Pablo Tello7fad9b12018-03-14 17:55:27 +000031{
Georgios Pinitas08302c12021-06-09 10:08:27 +010032struct CPUInfo::Impl
33{
34 cpuinfo::CpuInfo info{};
35 unsigned int L1_cache_size = 32768;
36 unsigned int L2_cache_size = 262144;
37};
38
39CPUInfo::CPUInfo()
40 : _impl(std::make_unique<Impl>())
41{
42 _impl->info = cpuinfo::CpuInfo::build();
Pablo Tello7fad9b12018-03-14 17:55:27 +000043}
44
Georgios Pinitas08302c12021-06-09 10:08:27 +010045CPUInfo::~CPUInfo() = default;
Pablo Tello7fad9b12018-03-14 17:55:27 +000046
Anthony Barbier8914e322018-08-10 15:28:25 +010047unsigned int CPUInfo::get_cpu_num() const
48{
Georgios Pinitas08302c12021-06-09 10:08:27 +010049 return _impl->info.num_cpus();
Anthony Barbier8914e322018-08-10 15:28:25 +010050}
Pablo Marquez Telloa50f1932021-03-08 17:27:05 +000051
52bool CPUInfo::has_sve() const
53{
Georgios Pinitas08302c12021-06-09 10:08:27 +010054 return _impl->info.has_sve();
Pablo Marquez Telloa50f1932021-03-08 17:27:05 +000055}
56
Pablo Tello7fad9b12018-03-14 17:55:27 +000057bool CPUInfo::has_fp16() const
58{
Georgios Pinitas08302c12021-06-09 10:08:27 +010059 return _impl->info.has_fp16();
60}
61
62bool CPUInfo::has_bf16() const
63{
64 return _impl->info.has_bf16();
Pablo Tello7fad9b12018-03-14 17:55:27 +000065}
66
67bool CPUInfo::has_dotprod() const
68{
Georgios Pinitas08302c12021-06-09 10:08:27 +010069 return _impl->info.has_dotprod();
Pablo Tello7fad9b12018-03-14 17:55:27 +000070}
71
72CPUModel CPUInfo::get_cpu_model() const
73{
Georgios Pinitas08302c12021-06-09 10:08:27 +010074 return _impl->info.cpu_model();
Pablo Tello7fad9b12018-03-14 17:55:27 +000075}
Georgios Pinitas08302c12021-06-09 10:08:27 +010076
77CPUModel CPUInfo::get_cpu_model(unsigned int cpuid) const
78{
79 return _impl->info.cpu_model(cpuid);
80}
81
82unsigned int CPUInfo::get_L1_cache_size() const
83{
84 return _impl->L1_cache_size;
85}
86
87unsigned int CPUInfo::get_L2_cache_size() const
88{
89 return _impl->L2_cache_size;
90}
91} // namespace arm_compute