[Mesa-dev] [PATCH 1/2] gallium: Enable aarch64 NEON CPU detection.
Matt Turner
mattst88 at gmail.com
Tue Jan 22 23:12:41 UTC 2019
NEON (now called ASIMD) is available on all aarch64 CPUs. It seems that
our code was missing an aarch64 path, leading to util_cpu_caps.has_neon
always being false on aarch64. I think that means that the NEON tiling
code in vc4 would not be enabled on aarch64 (vc4_load_lt_image_neon,
etc).
---
I have very little clue about aarch64 ABIs, so I don't know if there's
another case that needs to be handled -- aarch32 maybe? Does
PIPE_ARCH_AARCH64 just mean ARMv8 and so we should check something else
for the ABI and choose Elf{32,64} based on that?
Also, Android is not handled.
src/util/u_cpu_detect.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/util/u_cpu_detect.c b/src/util/u_cpu_detect.c
index 52b9ae547d4..e9cdb78e458 100644
--- a/src/util/u_cpu_detect.c
+++ b/src/util/u_cpu_detect.c
@@ -328,7 +328,7 @@ PIPE_ALIGN_STACK static inline boolean sse2_has_daz(void)
#endif /* X86 or X86_64 */
-#if defined(PIPE_ARCH_ARM)
+#if defined(PIPE_ARCH_ARM) || defined(PIPE_ARCH_AARCH64)
static void
check_os_arm_support(void)
{
@@ -348,24 +348,36 @@ check_os_arm_support(void)
util_cpu_caps.has_neon = 1;
}
#elif defined(PIPE_OS_LINUX)
- Elf32_auxv_t aux;
+
+#if defined(PIPE_ARCH_ARM)
+#define Elf_auxv_t Elf32_auxv_t
+#elif defined(PIPE_ARCH_AARCH64)
+#define Elf_auxv_t Elf64_auxv_t
+#endif
+
+ Elf_auxv_t aux;
int fd;
fd = open("/proc/self/auxv", O_RDONLY | O_CLOEXEC);
if (fd >= 0) {
- while (read(fd, &aux, sizeof(Elf32_auxv_t)) == sizeof(Elf32_auxv_t)) {
+ while (read(fd, &aux, sizeof(Elf_auxv_t)) == sizeof(Elf_auxv_t)) {
if (aux.a_type == AT_HWCAP) {
uint32_t hwcap = aux.a_un.a_val;
+#if defined(PIPE_ARCH_ARM)
util_cpu_caps.has_neon = (hwcap >> 12) & 1;
+#elif defined(PIPE_ARCH_AARCH64)
+ util_cpu_caps.has_neon = (hwcap >> 1) & 1;
+#endif
break;
}
}
close (fd);
}
+#undef Elf_auxv_t
#endif /* PIPE_OS_LINUX */
}
-#endif /* PIPE_ARCH_ARM */
+#endif /* PIPE_ARCH_ARM || PIPE_ARCH_AARCH64 */
static void
get_cpu_topology(void)
@@ -534,7 +546,7 @@ util_cpu_detect_once(void)
}
#endif /* PIPE_ARCH_X86 || PIPE_ARCH_X86_64 */
-#if defined(PIPE_ARCH_ARM)
+#if defined(PIPE_ARCH_ARM) || defined(PIPE_ARCH_AARCH64)
check_os_arm_support();
#endif
--
2.19.2
More information about the mesa-dev
mailing list