Skip to content

Commit

Permalink
GH-44098: [C++] Add home made _mm256_set_m128i for compilers who are …
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
zanmato1984 authored Sep 17, 2024
1 parent fea1e97 commit 87d6477
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 1 addition & 2 deletions cpp/src/arrow/acero/swiss_join_avx2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/arrow/compute/row/compare_internal_avx2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 10 additions & 3 deletions cpp/src/arrow/util/simd.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,25 @@
#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

# ifdef ARROW_HAVE_NEON
# 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

0 comments on commit 87d6477

Please sign in to comment.