Skip to content

Commit 2af6f12

Browse files
committed
feat: Add experimental SME/SVE runtime selection controls
Expose experimental runtime controls in CPUInfo so clients can mask SME/SME2 and SVE capabilities when selecting CPU kernels. This lets higher-level frameworks steer ACL away from ISA paths that should not be used for a graph while preserving default hardware-based selection when no override is supplied. Full context in the ArmNN PR: ARM-software/armnn#820 Signed-off-by: Damien Dooley <damien.dooley@arm.com> Change-Id: I602cebdd58942930d248948788bfac9e2be56474
1 parent 68d63f3 commit 2af6f12

3 files changed

Lines changed: 70 additions & 13 deletions

File tree

arm_compute/core/CPP/CPPTypes.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,27 @@ class CPUInfo final
168168
* @return true if the cpu supports sme_b16f32, false otherwise
169169
*/
170170
bool has_sme_b16f32() const;
171+
/** Sets whether SVE and SVE2 implementations are allowed to be selected at runtime.
172+
*
173+
* @experimental This API is under development and may change or be removed without notice in future releases.
174+
*
175+
* @param[in] is_allowed True to expose detected SVE/SVE2 support, false to hide SVE/SVE2 from runtime selectors.
176+
*/
177+
void set_sve_allowed(bool is_allowed);
178+
/** Sets whether SME and SME2 implementations are allowed to be selected at runtime.
179+
*
180+
* @experimental This API is under development and may change or be removed without notice in future releases.
181+
*
182+
* @param[in] is_allowed True to expose detected SME/SME2 support, false to hide SME/SME2 from runtime selectors.
183+
*/
184+
void set_sme_allowed(bool is_allowed);
185+
/** Returns whether SME and SME2 implementations are allowed to be selected at runtime.
186+
*
187+
* @experimental This API is under development and may change or be removed without notice in future releases.
188+
*
189+
* @return true if detected SME/SME2 support is exposed to runtime selectors, false otherwise.
190+
*/
191+
bool is_sme_allowed() const;
171192
/** Gets the cpu model for a given cpuid.
172193
*
173194
* @param[in] cpuid the id of the cpu core to be retrieved,

docs/Doxyfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ TAB_SIZE = 4
261261
# newlines.
262262

263263
ALIASES = \
264-
"publicapi=\xrefitem semver \"\" \"\""
264+
"publicapi=\xrefitem semver \"\" \"\"" \
265+
"experimental=@par Experimental:\n"
265266

266267
# This tag can be used to specify a number of word-keyword mappings (TCL only).
267268
# A mapping has the form "name=value". For example adding "class=itcl::class"

src/core/CPP/CPPTypes.cpp

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ struct CPUInfo::Impl
3939
cpuinfo::CpuInfo info{};
4040
unsigned int L1_cache_size = 32768;
4141
unsigned int L2_cache_size = 262144;
42+
bool sve_allowed = true;
43+
bool sme_allowed = true;
4244
};
4345

4446
CPUInfo &CPUInfo::get()
@@ -71,7 +73,7 @@ bool CPUInfo::has_bf16() const
7173

7274
bool CPUInfo::has_svebf16() const
7375
{
74-
return _impl->info.has_svebf16();
76+
return _impl->sve_allowed && _impl->info.has_svebf16();
7577
}
7678

7779
bool CPUInfo::has_dotprod() const
@@ -81,7 +83,7 @@ bool CPUInfo::has_dotprod() const
8183

8284
bool CPUInfo::has_svef32mm() const
8385
{
84-
return _impl->info.has_svef32mm();
86+
return _impl->sve_allowed && _impl->info.has_svef32mm();
8587
}
8688

8789
bool CPUInfo::has_i8mm() const
@@ -91,7 +93,7 @@ bool CPUInfo::has_i8mm() const
9193

9294
bool CPUInfo::has_svei8mm() const
9395
{
94-
return _impl->info.has_svei8mm();
96+
return _impl->sve_allowed && _impl->info.has_svei8mm();
9597
}
9698

9799
bool CPUInfo::has_fhm() const
@@ -101,42 +103,57 @@ bool CPUInfo::has_fhm() const
101103

102104
bool CPUInfo::has_sve() const
103105
{
104-
return _impl->info.has_sve();
106+
return _impl->sve_allowed && _impl->info.has_sve();
105107
}
106108

107109
bool CPUInfo::has_sve2() const
108110
{
109-
return _impl->info.has_sve2();
111+
return _impl->sve_allowed && _impl->info.has_sve2();
110112
}
111113

112114
bool CPUInfo::has_sme() const
113115
{
114-
return _impl->info.has_sme();
116+
return _impl->sme_allowed && _impl->info.has_sme();
115117
}
116118

117119
bool CPUInfo::has_sme2() const
118120
{
119-
return _impl->info.has_sme2();
121+
return _impl->sme_allowed && _impl->info.has_sme2();
120122
}
121123

122124
bool CPUInfo::has_sme_i8i32() const
123125
{
124-
return _impl->info.has_sme_i8i32();
126+
return _impl->sme_allowed && _impl->info.has_sme_i8i32();
125127
}
126128

127129
bool CPUInfo::has_sme_f16f32() const
128130
{
129-
return _impl->info.has_sme_f16f32();
131+
return _impl->sme_allowed && _impl->info.has_sme_f16f32();
130132
}
131133

132134
bool CPUInfo::has_sme_f32f32() const
133135
{
134-
return _impl->info.has_sme_f32f32();
136+
return _impl->sme_allowed && _impl->info.has_sme_f32f32();
135137
}
136138

137139
bool CPUInfo::has_sme_b16f32() const
138140
{
139-
return _impl->info.has_sme_b16f32();
141+
return _impl->sme_allowed && _impl->info.has_sme_b16f32();
142+
}
143+
144+
void CPUInfo::set_sve_allowed(bool is_allowed)
145+
{
146+
_impl->sve_allowed = is_allowed;
147+
}
148+
149+
void CPUInfo::set_sme_allowed(bool is_allowed)
150+
{
151+
_impl->sme_allowed = is_allowed;
152+
}
153+
154+
bool CPUInfo::is_sme_allowed() const
155+
{
156+
return _impl->sme_allowed;
140157
}
141158

142159
CPUModel CPUInfo::get_cpu_model() const
@@ -151,7 +168,25 @@ CPUModel CPUInfo::get_cpu_model(unsigned int cpuid) const
151168

152169
cpuinfo::CpuIsaInfo CPUInfo::get_isa() const
153170
{
154-
return _impl->info.isa();
171+
cpuinfo::CpuIsaInfo isa = _impl->info.isa();
172+
if (!_impl->sve_allowed)
173+
{
174+
isa.sve = false;
175+
isa.sve2 = false;
176+
isa.svebf16 = false;
177+
isa.svei8mm = false;
178+
isa.svef32mm = false;
179+
}
180+
if (!_impl->sme_allowed)
181+
{
182+
isa.sme = false;
183+
isa.sme2 = false;
184+
isa.sme_b16f32 = false;
185+
isa.sme_f16f32 = false;
186+
isa.sme_f32f32 = false;
187+
isa.sme_i8i32 = false;
188+
}
189+
return isa;
155190
}
156191

157192
unsigned int CPUInfo::get_L1_cache_size() const

0 commit comments

Comments
 (0)