Update Kokkos library in LAMMPS to v3.7.0
This commit is contained in:
@ -43,8 +43,6 @@
|
||||
*/
|
||||
|
||||
#include <TestStdAlgorithmsCommon.hpp>
|
||||
#include <std_algorithms/Kokkos_BeginEnd.hpp>
|
||||
#include <std_algorithms/Kokkos_Numeric.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace Test {
|
||||
@ -78,10 +76,16 @@ struct UnifDist<int> {
|
||||
int operator()() { return m_dist(m_gen); }
|
||||
};
|
||||
|
||||
template <class ViewType>
|
||||
void fill_zero(ViewType view) {
|
||||
Kokkos::parallel_for(view.extent(0), FillZeroFunctor<ViewType>(view));
|
||||
}
|
||||
template <>
|
||||
struct UnifDist<CustomValueType> {
|
||||
using dist_type = std::uniform_real_distribution<double>;
|
||||
std::mt19937 m_gen;
|
||||
dist_type m_dist;
|
||||
|
||||
UnifDist() : m_dist(0.05, 1.2) { m_gen.seed(1034343); }
|
||||
|
||||
CustomValueType operator()() { return m_dist(m_gen); }
|
||||
};
|
||||
|
||||
template <class ViewType>
|
||||
void fill_view(ViewType dest_view, const std::string& name) {
|
||||
@ -181,15 +185,17 @@ void verify_data(ViewType1 data_view, // contains data
|
||||
// << gold_h(i) << " " << test_view_h(i) << " "
|
||||
// << std::abs(gold_h(i) - test_view_h(i)) << std::endl;
|
||||
if (std::is_same<gold_view_value_type, int>::value) {
|
||||
EXPECT_TRUE(gold_h(i) == test_view_h(i));
|
||||
EXPECT_EQ(gold_h(i), test_view_h(i));
|
||||
} else {
|
||||
const auto error = std::abs(gold_h(i) - test_view_h(i));
|
||||
const auto error =
|
||||
std::abs(static_cast<double>(gold_h(i) - test_view_h(i)));
|
||||
if (error > 1e-10) {
|
||||
std::cout << i << " " << std::setprecision(15) << data_view_h(i)
|
||||
<< " " << gold_h(i) << " " << test_view_h(i) << " "
|
||||
<< std::abs(gold_h(i) - test_view_h(i)) << std::endl;
|
||||
<< std::abs(static_cast<double>(gold_h(i) - test_view_h(i)))
|
||||
<< std::endl;
|
||||
}
|
||||
EXPECT_TRUE(error < 1e-10);
|
||||
EXPECT_LT(error, 1e-10);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -201,12 +207,6 @@ struct MultiplyFunctor {
|
||||
ValueType operator()(const ValueType& a, const ValueType& b) const {
|
||||
return (a * b);
|
||||
}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
ValueType operator()(const volatile ValueType& a,
|
||||
const volatile ValueType& b) const {
|
||||
return (a * b);
|
||||
}
|
||||
};
|
||||
|
||||
template <class ValueType>
|
||||
@ -215,12 +215,6 @@ struct SumFunctor {
|
||||
ValueType operator()(const ValueType& a, const ValueType& b) const {
|
||||
return (a + b);
|
||||
}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
ValueType operator()(const volatile ValueType& a,
|
||||
const volatile ValueType& b) const {
|
||||
return (a + b);
|
||||
}
|
||||
};
|
||||
|
||||
std::string value_type_to_string(int) { return "int"; }
|
||||
@ -247,7 +241,7 @@ void run_single_scenario_default_op(const InfoType& scenario_info,
|
||||
auto r = KE::exclusive_scan(exespace(), KE::cbegin(view_from),
|
||||
KE::cend(view_from), KE::begin(view_dest),
|
||||
init_value);
|
||||
EXPECT_TRUE(r == KE::end(view_dest));
|
||||
EXPECT_EQ(r, KE::end(view_dest));
|
||||
verify_data(view_from, view_dest, init_value, default_op());
|
||||
}
|
||||
|
||||
@ -256,14 +250,14 @@ void run_single_scenario_default_op(const InfoType& scenario_info,
|
||||
auto r = KE::exclusive_scan("label", exespace(), KE::cbegin(view_from),
|
||||
KE::cend(view_from), KE::begin(view_dest),
|
||||
init_value);
|
||||
EXPECT_TRUE(r == KE::end(view_dest));
|
||||
EXPECT_EQ(r, KE::end(view_dest));
|
||||
verify_data(view_from, view_dest, init_value, default_op());
|
||||
}
|
||||
|
||||
{
|
||||
fill_zero(view_dest);
|
||||
auto r = KE::exclusive_scan(exespace(), view_from, view_dest, init_value);
|
||||
EXPECT_TRUE(r == KE::end(view_dest));
|
||||
EXPECT_EQ(r, KE::end(view_dest));
|
||||
verify_data(view_from, view_dest, init_value, default_op());
|
||||
}
|
||||
|
||||
@ -271,7 +265,7 @@ void run_single_scenario_default_op(const InfoType& scenario_info,
|
||||
fill_zero(view_dest);
|
||||
auto r = KE::exclusive_scan("label", exespace(), view_from, view_dest,
|
||||
init_value);
|
||||
EXPECT_TRUE(r == KE::end(view_dest));
|
||||
EXPECT_EQ(r, KE::end(view_dest));
|
||||
verify_data(view_from, view_dest, init_value, default_op());
|
||||
}
|
||||
|
||||
@ -297,7 +291,7 @@ void run_single_scenario_custom_op(const InfoType& scenario_info,
|
||||
auto r = KE::exclusive_scan(exespace(), KE::cbegin(view_from),
|
||||
KE::cend(view_from), KE::begin(view_dest),
|
||||
init_value, bop);
|
||||
EXPECT_TRUE(r == KE::end(view_dest));
|
||||
EXPECT_EQ(r, KE::end(view_dest));
|
||||
verify_data(view_from, view_dest, init_value, bop);
|
||||
}
|
||||
|
||||
@ -306,7 +300,7 @@ void run_single_scenario_custom_op(const InfoType& scenario_info,
|
||||
auto r = KE::exclusive_scan("label", exespace(), KE::cbegin(view_from),
|
||||
KE::cend(view_from), KE::begin(view_dest),
|
||||
init_value, bop);
|
||||
EXPECT_TRUE(r == KE::end(view_dest));
|
||||
EXPECT_EQ(r, KE::end(view_dest));
|
||||
verify_data(view_from, view_dest, init_value, bop);
|
||||
}
|
||||
|
||||
@ -314,7 +308,7 @@ void run_single_scenario_custom_op(const InfoType& scenario_info,
|
||||
fill_zero(view_dest);
|
||||
auto r =
|
||||
KE::exclusive_scan(exespace(), view_from, view_dest, init_value, bop);
|
||||
EXPECT_TRUE(r == KE::end(view_dest));
|
||||
EXPECT_EQ(r, KE::end(view_dest));
|
||||
verify_data(view_from, view_dest, init_value, bop);
|
||||
}
|
||||
|
||||
@ -322,7 +316,7 @@ void run_single_scenario_custom_op(const InfoType& scenario_info,
|
||||
fill_zero(view_dest);
|
||||
auto r = KE::exclusive_scan("label", exespace(), view_from, view_dest,
|
||||
init_value, bop);
|
||||
EXPECT_TRUE(r == KE::end(view_dest));
|
||||
EXPECT_EQ(r, KE::end(view_dest));
|
||||
verify_data(view_from, view_dest, init_value, bop);
|
||||
}
|
||||
|
||||
@ -342,7 +336,7 @@ void run_exclusive_scan_all_scenarios() {
|
||||
run_single_scenario_default_op<Tag, ValueType>(it, ValueType{-2});
|
||||
run_single_scenario_default_op<Tag, ValueType>(it, ValueType{3});
|
||||
|
||||
#if not defined KOKKOS_ENABLE_OPENMPTARGET
|
||||
#if !defined KOKKOS_ENABLE_OPENMPTARGET
|
||||
// custom multiply op is only run for small views otherwise it overflows
|
||||
if (it.first == "small-a" || it.first == "small-b") {
|
||||
using custom_bop_t = MultiplyFunctor<ValueType>;
|
||||
@ -374,6 +368,8 @@ TEST(std_algorithms_numeric_ops_test, exclusive_scan) {
|
||||
run_exclusive_scan_all_scenarios<StridedThreeTag, double>();
|
||||
run_exclusive_scan_all_scenarios<DynamicTag, int>();
|
||||
run_exclusive_scan_all_scenarios<StridedThreeTag, int>();
|
||||
run_exclusive_scan_all_scenarios<DynamicTag, CustomValueType>();
|
||||
run_exclusive_scan_all_scenarios<StridedThreeTag, CustomValueType>();
|
||||
}
|
||||
|
||||
} // namespace EScan
|
||||
|
||||
Reference in New Issue
Block a user