From 91340508d93a962b490ee782c6a36736cb54dec3 Mon Sep 17 00:00:00 2001 From: Ruoxi Sun Date: Sat, 14 Sep 2024 12:14:42 +0800 Subject: [PATCH] Add home made _mm256_set_m128i for compilers who are missing it --- cpp/src/arrow/acero/swiss_join_avx2.cc | 3 +-- cpp/src/arrow/compute/row/compare_internal_avx2.cc | 3 +-- cpp/src/arrow/util/simd.h | 13 ++++++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cpp/src/arrow/acero/swiss_join_avx2.cc b/cpp/src/arrow/acero/swiss_join_avx2.cc index e42b0b40445bf..1076073523448 100644 --- a/cpp/src/arrow/acero/swiss_join_avx2.cc +++ b/cpp/src/arrow/acero/swiss_join_avx2.cc @@ -15,10 +15,9 @@ // specific language governing permissions and limitations // under the License. -#include - #include "arrow/acero/swiss_join_internal.h" #include "arrow/util/bit_util.h" +#include "arrow/util/simd.h" namespace arrow { namespace acero { diff --git a/cpp/src/arrow/compute/row/compare_internal_avx2.cc b/cpp/src/arrow/compute/row/compare_internal_avx2.cc index 96eed6fc03a2a..9f6e1adfe2108 100644 --- a/cpp/src/arrow/compute/row/compare_internal_avx2.cc +++ b/cpp/src/arrow/compute/row/compare_internal_avx2.cc @@ -15,11 +15,10 @@ // specific language governing permissions and limitations // under the License. -#include - #include "arrow/compute/row/compare_internal.h" #include "arrow/compute/util.h" #include "arrow/util/bit_util.h" +#include "arrow/util/simd.h" namespace arrow { namespace compute { diff --git a/cpp/src/arrow/util/simd.h b/cpp/src/arrow/util/simd.h index b37f6e4926978..cc1a7d6cc807c 100644 --- a/cpp/src/arrow/util/simd.h +++ b/cpp/src/arrow/util/simd.h @@ -27,13 +27,14 @@ #else // gcc/clang (possibly others) -# if defined(ARROW_HAVE_BMI2) +# if defined(ARROW_HAVE_BMI2) || defined(ARROW_HAVE_RUNTIME_BMI2) # include # endif -# if defined(ARROW_HAVE_AVX2) || defined(ARROW_HAVE_AVX512) +# if defined(ARROW_HAVE_AVX2) || defined(ARROW_HAVE_AVX512) || \ + defined(ARROW_HAVE_RUNTIME_AVX2) || defined(ARROW_HAVE_RUNTIME_AVX512) # include -# elif defined(ARROW_HAVE_SSE4_2) +# elif defined(ARROW_HAVE_SSE4_2) || defined(ARROW_HAVE_RUNTIME_SSE4_2) # include # endif @@ -41,4 +42,10 @@ # include # endif +// GH-44098: Workaround for missing _mm256_set_m128i in older versions of GCC. +# if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8 +# define _mm256_set_m128i(hi, lo) \ + _mm256_inserti128_si256(_mm256_castsi128_si256(lo), (hi), 1) +# endif + #endif