Skip to content

Commit 6032403

Browse files
committed
fix: FEAT_SME2 detection in Android(TM) and Linux(R)
Resolves: COMPMID-8648 Change-Id: Iade2a514738b5731e2594056b1de7c259f0128bc Signed-off-by: Gunes Bayir <[email protected]>
1 parent 51fd9ac commit 6032403

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/common/cpuinfo/CpuInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ CpuInfo CpuInfo::build()
354354
{
355355
#if !defined(_WIN64) && !defined(BARE_METAL) && !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__QNX__) && \
356356
(defined(__arm__) || defined(__aarch64__))
357-
const uint32_t hwcaps = getauxval(AT_HWCAP);
358-
const uint32_t hwcaps2 = getauxval(AT_HWCAP2);
357+
const uint64_t hwcaps = getauxval(AT_HWCAP);
358+
const uint64_t hwcaps2 = getauxval(AT_HWCAP2);
359359
const uint32_t max_cpus = get_max_cpus();
360360

361361
// Populate midr values

src/common/cpuinfo/CpuIsaInfo.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#define ARM_COMPUTE_CPU_FEATURE_HWCAP2_I8MM (1 << 13)
4646
#define ARM_COMPUTE_CPU_FEATURE_HWCAP2_BF16 (1 << 14)
4747
#define ARM_COMPUTE_CPU_FEATURE_HWCAP2_SME (1 << 23)
48+
#define ARM_COMPUTE_CPU_FEATURE_HWCAP2_SME2 (1UL << 37)
4849

4950
namespace arm_compute
5051
{
@@ -58,14 +59,14 @@ inline bool is_feature_supported(uint64_t features, uint64_t feature_mask)
5859
}
5960

6061
#if defined(__arm__)
61-
void decode_hwcaps(CpuIsaInfo &isa, const uint32_t hwcaps, const uint32_t hwcaps2)
62+
void decode_hwcaps(CpuIsaInfo &isa, const uint64_t hwcaps, const uint64_t hwcaps2)
6263
{
6364
ARM_COMPUTE_UNUSED(hwcaps2);
6465
isa.fp16 = false;
6566
isa.neon = is_feature_supported(hwcaps, ARM_COMPUTE_CPU_FEATURE_HWCAP_NEON);
6667
}
6768
#elif defined(__aarch64__)
68-
void decode_hwcaps(CpuIsaInfo &isa, const uint32_t hwcaps, const uint32_t hwcaps2)
69+
void decode_hwcaps(CpuIsaInfo &isa, const uint64_t hwcaps, const uint64_t hwcaps2)
6970
{
7071
// High-level SIMD support
7172
isa.neon = is_feature_supported(hwcaps, ARM_COMPUTE_CPU_FEATURE_HWCAP_ASIMD);
@@ -75,7 +76,7 @@ void decode_hwcaps(CpuIsaInfo &isa, const uint32_t hwcaps, const uint32_t hwcaps
7576

7677
// Detection of SME from type HWCAP2 in the auxillary vector
7778
isa.sme = is_feature_supported(hwcaps2, ARM_COMPUTE_CPU_FEATURE_HWCAP2_SME);
78-
isa.sme2 = isa.sme; // Needs to be set properly
79+
isa.sme2 = is_feature_supported(hwcaps2, ARM_COMPUTE_CPU_FEATURE_HWCAP2_SME2);
7980

8081
// Data-type support
8182
isa.fp16 = is_feature_supported(hwcaps, ARM_COMPUTE_CPU_FEATURE_HWCAP_FPHP | ARM_COMPUTE_CPU_FEATURE_HWCAP_ASIMDHP);
@@ -89,7 +90,7 @@ void decode_hwcaps(CpuIsaInfo &isa, const uint32_t hwcaps, const uint32_t hwcaps
8990
isa.svef32mm = is_feature_supported(hwcaps2, ARM_COMPUTE_CPU_FEATURE_HWCAP2_SVEF32MM);
9091
}
9192
#else /* defined(__aarch64__) */
92-
void decode_hwcaps(CpuIsaInfo &isa, const uint32_t hwcaps, const uint32_t hwcaps2)
93+
void decode_hwcaps(CpuIsaInfo &isa, const uint64_t hwcaps, const uint64_t hwcaps2)
9394
{
9495
ARM_COMPUTE_UNUSED(isa, hwcaps, hwcaps2);
9596
}
@@ -143,7 +144,7 @@ void allowlisted_model_features(CpuIsaInfo &isa, CpuModel model)
143144
}
144145
} // namespace
145146

146-
CpuIsaInfo init_cpu_isa_from_hwcaps(uint32_t hwcaps, uint32_t hwcaps2, uint32_t midr)
147+
CpuIsaInfo init_cpu_isa_from_hwcaps(uint64_t hwcaps, uint64_t hwcaps2, uint32_t midr)
147148
{
148149
CpuIsaInfo isa;
149150

src/common/cpuinfo/CpuIsaInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct CpuIsaInfo
6464
*
6565
* @return CpuIsaInfo A populated ISA feature structure
6666
*/
67-
CpuIsaInfo init_cpu_isa_from_hwcaps(uint32_t hwcaps, uint32_t hwcaps2, uint32_t midr);
67+
CpuIsaInfo init_cpu_isa_from_hwcaps(uint64_t hwcaps, uint64_t hwcaps2, uint32_t midr);
6868

6969
/** Identify ISA related information through register information
7070
*

0 commit comments

Comments
 (0)