This is an automated email from the ASF dual-hosted git repository.

michaelsmith pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git


The following commit(s) were added to refs/heads/master by this push:
     new 8ff71d61e IMPALA-14715: Fix CMake AVX2 check
8ff71d61e is described below

commit 8ff71d61e53fbb2690f8e5a60002f108a5f17430
Author: Joe McDonnell <[email protected]>
AuthorDate: Mon Feb 2 11:48:31 2026 -0800

    IMPALA-14715: Fix CMake AVX2 check
    
    Impala currently has two different checks for AVX2 compiler
    support: one in be/src/util and another from Kudu in be/src/kudu/util.
    The Kudu one is currently broken for the Impala build, disabling AVX2
    support for blocked bloom filters. This seems to be specific to Impala's
    toolchain CMake 3.22.2. Other versions of CMake (e.g. 3.22.1 on Ubuntu 22
    or 3.31.10) work properly.
    
    This centralizes the AVX2 check and uses the working version from
    be/src/util. To prevent future issues, it fails the build if AVX2
    support is not detected on x86_64. In order to be easy to backport,
    this does not upgrade CMake (but that will happen separately).
    
    Testing:
     - Ran build on my local x86_64 machine and verified the compilation
       flags for Impala's parquet bloom filters, Kudu's block bloom filters,
       and roaring bitmap all reflect AVX2 support.
    
    Change-Id: If34820a1a0d70e54df0859ec6d524b178367db0a
    Reviewed-on: http://gerrit.cloudera.org:8080/23931
    Reviewed-by: Jason Fehr <[email protected]>
    Reviewed-by: Michael Smith <[email protected]>
    Tested-by: Impala Public Jenkins <[email protected]>
---
 be/CMakeLists.txt               | 20 ++++++++++++++++++++
 be/src/kudu/util/CMakeLists.txt | 16 ++++------------
 be/src/util/CMakeLists.txt      | 13 +++----------
 3 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt
index cd13365bd..69da6f511 100644
--- a/be/CMakeLists.txt
+++ b/be/CMakeLists.txt
@@ -34,6 +34,26 @@ if (NOT "$ENV{IMPALA_LINKER}" STREQUAL "ld" AND
   message(FATAL_ERROR "Invalid IMPALA_LINKER: $ENV{IMPALA_LINKER} (expected: 
ld, gold, or mold)")
 endif()
 
+# Detect AVX2 support. This centralizes the logic used in be/src/util and 
be/src/kudu/util.
+# IMPALA-14715: This check is sensitive to CMake versions, so this uses the 
Impala check that
+# is compatible with CMake 3.22.2.
+set(AVX2_CMD "echo | ${CMAKE_CXX_COMPILER} -mavx2 -dM -E - | awk '$2 == 
\"__AVX2__\" { print $3 }'")
+execute_process(
+  COMMAND bash -c ${AVX2_CMD}
+  OUTPUT_VARIABLE AVX2_SUPPORT
+  OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
+if (AVX2_SUPPORT)
+  message("Compiler supports AVX2")
+else()
+  if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
+    message(FATAL_ERROR "Compiler is required to support AVX2 on x86_64")
+  else()
+    message("Compiler does not support AVX2 on ${CMAKE_SYSTEM_PROCESSOR}")
+  endif()
+endif()
+
 # compiler flags that are common across debug/release builds
 #  -Wall: Enable all warnings.
 #  -Wno-sign-compare: suppress warnings for comparison between signed and 
unsigned
diff --git a/be/src/kudu/util/CMakeLists.txt b/be/src/kudu/util/CMakeLists.txt
index d75438b3d..140c1718f 100644
--- a/be/src/kudu/util/CMakeLists.txt
+++ b/be/src/kudu/util/CMakeLists.txt
@@ -289,17 +289,9 @@ endif()
 # optimized regardless of the default optimization options.
 set_source_files_properties(memory/overwrite.cc PROPERTIES COMPILE_FLAGS "-O3")
 
-# Detect AVX2 support
-execute_process(
-  COMMAND echo
-  COMMAND ${CMAKE_CXX_COMPILER} -mavx2 -dM -E -
-  COMMAND awk "$2 == \"__AVX2__\" { print $3 }"
-  ERROR_QUIET
-  OUTPUT_VARIABLE AVX2_SUPPORT
-  OUTPUT_STRIP_TRAILING_WHITESPACE
-)
-
 # block_bloom_filter_avx2.cc uses AVX2 operations.
+# NOTE: This is modified from the Kudu source code. As other Impala code needs 
AVX2
+# detection, it has been centralized in be/CMakeLists.txt
 if (AVX2_SUPPORT)
   list(APPEND UTIL_SRCS block_bloom_filter_avx2.cc)
   set_source_files_properties(block_bloom_filter_avx2.cc PROPERTIES 
COMPILE_FLAGS "-mavx2")
@@ -308,9 +300,9 @@ if (AVX2_SUPPORT)
   # instead of relying on __AVX2__ defined by compiler with -mavx2.
   set_source_files_properties(block_bloom_filter_avx2.cc block_bloom_filter.cc
                               PROPERTIES COMPILE_DEFINITIONS "USE_AVX2=1")
-  message("Compiler supports AVX2")
+  message("Compiler supports AVX2 (be/src/kudu/util)")
 else()
-  message("Compiler does not support AVX2")
+  message("Compiler does not support AVX2 (be/src/kudu/util)")
 endif()
 
 set(UTIL_LIBS
diff --git a/be/src/util/CMakeLists.txt b/be/src/util/CMakeLists.txt
index e54a3c446..b6b42fbdf 100644
--- a/be/src/util/CMakeLists.txt
+++ b/be/src/util/CMakeLists.txt
@@ -122,15 +122,8 @@ set(UTIL_SRCS
   ${MPFIT_SRC_DIR}/mpfit.c
   ${ROARING_SRC_DIR}/roaring.c)
 
-# Detect AVX2 support
-set(AVX2_CMD "echo | ${CMAKE_CXX_COMPILER} -mavx2 -dM -E - | awk '$2 == 
\"__AVX2__\" { print $3 }'")
-execute_process(
-  COMMAND bash -c ${AVX2_CMD}
-  OUTPUT_VARIABLE AVX2_SUPPORT
-  OUTPUT_STRIP_TRAILING_WHITESPACE
-)
-
 # parquet-bloom-filter-avx2.cc uses AVX2 operations.
+# NOTE: AVX2 detection has been centralized in be/CMakeLists.txt.
 if (AVX2_SUPPORT)
   list(APPEND UTIL_SRCS parquet-bloom-filter-avx2.cc)
 
@@ -143,9 +136,9 @@ if (AVX2_SUPPORT)
   # be/src/kudu/util/block_bloom_filter_avx2.cc.
   set_source_files_properties(parquet-bloom-filter-avx2.cc 
parquet-bloom-filter.cc
                               PROPERTIES COMPILE_DEFINITIONS "USE_AVX2=1")
-  message("Compiler supports AVX2")
+  message("Compiler supports AVX2 (be/src/util)")
 else()
-  message("Compiler does not support AVX2")
+  message("Compiler does not support AVX2 (be/src/util)")
 endif()
 
 # roaring.c uses AVX operations

Reply via email to