From 0244b1858fbb25f9230c11ac0aba671bc859d467 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Tue, 30 Aug 2022 14:57:26 +0800 Subject: [PATCH] util: add support for detecting avx512 vector bit size Default to 256 until we're confident llvmpipe with 512 is as correct and not slower than 256 Signed-off-by: Yonggang Luo Reviewed-by: Jose Fonseca Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_init.c | 6 +++++- src/util/u_cpu_detect.c | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index c5cb666a019..f77aac75b76 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -28,6 +28,7 @@ #include "pipe/p_config.h" #include "pipe/p_compiler.h" +#include "util/macros.h" #include "util/u_cpu_detect.h" #include "util/u_debug.h" #include "util/u_memory.h" @@ -438,8 +439,11 @@ lp_build_init(void) lp_set_target_options(); + // Default to 256 until we're confident llvmpipe with 512 is as correct and not slower than 256 + lp_native_vector_width = MIN2(util_get_cpu_caps()->max_vector_bits, 256); + lp_native_vector_width = debug_get_num_option("LP_NATIVE_VECTOR_WIDTH", - util_get_cpu_caps()->max_vector_bits); + lp_native_vector_width); #ifdef PIPE_ARCH_PPC_64 /* Set the NJ bit in VSCR to 0 so denormalized values are handled as diff --git a/src/util/u_cpu_detect.c b/src/util/u_cpu_detect.c index c15ea11f783..dd799f29056 100644 --- a/src/util/u_cpu_detect.c +++ b/src/util/u_cpu_detect.c @@ -671,7 +671,9 @@ void check_max_vector_bits(void) */ util_cpu_caps.max_vector_bits = 128; #if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) - if (util_cpu_caps.has_avx) { + if (util_cpu_caps.has_avx512f) { + util_cpu_caps.max_vector_bits = 512; + } else if (util_cpu_caps.has_avx) { util_cpu_caps.max_vector_bits = 256; } #endif