Update Kokkos library in LAMMPS to v4.4.0

This commit is contained in:
Stan Moore
2024-09-11 09:20:36 -06:00
parent 16b19c71c1
commit a44955dd2e
254 changed files with 14227 additions and 9881 deletions

View File

@ -1,7 +1,9 @@
KOKKOS_INCLUDE_DIRECTORIES(${KOKKOS_SOURCE_DIR}/simd/unit_tests/include)
KOKKOS_ADD_EXECUTABLE_AND_TEST(
UnitTest_SIMD
SOURCES
UnitTestMain.cpp
TestSIMD.cpp)
IF((NOT (Kokkos_ENABLE_CUDA AND WIN32)))
KOKKOS_ADD_EXECUTABLE_AND_TEST(
UnitTest_SIMD
SOURCES
UnitTestMain.cpp
TestSIMD.cpp)
ENDIF()

View File

@ -81,7 +81,9 @@ class absolutes {
auto on_host(T const& a) const {
if constexpr (std::is_signed_v<typename T::value_type>) {
#if defined(KOKKOS_ENABLE_DEPRECATED_CODE_4)
KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_PUSH()
return Kokkos::Experimental::abs(a);
KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_POP()
#else
return Kokkos::abs(a);
#endif

View File

@ -135,8 +135,8 @@ class load_masked {
for (std::size_t i = 0; i < n; ++i) {
mask[i] = true;
}
result = T(0);
where(mask, result).copy_from(mem, Kokkos::Experimental::simd_flag_default);
where(!mask, result) = 0;
return true;
}
template <class T, class Abi>
@ -181,4 +181,14 @@ class load_as_scalars {
}
};
// Simple check to loosely test that T is a complete type.
// Some capabilities are only defined for specific data type and abi pairs (i.e.
// extended vector width); this is used to exclude pairs that
// are not defined from being tested.
template <typename T, typename = void>
constexpr bool is_type_v = false;
template <typename T>
constexpr bool is_type_v<T, decltype(void(sizeof(T)))> = true;
#endif

View File

@ -22,21 +22,23 @@
template <typename Abi, typename DataType>
inline void host_check_condition() {
using simd_type = typename Kokkos::Experimental::simd<DataType, Abi>;
using mask_type = typename simd_type::mask_type;
if constexpr (is_type_v<Kokkos::Experimental::simd<DataType, Abi>>) {
using simd_type = typename Kokkos::Experimental::simd<DataType, Abi>;
using mask_type = typename simd_type::mask_type;
auto condition_op = [](mask_type const& mask, simd_type const& a,
simd_type const& b) {
return Kokkos::Experimental::condition(mask, a, b);
};
auto condition_op = [](mask_type const& mask, simd_type const& a,
simd_type const& b) {
return Kokkos::Experimental::condition(mask, a, b);
};
simd_type value_a(16);
simd_type value_b(20);
simd_type value_a(16);
simd_type value_b(20);
auto condition_result = condition_op(mask_type(false), value_a, value_b);
EXPECT_TRUE(all_of(condition_result == value_b));
condition_result = condition_op(mask_type(true), value_a, value_b);
EXPECT_TRUE(all_of(condition_result == value_a));
auto condition_result = condition_op(mask_type(false), value_a, value_b);
EXPECT_TRUE(all_of(condition_result == value_b));
condition_result = condition_op(mask_type(true), value_a, value_b);
EXPECT_TRUE(all_of(condition_result == value_a));
}
}
template <typename Abi, typename... DataTypes>
@ -54,22 +56,24 @@ inline void host_check_condition_all_abis(
template <typename Abi, typename DataType>
KOKKOS_INLINE_FUNCTION void device_check_condition() {
using simd_type = typename Kokkos::Experimental::simd<DataType, Abi>;
using mask_type = typename simd_type::mask_type;
kokkos_checker checker;
if constexpr (is_type_v<Kokkos::Experimental::simd<DataType, Abi>>) {
using simd_type = typename Kokkos::Experimental::simd<DataType, Abi>;
using mask_type = typename simd_type::mask_type;
kokkos_checker checker;
auto condition_op = [](mask_type const& mask, simd_type const& a,
simd_type const& b) {
return Kokkos::Experimental::condition(mask, a, b);
};
auto condition_op = [](mask_type const& mask, simd_type const& a,
simd_type const& b) {
return Kokkos::Experimental::condition(mask, a, b);
};
simd_type value_a(16);
simd_type value_b(20);
simd_type value_a(16);
simd_type value_b(20);
auto condition_result = condition_op(mask_type(false), value_a, value_b);
checker.truth(all_of(condition_result == value_b));
condition_result = condition_op(mask_type(true), value_a, value_b);
checker.truth(all_of(condition_result == value_a));
auto condition_result = condition_op(mask_type(false), value_a, value_b);
checker.truth(all_of(condition_result == value_b));
condition_result = condition_op(mask_type(true), value_a, value_b);
checker.truth(all_of(condition_result == value_a));
}
}
template <typename Abi, typename... DataTypes>

View File

@ -22,40 +22,42 @@
template <typename Abi>
inline void host_check_conversions() {
{
auto a = Kokkos::Experimental::simd<std::uint64_t, Abi>(1);
auto b = Kokkos::Experimental::simd<std::int64_t, Abi>(a);
EXPECT_TRUE(all_of(b == decltype(b)(1)));
}
{
auto a = Kokkos::Experimental::simd<std::int32_t, Abi>(1);
auto b = Kokkos::Experimental::simd<std::uint64_t, Abi>(a);
EXPECT_TRUE(all_of(b == decltype(b)(1)));
}
{
auto a = Kokkos::Experimental::simd<std::uint64_t, Abi>(1);
auto b = Kokkos::Experimental::simd<std::int32_t, Abi>(a);
EXPECT_TRUE(all_of(b == decltype(b)(1)));
}
{
auto a = Kokkos::Experimental::simd_mask<double, Abi>(true);
auto b = Kokkos::Experimental::simd_mask<std::int32_t, Abi>(a);
EXPECT_TRUE(b == decltype(b)(true));
}
{
auto a = Kokkos::Experimental::simd_mask<std::int32_t, Abi>(true);
auto b = Kokkos::Experimental::simd_mask<std::uint64_t, Abi>(a);
EXPECT_TRUE(b == decltype(b)(true));
}
{
auto a = Kokkos::Experimental::simd_mask<std::int32_t, Abi>(true);
auto b = Kokkos::Experimental::simd_mask<std::int64_t, Abi>(a);
EXPECT_TRUE(b == decltype(b)(true));
}
{
auto a = Kokkos::Experimental::simd_mask<std::int32_t, Abi>(true);
auto b = Kokkos::Experimental::simd_mask<double, Abi>(a);
EXPECT_TRUE(b == decltype(b)(true));
if constexpr (is_type_v<Kokkos::Experimental::simd<uint64_t, Abi>>) {
{
auto a = Kokkos::Experimental::simd<std::uint64_t, Abi>(1);
auto b = Kokkos::Experimental::simd<std::int64_t, Abi>(a);
EXPECT_TRUE(all_of(b == decltype(b)(1)));
}
{
auto a = Kokkos::Experimental::simd<std::int32_t, Abi>(1);
auto b = Kokkos::Experimental::simd<std::uint64_t, Abi>(a);
EXPECT_TRUE(all_of(b == decltype(b)(1)));
}
{
auto a = Kokkos::Experimental::simd<std::uint64_t, Abi>(1);
auto b = Kokkos::Experimental::simd<std::int32_t, Abi>(a);
EXPECT_TRUE(all_of(b == decltype(b)(1)));
}
{
auto a = Kokkos::Experimental::simd_mask<double, Abi>(true);
auto b = Kokkos::Experimental::simd_mask<std::int32_t, Abi>(a);
EXPECT_TRUE(b == decltype(b)(true));
}
{
auto a = Kokkos::Experimental::simd_mask<std::int32_t, Abi>(true);
auto b = Kokkos::Experimental::simd_mask<std::uint64_t, Abi>(a);
EXPECT_TRUE(b == decltype(b)(true));
}
{
auto a = Kokkos::Experimental::simd_mask<std::int32_t, Abi>(true);
auto b = Kokkos::Experimental::simd_mask<std::int64_t, Abi>(a);
EXPECT_TRUE(b == decltype(b)(true));
}
{
auto a = Kokkos::Experimental::simd_mask<std::int32_t, Abi>(true);
auto b = Kokkos::Experimental::simd_mask<double, Abi>(a);
EXPECT_TRUE(b == decltype(b)(true));
}
}
}
@ -67,41 +69,43 @@ inline void host_check_conversions_all_abis(
template <typename Abi>
KOKKOS_INLINE_FUNCTION void device_check_conversions() {
kokkos_checker checker;
{
auto a = Kokkos::Experimental::simd<std::uint64_t, Abi>(1);
auto b = Kokkos::Experimental::simd<std::int64_t, Abi>(a);
checker.truth(all_of(b == decltype(b)(1)));
}
{
auto a = Kokkos::Experimental::simd<std::int32_t, Abi>(1);
auto b = Kokkos::Experimental::simd<std::uint64_t, Abi>(a);
checker.truth(all_of(b == decltype(b)(1)));
}
{
auto a = Kokkos::Experimental::simd<std::uint64_t, Abi>(1);
auto b = Kokkos::Experimental::simd<std::int32_t, Abi>(a);
checker.truth(all_of(b == decltype(b)(1)));
}
{
auto a = Kokkos::Experimental::simd_mask<double, Abi>(true);
auto b = Kokkos::Experimental::simd_mask<std::int32_t, Abi>(a);
checker.truth(b == decltype(b)(true));
}
{
auto a = Kokkos::Experimental::simd_mask<std::int32_t, Abi>(true);
auto b = Kokkos::Experimental::simd_mask<std::uint64_t, Abi>(a);
checker.truth(b == decltype(b)(true));
}
{
auto a = Kokkos::Experimental::simd_mask<std::int32_t, Abi>(true);
auto b = Kokkos::Experimental::simd_mask<std::int64_t, Abi>(a);
checker.truth(b == decltype(b)(true));
}
{
auto a = Kokkos::Experimental::simd_mask<std::int32_t, Abi>(true);
auto b = Kokkos::Experimental::simd_mask<double, Abi>(a);
checker.truth(b == decltype(b)(true));
if constexpr (is_type_v<Kokkos::Experimental::simd<uint64_t, Abi>>) {
kokkos_checker checker;
{
auto a = Kokkos::Experimental::simd<std::uint64_t, Abi>(1);
auto b = Kokkos::Experimental::simd<std::int64_t, Abi>(a);
checker.truth(all_of(b == decltype(b)(1)));
}
{
auto a = Kokkos::Experimental::simd<std::int32_t, Abi>(1);
auto b = Kokkos::Experimental::simd<std::uint64_t, Abi>(a);
checker.truth(all_of(b == decltype(b)(1)));
}
{
auto a = Kokkos::Experimental::simd<std::uint64_t, Abi>(1);
auto b = Kokkos::Experimental::simd<std::int32_t, Abi>(a);
checker.truth(all_of(b == decltype(b)(1)));
}
{
auto a = Kokkos::Experimental::simd_mask<double, Abi>(true);
auto b = Kokkos::Experimental::simd_mask<std::int32_t, Abi>(a);
checker.truth(b == decltype(b)(true));
}
{
auto a = Kokkos::Experimental::simd_mask<std::int32_t, Abi>(true);
auto b = Kokkos::Experimental::simd_mask<std::uint64_t, Abi>(a);
checker.truth(b == decltype(b)(true));
}
{
auto a = Kokkos::Experimental::simd_mask<std::int32_t, Abi>(true);
auto b = Kokkos::Experimental::simd_mask<std::int64_t, Abi>(a);
checker.truth(b == decltype(b)(true));
}
{
auto a = Kokkos::Experimental::simd_mask<std::int32_t, Abi>(true);
auto b = Kokkos::Experimental::simd_mask<double, Abi>(a);
checker.truth(b == decltype(b)(true));
}
}
}

View File

@ -22,49 +22,51 @@
template <typename Abi, typename DataType>
inline void host_check_gen_ctor() {
using simd_type = Kokkos::Experimental::simd<DataType, Abi>;
using mask_type = typename simd_type::mask_type;
constexpr std::size_t lanes = simd_type::size();
if constexpr (is_type_v<Kokkos::Experimental::simd<DataType, Abi>>) {
using simd_type = Kokkos::Experimental::simd<DataType, Abi>;
using mask_type = typename simd_type::mask_type;
constexpr std::size_t lanes = simd_type::size();
DataType init[lanes];
DataType expected[lanes];
mask_type init_mask(false);
DataType init[lanes];
DataType expected[lanes];
mask_type init_mask(false);
for (std::size_t i = 0; i < lanes; ++i) {
if (i % 3 == 0) init_mask[i] = true;
init[i] = 7;
expected[i] = (init_mask[i]) ? init[i] * 9 : init[i];
}
for (std::size_t i = 0; i < lanes; ++i) {
if (i % 3 == 0) init_mask[i] = true;
init[i] = 7;
expected[i] = (init_mask[i]) ? init[i] * 9 : init[i];
}
simd_type rhs;
rhs.copy_from(init, Kokkos::Experimental::simd_flag_default);
simd_type rhs;
rhs.copy_from(init, Kokkos::Experimental::simd_flag_default);
simd_type blend;
blend.copy_from(expected, Kokkos::Experimental::simd_flag_default);
simd_type blend;
blend.copy_from(expected, Kokkos::Experimental::simd_flag_default);
#if !(defined(KOKKOS_ENABLE_CUDA) && defined(KOKKOS_COMPILER_MSVC))
if constexpr (std::is_same_v<Abi, Kokkos::Experimental::simd_abi::scalar>) {
simd_type basic(KOKKOS_LAMBDA(std::size_t i) { return init[i]; });
host_check_equality(basic, rhs, lanes);
if constexpr (std::is_same_v<Abi, Kokkos::Experimental::simd_abi::scalar>) {
simd_type basic(KOKKOS_LAMBDA(std::size_t i) { return init[i]; });
host_check_equality(basic, rhs, lanes);
simd_type lhs(KOKKOS_LAMBDA(std::size_t i) { return init[i] * 9; });
mask_type mask(KOKKOS_LAMBDA(std::size_t i) { return init_mask[i]; });
simd_type result(
KOKKOS_LAMBDA(std::size_t i) { return (mask[i]) ? lhs[i] : rhs[i]; });
simd_type lhs(KOKKOS_LAMBDA(std::size_t i) { return init[i] * 9; });
mask_type mask(KOKKOS_LAMBDA(std::size_t i) { return init_mask[i]; });
simd_type result(
KOKKOS_LAMBDA(std::size_t i) { return (mask[i]) ? lhs[i] : rhs[i]; });
host_check_equality(blend, result, lanes);
} else {
simd_type basic([=](std::size_t i) { return init[i]; });
host_check_equality(basic, rhs, lanes);
host_check_equality(blend, result, lanes);
} else {
simd_type basic([=](std::size_t i) { return init[i]; });
host_check_equality(basic, rhs, lanes);
simd_type lhs([=](std::size_t i) { return init[i] * 9; });
mask_type mask([=](std::size_t i) { return init_mask[i]; });
simd_type result(
[=](std::size_t i) { return (mask[i]) ? lhs[i] : rhs[i]; });
simd_type lhs([=](std::size_t i) { return init[i] * 9; });
mask_type mask([=](std::size_t i) { return init_mask[i]; });
simd_type result(
[=](std::size_t i) { return (mask[i]) ? lhs[i] : rhs[i]; });
host_check_equality(blend, result, lanes);
}
host_check_equality(blend, result, lanes);
}
#endif
}
}
template <typename Abi, typename... DataTypes>
@ -82,32 +84,34 @@ inline void host_check_gen_ctors_all_abis(
template <typename Abi, typename DataType>
KOKKOS_INLINE_FUNCTION void device_check_gen_ctor() {
using simd_type = Kokkos::Experimental::simd<DataType, Abi>;
using mask_type = typename simd_type::mask_type;
constexpr std::size_t lanes = simd_type::size();
if constexpr (is_type_v<Kokkos::Experimental::simd<DataType, Abi>>) {
using simd_type = Kokkos::Experimental::simd<DataType, Abi>;
using mask_type = typename simd_type::mask_type;
constexpr std::size_t lanes = simd_type::size();
DataType init[lanes];
DataType expected[lanes];
mask_type mask(false);
DataType init[lanes];
DataType expected[lanes];
mask_type mask(false);
for (std::size_t i = 0; i < lanes; ++i) {
if (i % 3 == 0) mask[i] = true;
init[i] = 7;
expected[i] = (mask[i]) ? init[i] * 9 : init[i];
for (std::size_t i = 0; i < lanes; ++i) {
if (i % 3 == 0) mask[i] = true;
init[i] = 7;
expected[i] = (mask[i]) ? init[i] * 9 : init[i];
}
simd_type basic(KOKKOS_LAMBDA(std::size_t i) { return init[i]; });
simd_type rhs;
rhs.copy_from(init, Kokkos::Experimental::simd_flag_default);
device_check_equality(basic, rhs, lanes);
simd_type lhs(KOKKOS_LAMBDA(std::size_t i) { return init[i] * 9; });
simd_type result(
KOKKOS_LAMBDA(std::size_t i) { return (mask[i]) ? lhs[i] : rhs[i]; });
simd_type blend;
blend.copy_from(expected, Kokkos::Experimental::simd_flag_default);
device_check_equality(result, blend, lanes);
}
simd_type basic(KOKKOS_LAMBDA(std::size_t i) { return init[i]; });
simd_type rhs;
rhs.copy_from(init, Kokkos::Experimental::simd_flag_default);
device_check_equality(basic, rhs, lanes);
simd_type lhs(KOKKOS_LAMBDA(std::size_t i) { return init[i] * 9; });
simd_type result(
KOKKOS_LAMBDA(std::size_t i) { return (mask[i]) ? lhs[i] : rhs[i]; });
simd_type blend;
blend.copy_from(expected, Kokkos::Experimental::simd_flag_default);
device_check_equality(result, blend, lanes);
}
template <typename Abi, typename... DataTypes>

View File

@ -22,25 +22,27 @@
template <typename Abi, typename DataType>
inline void host_check_mask_ops() {
using mask_type = Kokkos::Experimental::simd_mask<DataType, Abi>;
if constexpr (is_type_v<Kokkos::Experimental::simd<DataType, Abi>>) {
using mask_type = Kokkos::Experimental::simd_mask<DataType, Abi>;
EXPECT_FALSE(none_of(mask_type(true)));
EXPECT_TRUE(none_of(mask_type(false)));
EXPECT_TRUE(all_of(mask_type(true)));
EXPECT_FALSE(all_of(mask_type(false)));
EXPECT_TRUE(any_of(mask_type(true)));
EXPECT_FALSE(any_of(mask_type(false)));
EXPECT_FALSE(none_of(mask_type(true)));
EXPECT_TRUE(none_of(mask_type(false)));
EXPECT_TRUE(all_of(mask_type(true)));
EXPECT_FALSE(all_of(mask_type(false)));
EXPECT_TRUE(any_of(mask_type(true)));
EXPECT_FALSE(any_of(mask_type(false)));
for (std::size_t i = 0; i < mask_type::size(); ++i) {
mask_type test_mask(KOKKOS_LAMBDA(std::size_t j) { return i == j; });
for (std::size_t i = 0; i < mask_type::size(); ++i) {
mask_type test_mask(KOKKOS_LAMBDA(std::size_t j) { return i == j; });
EXPECT_TRUE(any_of(test_mask));
EXPECT_FALSE(none_of(test_mask));
EXPECT_TRUE(any_of(test_mask));
EXPECT_FALSE(none_of(test_mask));
if constexpr (mask_type::size() > 1) {
EXPECT_FALSE(all_of(test_mask));
} else {
EXPECT_TRUE(all_of(test_mask));
if constexpr (mask_type::size() > 1) {
EXPECT_FALSE(all_of(test_mask));
} else {
EXPECT_TRUE(all_of(test_mask));
}
}
}
}
@ -60,25 +62,27 @@ inline void host_check_mask_ops_all_abis(
template <typename Abi, typename DataType>
KOKKOS_INLINE_FUNCTION void device_check_mask_ops() {
using mask_type = Kokkos::Experimental::simd_mask<DataType, Abi>;
kokkos_checker checker;
checker.truth(!none_of(mask_type(true)));
checker.truth(none_of(mask_type(false)));
checker.truth(all_of(mask_type(true)));
checker.truth(!all_of(mask_type(false)));
checker.truth(any_of(mask_type(true)));
checker.truth(!any_of(mask_type(false)));
if constexpr (is_type_v<Kokkos::Experimental::simd<DataType, Abi>>) {
using mask_type = Kokkos::Experimental::simd_mask<DataType, Abi>;
kokkos_checker checker;
checker.truth(!none_of(mask_type(true)));
checker.truth(none_of(mask_type(false)));
checker.truth(all_of(mask_type(true)));
checker.truth(!all_of(mask_type(false)));
checker.truth(any_of(mask_type(true)));
checker.truth(!any_of(mask_type(false)));
for (std::size_t i = 0; i < mask_type::size(); ++i) {
mask_type test_mask(KOKKOS_LAMBDA(std::size_t j) { return i == j; });
for (std::size_t i = 0; i < mask_type::size(); ++i) {
mask_type test_mask(KOKKOS_LAMBDA(std::size_t j) { return i == j; });
checker.truth(any_of(test_mask));
checker.truth(!none_of(test_mask));
checker.truth(any_of(test_mask));
checker.truth(!none_of(test_mask));
if constexpr (mask_type::size() > 1) {
checker.truth(!all_of(test_mask));
} else {
checker.truth(all_of(test_mask));
if constexpr (mask_type::size() > 1) {
checker.truth(!all_of(test_mask));
} else {
checker.truth(all_of(test_mask));
}
}
}
}

View File

@ -121,31 +121,34 @@ inline void host_check_abi_size() {
template <typename Abi, typename DataType>
inline void host_check_math_ops() {
constexpr size_t n = 11;
constexpr size_t alignment =
Kokkos::Experimental::simd<DataType, Abi>::size() * sizeof(DataType);
if constexpr (is_type_v<Kokkos::Experimental::simd<DataType, Abi>>) {
constexpr size_t alignment =
Kokkos::Experimental::simd<DataType, Abi>::size() * sizeof(DataType);
host_check_abi_size<Abi, DataType>();
host_check_abi_size<Abi, DataType>();
if constexpr (!std::is_integral_v<DataType>) {
alignas(alignment) DataType const first_args[n] = {
0.1, 0.4, 0.5, 0.7, 1.0, 1.5, -2.0, 10.0, 0.0, 1.2, -2.8};
alignas(alignment) DataType const second_args[n] = {
1.0, 0.2, 1.1, 1.8, -0.1, -3.0, -2.4, 1.0, 13.0, -3.2, -2.1};
host_check_all_math_ops<Abi>(first_args, second_args);
} else {
if constexpr (std::is_signed_v<DataType>) {
alignas(alignment)
DataType const first_args[n] = {1, 2, -1, 10, 0, 1, -2, 10, 0, 1, -2};
alignas(alignment) DataType const second_args[n] = {1, 2, 1, 1, 1, -3,
-2, 1, 13, -3, -2};
if constexpr (!std::is_integral_v<DataType>) {
alignas(alignment) DataType const first_args[] = {
0.1, 0.4, 0.5, 0.7, 1.0, 1.5, -2.0, 10.0,
0.0, 1.2, -2.8, 3.0, 4.0, -0.1, 5.0, -0.2};
alignas(alignment) DataType const second_args[] = {
1.0, 0.2, 1.1, 1.8, -0.1, -3.0, -2.4, 1.0,
13.0, -3.2, -2.1, 3.0, -15.0, -0.5, -0.2, -0.2};
host_check_all_math_ops<Abi>(first_args, second_args);
} else {
alignas(alignment)
DataType const first_args[n] = {1, 2, 1, 10, 0, 1, 2, 10, 0, 1, 2};
alignas(alignment)
DataType const second_args[n] = {1, 2, 1, 1, 1, 3, 2, 1, 13, 3, 2};
host_check_all_math_ops<Abi>(first_args, second_args);
if constexpr (std::is_signed_v<DataType>) {
alignas(alignment) DataType const first_args[] = {
1, 2, -1, 10, 0, 1, -2, 10, 0, 1, -2, -3, 7, 4, -9, -15};
alignas(alignment) DataType const second_args[] = {
1, 2, 1, 1, 1, -3, -2, 1, 13, -3, -2, 10, -15, 7, 2, -10};
host_check_all_math_ops<Abi>(first_args, second_args);
} else {
alignas(alignment) DataType const first_args[] = {
1, 2, 1, 10, 0, 1, 2, 10, 0, 1, 2, 11, 5, 8, 2, 14};
alignas(alignment) DataType const second_args[] = {
1, 2, 1, 1, 1, 3, 2, 1, 13, 3, 2, 3, 6, 20, 5, 14};
host_check_all_math_ops<Abi>(first_args, second_args);
}
}
}
}
@ -253,25 +256,31 @@ KOKKOS_INLINE_FUNCTION void device_check_abi_size() {
template <typename Abi, typename DataType>
KOKKOS_INLINE_FUNCTION void device_check_math_ops() {
constexpr size_t n = 11;
if constexpr (is_type_v<Kokkos::Experimental::simd<DataType, Abi>>) {
device_check_abi_size<Abi, DataType>();
device_check_abi_size<Abi, DataType>();
if constexpr (!std::is_integral_v<DataType>) {
DataType const first_args[n] = {0.1, 0.4, 0.5, 0.7, 1.0, 1.5,
-2.0, 10.0, 0.0, 1.2, -2.8};
DataType const second_args[n] = {1.0, 0.2, 1.1, 1.8, -0.1, -3.0,
-2.4, 1.0, 13.0, -3.2, -2.1};
device_check_all_math_ops<Abi>(first_args, second_args);
} else {
if constexpr (std::is_signed_v<DataType>) {
DataType const first_args[n] = {1, 2, -1, 10, 0, 1, -2, 10, 0, 1, -2};
DataType const second_args[n] = {1, 2, 1, 1, 1, -3, -2, 1, 13, -3, -2};
if constexpr (!std::is_integral_v<DataType>) {
DataType const first_args[] = {0.1, 0.4, 0.5, 0.7, 1.0, 1.5,
-2.0, 10.0, 0.0, 1.2, -2.8, 3.0,
4.0, -0.1, 5.0, -0.2};
DataType const second_args[] = {1.0, 0.2, 1.1, 1.8, -0.1, -3.0,
-2.4, 1.0, 13.0, -3.2, -2.1, 3.0,
-15.0, -0.5, -0.2, -0.2};
device_check_all_math_ops<Abi>(first_args, second_args);
} else {
DataType const first_args[n] = {1, 2, 1, 10, 0, 1, 2, 10, 0, 1, 2};
DataType const second_args[n] = {1, 2, 1, 1, 1, 3, 2, 1, 13, 3, 2};
device_check_all_math_ops<Abi>(first_args, second_args);
if constexpr (std::is_signed_v<DataType>) {
DataType const first_args[] = {1, 2, -1, 10, 0, 1, -2, 10,
0, 1, -2, -3, 7, 4, -9, -15};
DataType const second_args[] = {1, 2, 1, 1, 1, -3, -2, 1,
13, -3, -2, 10, -15, 7, 2, -10};
device_check_all_math_ops<Abi>(first_args, second_args);
} else {
DataType const first_args[] = {1, 2, 1, 10, 0, 1, 2, 10,
0, 1, 2, 11, 5, 8, 2, 14};
DataType const second_args[] = {1, 2, 1, 1, 1, 3, 2, 1,
13, 3, 2, 3, 6, 20, 5, 14};
device_check_all_math_ops<Abi>(first_args, second_args);
}
}
}
}

View File

@ -65,14 +65,18 @@ inline void host_check_all_reductions(const DataType (&args)[n]) {
template <typename Abi, typename DataType>
inline void host_check_reductions() {
constexpr size_t n = 11;
if constexpr (is_type_v<Kokkos::Experimental::simd<DataType, Abi>>) {
constexpr size_t n = 16;
if constexpr (std::is_signed_v<DataType>) {
DataType const args[n] = {1, 2, -1, 10, 0, 1, -2, 10, 0, 1, -2};
host_check_all_reductions<Abi>(args);
} else {
DataType const args[n] = {1, 2, 1, 10, 0, 1, 2, 10, 0, 1, 2};
host_check_all_reductions<Abi>(args);
if constexpr (std::is_signed_v<DataType>) {
DataType const args[n] = {1, 2, -1, 10, 0, 1, -2, 10,
0, 1, -2, -15, 5, 17, -22, 20};
host_check_all_reductions<Abi>(args);
} else {
DataType const args[n] = {1, 2, 1, 10, 0, 1, 2, 10,
0, 1, 2, 15, 5, 17, 22, 20};
host_check_all_reductions<Abi>(args);
}
}
}
@ -135,14 +139,18 @@ KOKKOS_INLINE_FUNCTION void device_check_all_reductions(
template <typename Abi, typename DataType>
KOKKOS_INLINE_FUNCTION void device_check_reductions() {
constexpr size_t n = 11;
if constexpr (is_type_v<Kokkos::Experimental::simd<DataType, Abi>>) {
constexpr size_t n = 16;
if constexpr (std::is_signed_v<DataType>) {
DataType const args[n] = {1, 2, -1, 10, 0, 1, -2, 10, 0, 1, -2};
device_check_all_reductions<Abi>(args);
} else {
DataType const args[n] = {1, 2, 1, 10, 0, 1, 2, 10, 0, 1, 2};
device_check_all_reductions<Abi>(args);
if constexpr (std::is_signed_v<DataType>) {
DataType const args[n] = {1, 2, -1, 10, 0, 1, -2, 10,
0, 1, -2, -15, 5, 17, -22, 20};
device_check_all_reductions<Abi>(args);
} else {
DataType const args[n] = {1, 2, 1, 10, 0, 1, 2, 10,
0, 1, 2, 15, 5, 17, 22, 20};
device_check_all_reductions<Abi>(args);
}
}
}

View File

@ -103,34 +103,35 @@ inline void host_check_shift_op_all_loaders(ShiftOp shift_op,
template <typename Abi, typename DataType>
inline void host_check_shift_ops() {
if constexpr (std::is_integral_v<DataType>) {
using simd_type = Kokkos::Experimental::simd<DataType, Abi>;
constexpr std::size_t width = simd_type::size();
constexpr std::size_t num_cases = 8;
constexpr size_t alignment =
Kokkos::Experimental::simd<DataType, Abi>::size() * sizeof(DataType);
if constexpr (is_type_v<Kokkos::Experimental::simd<DataType, Abi>>) {
if constexpr (std::is_integral_v<DataType>) {
using simd_type = Kokkos::Experimental::simd<DataType, Abi>;
constexpr std::size_t width = simd_type::size();
constexpr std::size_t num_cases = 16;
constexpr size_t alignment =
Kokkos::Experimental::simd<DataType, Abi>::size() * sizeof(DataType);
DataType max = std::numeric_limits<DataType>::max();
DataType max = std::numeric_limits<DataType>::max();
alignas(alignment) DataType shift_by[num_cases] = {
0, 1, 3, width / 2, width / 2 + 1, width - 1, width, width + 1};
alignas(alignment) DataType test_vals[width];
for (std::size_t i = 0; i < width; ++i) {
DataType inc = max / width;
test_vals[i] = i * inc + 1;
}
alignas(alignment) DataType shift_by[num_cases] = {
0, 1, 3, width / 2, width / 2 + 1, width - 1, width, width + 1,
0, 1, 3, width / 2, width / 2 + 1, width - 1, width, width + 1};
alignas(alignment) DataType test_vals[width];
for (std::size_t i = 0; i < width; ++i) {
DataType inc = max / width;
test_vals[i] = i * inc + 1;
}
host_check_shift_op_all_loaders<Abi>(shift_right(), test_vals, shift_by,
num_cases);
host_check_shift_op_all_loaders<Abi>(shift_left(), test_vals, shift_by,
num_cases);
if constexpr (std::is_signed_v<DataType>) {
for (std::size_t i = 0; i < width; ++i) test_vals[i] *= -1;
host_check_shift_op_all_loaders<Abi>(shift_right(), test_vals, shift_by,
num_cases);
host_check_shift_op_all_loaders<Abi>(shift_left(), test_vals, shift_by,
num_cases);
if constexpr (std::is_signed_v<DataType>) {
for (std::size_t i = 0; i < width; ++i) test_vals[i] *= -1;
host_check_shift_op_all_loaders<Abi>(shift_right(), test_vals, shift_by,
num_cases);
}
}
}
}
@ -224,33 +225,34 @@ KOKKOS_INLINE_FUNCTION void device_check_shift_op_all_loaders(
template <typename Abi, typename DataType>
KOKKOS_INLINE_FUNCTION void device_check_shift_ops() {
if constexpr (std::is_integral_v<DataType>) {
using simd_type = Kokkos::Experimental::simd<DataType, Abi>;
constexpr std::size_t width = simd_type::size();
constexpr std::size_t num_cases = 8;
if constexpr (is_type_v<Kokkos::Experimental::simd<DataType, Abi>>) {
if constexpr (std::is_integral_v<DataType>) {
using simd_type = Kokkos::Experimental::simd<DataType, Abi>;
constexpr std::size_t width = simd_type::size();
constexpr std::size_t num_cases = 16;
DataType max = Kokkos::reduction_identity<DataType>::max();
DataType max = Kokkos::reduction_identity<DataType>::max();
DataType shift_by[num_cases] = {
0, 1, 3, width / 2, width / 2 + 1, width - 1, width, width + 1};
DataType test_vals[width];
DataType shift_by[num_cases] = {
0, 1, 3, width / 2, width / 2 + 1, width - 1, width, width + 1,
0, 1, 3, width / 2, width / 2 + 1, width - 1, width, width + 1};
DataType test_vals[width];
for (std::size_t i = 0; i < width; ++i) {
DataType inc = max / width;
test_vals[i] = i * inc + 1;
}
for (std::size_t i = 0; i < width; ++i) {
DataType inc = max / width;
test_vals[i] = i * inc + 1;
}
device_check_shift_op_all_loaders<Abi>(shift_right(), test_vals, shift_by,
num_cases);
device_check_shift_op_all_loaders<Abi>(shift_left(), test_vals, shift_by,
num_cases);
if constexpr (std::is_signed_v<DataType>) {
for (std::size_t i = 0; i < width; ++i) test_vals[i] *= -1;
device_check_shift_op_all_loaders<Abi>(shift_right(), test_vals, shift_by,
num_cases);
device_check_shift_op_all_loaders<Abi>(shift_left(), test_vals, shift_by,
num_cases);
if constexpr (std::is_signed_v<DataType>) {
for (std::size_t i = 0; i < width; ++i) test_vals[i] *= -1;
device_check_shift_op_all_loaders<Abi>(shift_right(), test_vals,
shift_by, num_cases);
}
}
}
}

View File

@ -22,60 +22,66 @@
template <typename Abi, typename DataType>
inline void host_check_where_expr_scatter_to() {
using simd_type = Kokkos::Experimental::simd<DataType, Abi>;
using index_type = Kokkos::Experimental::simd<std::int32_t, Abi>;
using mask_type = typename simd_type::mask_type;
if constexpr (is_type_v<Kokkos::Experimental::simd<DataType, Abi>>) {
using simd_type = Kokkos::Experimental::simd<DataType, Abi>;
using index_type = Kokkos::Experimental::simd<std::int32_t, Abi>;
using mask_type = typename simd_type::mask_type;
std::size_t nlanes = simd_type::size();
DataType init[] = {11, 13, 17, 19, 23, 29, 31, 37};
simd_type src;
src.copy_from(init, Kokkos::Experimental::simd_flag_default);
std::size_t nlanes = simd_type::size();
DataType init[] = {11, 13, 17, 19, 23, 29, 31, 37,
53, 71, 79, 83, 89, 93, 97, 103};
simd_type src;
src.copy_from(init, Kokkos::Experimental::simd_flag_default);
for (std::size_t idx = 0; idx < nlanes; ++idx) {
mask_type mask(true);
mask[idx] = false;
for (std::size_t idx = 0; idx < nlanes; ++idx) {
mask_type mask(true);
mask[idx] = false;
DataType dst[8] = {0};
index_type index;
simd_type expected_result;
for (std::size_t i = 0; i < nlanes; ++i) {
dst[i] = (2 + (i * 2));
index[i] = i;
expected_result[i] = (mask[i]) ? src[index[i]] : dst[i];
DataType dst[simd_type::size()] = {0};
index_type index;
simd_type expected_result;
for (std::size_t i = 0; i < nlanes; ++i) {
dst[i] = (2 + (i * 2));
index[i] = i;
expected_result[i] = (mask[i]) ? src[index[i]] : dst[i];
}
where(mask, src).scatter_to(dst, index);
simd_type dst_simd;
dst_simd.copy_from(dst, Kokkos::Experimental::simd_flag_default);
host_check_equality(expected_result, dst_simd, nlanes);
}
where(mask, src).scatter_to(dst, index);
simd_type dst_simd;
dst_simd.copy_from(dst, Kokkos::Experimental::simd_flag_default);
host_check_equality(expected_result, dst_simd, nlanes);
}
}
template <typename Abi, typename DataType>
inline void host_check_where_expr_gather_from() {
using simd_type = Kokkos::Experimental::simd<DataType, Abi>;
using index_type = Kokkos::Experimental::simd<std::int32_t, Abi>;
using mask_type = typename simd_type::mask_type;
if constexpr (is_type_v<Kokkos::Experimental::simd<DataType, Abi>>) {
using simd_type = Kokkos::Experimental::simd<DataType, Abi>;
using index_type = Kokkos::Experimental::simd<std::int32_t, Abi>;
using mask_type = typename simd_type::mask_type;
std::size_t nlanes = simd_type::size();
DataType src[] = {11, 13, 17, 19, 23, 29, 31, 37};
std::size_t nlanes = simd_type::size();
DataType src[] = {11, 13, 17, 19, 23, 29, 31, 37,
53, 71, 79, 83, 89, 93, 97, 103};
for (std::size_t idx = 0; idx < nlanes; ++idx) {
mask_type mask(true);
mask[idx] = false;
for (std::size_t idx = 0; idx < nlanes; ++idx) {
mask_type mask(true);
mask[idx] = false;
simd_type dst;
index_type index;
simd_type expected_result;
for (std::size_t i = 0; i < nlanes; ++i) {
dst[i] = (2 + (i * 2));
index[i] = i;
expected_result[i] = (mask[i]) ? src[index[i]] : dst[i];
simd_type dst;
index_type index;
simd_type expected_result;
for (std::size_t i = 0; i < nlanes; ++i) {
dst[i] = (2 + (i * 2));
index[i] = i;
expected_result[i] = (mask[i]) ? src[index[i]] : dst[i];
}
where(mask, dst).gather_from(src, index);
host_check_equality(expected_result, dst, nlanes);
}
where(mask, dst).gather_from(src, index);
host_check_equality(expected_result, dst, nlanes);
}
}
@ -100,33 +106,36 @@ inline void host_check_where_expr_all_abis(
template <typename Abi, typename DataType>
KOKKOS_INLINE_FUNCTION void device_check_where_expr_scatter_to() {
using simd_type = Kokkos::Experimental::simd<DataType, Abi>;
using index_type = Kokkos::Experimental::simd<std::int32_t, Abi>;
using mask_type = typename simd_type::mask_type;
if constexpr (is_type_v<Kokkos::Experimental::simd<DataType, Abi>>) {
using simd_type = Kokkos::Experimental::simd<DataType, Abi>;
using index_type = Kokkos::Experimental::simd<std::int32_t, Abi>;
using mask_type = typename simd_type::mask_type;
std::size_t nlanes = simd_type::size();
DataType init[] = {11, 13, 17, 19, 23, 29, 31, 37};
simd_type src;
src.copy_from(init, Kokkos::Experimental::simd_flag_default);
std::size_t nlanes = simd_type::size();
DataType init[] = {11, 13, 17, 19, 23, 29, 31, 37,
53, 71, 79, 83, 89, 93, 97, 103};
simd_type src;
src.copy_from(init, Kokkos::Experimental::simd_flag_default);
for (std::size_t idx = 0; idx < nlanes; ++idx) {
mask_type mask(true);
mask[idx] = false;
for (std::size_t idx = 0; idx < nlanes; ++idx) {
mask_type mask(true);
mask[idx] = false;
DataType dst[8] = {0};
index_type index;
simd_type expected_result;
for (std::size_t i = 0; i < nlanes; ++i) {
dst[i] = (2 + (i * 2));
index[i] = i;
expected_result[i] = (mask[i]) ? src[index[i]] : dst[i];
DataType dst[simd_type::size()] = {0};
index_type index;
simd_type expected_result;
for (std::size_t i = 0; i < nlanes; ++i) {
dst[i] = (2 + (i * 2));
index[i] = i;
expected_result[i] = (mask[i]) ? src[index[i]] : dst[i];
}
where(mask, src).scatter_to(dst, index);
simd_type dst_simd;
dst_simd.copy_from(dst, Kokkos::Experimental::simd_flag_default);
device_check_equality(expected_result, dst_simd, nlanes);
}
where(mask, src).scatter_to(dst, index);
simd_type dst_simd;
dst_simd.copy_from(dst, Kokkos::Experimental::simd_flag_default);
device_check_equality(expected_result, dst_simd, nlanes);
}
}
@ -137,7 +146,8 @@ KOKKOS_INLINE_FUNCTION void device_check_where_expr_gather_from() {
using mask_type = typename simd_type::mask_type;
std::size_t nlanes = simd_type::size();
DataType src[] = {11, 13, 17, 19, 23, 29, 31, 37};
DataType src[] = {11, 13, 17, 19, 23, 29, 31, 37,
53, 71, 79, 83, 89, 93, 97, 103};
for (std::size_t idx = 0; idx < nlanes; ++idx) {
mask_type mask(true);