This is an automated email from the ASF dual-hosted git repository.
apitrou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 87d647742b GH-44098: [C++] Add home made _mm256_set_m128i for
compilers who are missing it (#44116)
87d647742b is described below
commit 87d647742b9ae46e86050ac7361d6c3e75613a47
Author: Rossi Sun <[email protected]>
AuthorDate: Tue Sep 17 20:47:49 2024 +0800
GH-44098: [C++] Add home made _mm256_set_m128i for compilers who are
missing it (#44116)
### Rationale for this change
AVX2 intrinsic _mm256_set_m128i is missing in GCC versions <8.0 - this is a
GCC bug discussed in [1], causing certain CI build failed.
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80582
### What changes are included in this PR?
Check the GCC version and use a home made replacement if necessary.
### Are these changes tested?
Manually tested.
### Are there any user-facing changes?
None.
* GitHub Issue: #44098
Authored-by: Ruoxi Sun <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
---
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 e42b0b4044..1076073523 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 <immintrin.h>
-
#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 96eed6fc03..9f6e1adfe2 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 <immintrin.h>
-
#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 b37f6e4926..cc1a7d6cc8 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 <x86intrin.h>
# 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 <immintrin.h>
-# elif defined(ARROW_HAVE_SSE4_2)
+# elif defined(ARROW_HAVE_SSE4_2) || defined(ARROW_HAVE_RUNTIME_SSE4_2)
# include <nmmintrin.h>
# endif
@@ -41,4 +42,10 @@
# include <arm_neon.h>
# 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