Update Kokkos library in LAMMPS to v4.3.0
This commit is contained in:
@ -16,6 +16,7 @@
|
||||
|
||||
#include <TestStdAlgorithmsCommon.hpp>
|
||||
#include <utility>
|
||||
#include <iomanip>
|
||||
|
||||
namespace Test {
|
||||
namespace stdalgos {
|
||||
@ -160,24 +161,15 @@ void verify_data(ViewType1 data_view, // contains data
|
||||
create_mirror_view_and_copy(Kokkos::HostSpace(), test_view_dc);
|
||||
if (test_view_h.extent(0) > 0) {
|
||||
for (std::size_t i = 0; i < test_view_h.extent(0); ++i) {
|
||||
// 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;
|
||||
|
||||
if (std::is_same<gold_view_value_type, int>::value) {
|
||||
ASSERT_EQ(gold_h(i), test_view_h(i));
|
||||
} else {
|
||||
const auto error = std::abs(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;
|
||||
}
|
||||
EXPECT_LT(error, 1e-10);
|
||||
ASSERT_LT(error, 1e-10) << i << " " << std::setprecision(15) << error
|
||||
<< static_cast<double>(test_view_h(i)) << " "
|
||||
<< static_cast<double>(gold_h(i));
|
||||
}
|
||||
}
|
||||
// std::cout << " last el: " << test_view_h(test_view_h.extent(0)-1) <<
|
||||
// std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,17 +197,13 @@ void run_single_scenario(const InfoType& scenario_info, ValueType init_value,
|
||||
BinaryOp bop, UnaryOp uop) {
|
||||
const auto name = std::get<0>(scenario_info);
|
||||
const std::size_t view_ext = std::get<1>(scenario_info);
|
||||
// std::cout << "transform_exclusive_scan custom op: " << name << ", "
|
||||
// << view_tag_to_string(Tag{}) << ", "
|
||||
// << value_type_to_string(ValueType()) << ", "
|
||||
// << "init = " << init_value << std::endl;
|
||||
|
||||
auto view_dest =
|
||||
create_view<ValueType>(Tag{}, view_ext, "transform_exclusive_scan");
|
||||
auto view_from =
|
||||
create_view<ValueType>(Tag{}, view_ext, "transform_exclusive_scan");
|
||||
auto view_from = create_view<ValueType>(Tag{}, view_ext,
|
||||
"transform_exclusive_scan_view_from");
|
||||
fill_view(view_from, name);
|
||||
|
||||
auto view_dest = create_view<ValueType>(Tag{}, view_ext,
|
||||
"transform_exclusive_scan_view_dest");
|
||||
{
|
||||
fill_zero(view_dest);
|
||||
auto r = KE::transform_exclusive_scan(
|
||||
@ -253,6 +241,65 @@ void run_single_scenario(const InfoType& scenario_info, ValueType init_value,
|
||||
Kokkos::fence();
|
||||
}
|
||||
|
||||
template <class Tag, class ValueType, class InfoType, class BinaryOp,
|
||||
class UnaryOp>
|
||||
void run_single_scenario_inplace(const InfoType& scenario_info,
|
||||
ValueType init_value, BinaryOp bop,
|
||||
UnaryOp uop) {
|
||||
const auto name = std::get<0>(scenario_info);
|
||||
const std::size_t view_ext = std::get<1>(scenario_info);
|
||||
|
||||
// since here we call the in-place operation, we need to use two views:
|
||||
// view1: filled according to what the scenario asks for and is not modified
|
||||
// view2: filled according to what the scenario asks for and used for the
|
||||
// in-place op Therefore, after the op is done, view2 should contain the
|
||||
// result of doing exclusive scan NOTE: view2 is filled below every time
|
||||
// because the algorithm acts in place
|
||||
|
||||
auto view1 =
|
||||
create_view<ValueType>(Tag{}, view_ext, "transform_exclusive_scan_view1");
|
||||
fill_view(view1, name);
|
||||
|
||||
auto view2 =
|
||||
create_view<ValueType>(Tag{}, view_ext, "transform_exclusive_scan_view2");
|
||||
|
||||
{
|
||||
fill_view(view2, name);
|
||||
auto r = KE::transform_exclusive_scan(exespace(), KE::cbegin(view2),
|
||||
KE::cend(view2), KE::begin(view2),
|
||||
init_value, bop, uop);
|
||||
ASSERT_EQ(r, KE::end(view2));
|
||||
verify_data(view1, view2, init_value, bop, uop);
|
||||
}
|
||||
|
||||
{
|
||||
fill_view(view2, name);
|
||||
auto r = KE::transform_exclusive_scan(
|
||||
"label", exespace(), KE::cbegin(view2), KE::cend(view2),
|
||||
KE::begin(view2), init_value, bop, uop);
|
||||
ASSERT_EQ(r, KE::end(view2));
|
||||
verify_data(view1, view2, init_value, bop, uop);
|
||||
}
|
||||
|
||||
{
|
||||
fill_view(view2, name);
|
||||
auto r = KE::transform_exclusive_scan(exespace(), view2, view2, init_value,
|
||||
bop, uop);
|
||||
ASSERT_EQ(r, KE::end(view2));
|
||||
verify_data(view1, view2, init_value, bop, uop);
|
||||
}
|
||||
|
||||
{
|
||||
fill_view(view2, name);
|
||||
auto r = KE::transform_exclusive_scan("label", exespace(), view2, view2,
|
||||
init_value, bop, uop);
|
||||
ASSERT_EQ(r, KE::end(view2));
|
||||
verify_data(view1, view2, init_value, bop, uop);
|
||||
}
|
||||
|
||||
Kokkos::fence();
|
||||
}
|
||||
|
||||
template <class Tag, class ValueType>
|
||||
void run_all_scenarios() {
|
||||
const std::map<std::string, std::size_t> scenarios = {
|
||||
@ -267,6 +314,11 @@ void run_all_scenarios() {
|
||||
run_single_scenario<Tag, ValueType>(it, ValueType{1}, bop_t(), uop_t());
|
||||
run_single_scenario<Tag, ValueType>(it, ValueType{-2}, bop_t(), uop_t());
|
||||
run_single_scenario<Tag, ValueType>(it, ValueType{3}, bop_t(), uop_t());
|
||||
|
||||
run_single_scenario_inplace<Tag, ValueType>(it, ValueType{0}, bop_t(),
|
||||
uop_t());
|
||||
run_single_scenario_inplace<Tag, ValueType>(it, ValueType{-2}, bop_t(),
|
||||
uop_t());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user