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
25 #include "arm_compute/core/CPP/CPPTypes.h"
26
27 #include "arm_compute/core/Error.h"
28 #include "src/common/cpuinfo/CpuInfo.h"
29 #include "src/common/cpuinfo/CpuIsaInfo.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
get()40 CPUInfo &CPUInfo::get()
41 {
42 static CPUInfo _cpuinfo;
43 return _cpuinfo;
44 }
45
CPUInfo()46 CPUInfo::CPUInfo()
47 : _impl(std::make_unique<Impl>())
48 {
49 _impl->info = cpuinfo::CpuInfo::build();
50 }
51
52 CPUInfo::~CPUInfo() = default;
53
get_cpu_num() const54 unsigned int CPUInfo::get_cpu_num() const
55 {
56 return _impl->info.num_cpus();
57 }
58
has_fp16() const59 bool CPUInfo::has_fp16() const
60 {
61 return _impl->info.has_fp16();
62 }
63
has_bf16() const64 bool CPUInfo::has_bf16() const
65 {
66 return _impl->info.has_bf16();
67 }
68
has_svebf16() const69 bool CPUInfo::has_svebf16() const
70 {
71 return _impl->info.has_svebf16();
72 }
73
has_dotprod() const74 bool CPUInfo::has_dotprod() const
75 {
76 return _impl->info.has_dotprod();
77 }
78
has_svef32mm() const79 bool CPUInfo::has_svef32mm() const
80 {
81 return _impl->info.has_svef32mm();
82 }
83
has_i8mm() const84 bool CPUInfo::has_i8mm() const
85 {
86 return _impl->info.has_i8mm();
87 }
88
has_svei8mm() const89 bool CPUInfo::has_svei8mm() const
90 {
91 return _impl->info.has_svei8mm();
92 }
93
has_sve() const94 bool CPUInfo::has_sve() const
95 {
96 return _impl->info.has_sve();
97 }
98
has_sve2() const99 bool CPUInfo::has_sve2() const
100 {
101 return _impl->info.has_sve2();
102 }
103
has_sme() const104 bool CPUInfo::has_sme() const
105 {
106 return _impl->info.has_sme();
107 }
108
has_sme2() const109 bool CPUInfo::has_sme2() const
110 {
111 return _impl->info.has_sme2();
112 }
113
get_cpu_model() const114 CPUModel CPUInfo::get_cpu_model() const
115 {
116 return _impl->info.cpu_model();
117 }
118
get_cpu_model(unsigned int cpuid) const119 CPUModel CPUInfo::get_cpu_model(unsigned int cpuid) const
120 {
121 return _impl->info.cpu_model(cpuid);
122 }
123
get_isa() const124 cpuinfo::CpuIsaInfo CPUInfo::get_isa() const
125 {
126 return _impl->info.isa();
127 }
128
get_L1_cache_size() const129 unsigned int CPUInfo::get_L1_cache_size() const
130 {
131 return _impl->L1_cache_size;
132 }
133
get_L2_cache_size() const134 unsigned int CPUInfo::get_L2_cache_size() const
135 {
136 return _impl->L2_cache_size;
137 }
138 } // namespace arm_compute
139