Skip to content

Commit

Permalink
simd: Fixed an incorrectly returning size for uint64_t in avx2 (#6004)
Browse files Browse the repository at this point in the history
* Fixed a size error in simd uint64_t avx2

* Converted unit test to compile time checks

* Removed an unused variable
  • Loading branch information
ldh4 committed Mar 24, 2023
1 parent aa1f48f commit 8400cbf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion simd/src/Kokkos_SIMD_AVX2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ class simd<std::uint64_t, simd_abi::avx2_fixed_size<4>> {
KOKKOS_IMPL_HOST_FORCEINLINE_FUNCTION simd& operator=(simd const&) = default;
KOKKOS_IMPL_HOST_FORCEINLINE_FUNCTION simd& operator=(simd&&) = default;
KOKKOS_IMPL_HOST_FORCEINLINE_FUNCTION static constexpr std::size_t size() {
return 8;
return 4;
}
template <class U, std::enable_if_t<std::is_convertible_v<U, value_type>,
bool> = false>
Expand Down
29 changes: 29 additions & 0 deletions simd/unit_tests/TestSIMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,3 +486,32 @@ TEST(simd, device) {
Kokkos::parallel_for(Kokkos::RangePolicy<Kokkos::IndexType<int>>(0, 1),
simd_device_functor());
}

TEST(simd, test_size) {
#if defined(KOKKOS_ARCH_AVX512XEON)
constexpr auto width = 8;
using Abi = Kokkos::Experimental::simd_abi::avx512_fixed_size<width>;
static_assert(width ==
Kokkos::Experimental::simd<std::uint32_t, Abi>::size());

#elif defined(KOKKOS_ARCH_AVX2)
constexpr auto width = 4;
using Abi = Kokkos::Experimental::simd_abi::avx2_fixed_size<width>;

#elif defined(__ARM_NEON)
constexpr auto width = 2;
using Abi = Kokkos::Experimental::simd_abi::neon_fixed_size<width>;

#else
constexpr auto width = 1;
using Abi = Kokkos::Experimental::simd_abi::scalar;
static_assert(width ==
Kokkos::Experimental::simd<std::uint32_t, Abi>::size());
#endif

static_assert(width == Kokkos::Experimental::simd<double, Abi>::size());
static_assert(width == Kokkos::Experimental::simd<std::int64_t, Abi>::size());
static_assert(width ==
Kokkos::Experimental::simd<std::uint64_t, Abi>::size());
static_assert(width == Kokkos::Experimental::simd<std::int32_t, Abi>::size());
}

0 comments on commit 8400cbf

Please sign in to comment.