Update Kokkos library in LAMMPS to v3.6.0

This commit is contained in:
Stan Gerald Moore
2022-05-05 11:44:47 -06:00
parent bd4bbbddbe
commit b79c0bc7b4
380 changed files with 41928 additions and 8786 deletions

View File

@ -5,15 +5,10 @@ KOKKOS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../src )
KOKKOS_INCLUDE_DIRECTORIES(${KOKKOS_SOURCE_DIR}/core/unit_test/category_files)
foreach(Tag Threads;Serial;OpenMP;HPX;Cuda;HIP;SYCL)
# Because there is always an exception to the rule
if(Tag STREQUAL "Threads")
set(DEVICE "PTHREAD")
else()
string(TOUPPER ${Tag} DEVICE)
endif()
string(TOUPPER ${Tag} DEVICE)
string(TOLOWER ${Tag} dir)
# Add test for that backend if it is enabled
if(Kokkos_ENABLE_${DEVICE})
if(KOKKOS_ENABLE_${DEVICE})
set(UnitTestSources UnitTestMain.cpp)
set(dir ${CMAKE_CURRENT_BINARY_DIR}/${dir})
file(MAKE_DIRECTORY ${dir})
@ -28,6 +23,7 @@ foreach(Tag Threads;Serial;OpenMP;HPX;Cuda;HIP;SYCL)
OffsetView
ScatterView
StaticCrsGraph
WithoutInitializing
UnorderedMap
Vector
ViewCtorPropEmbeddedDim
@ -42,6 +38,11 @@ foreach(Tag Threads;Serial;OpenMP;HPX;Cuda;HIP;SYCL)
configure_file(${dir}/dummy.cpp ${file})
list(APPEND UnitTestSources ${file})
endforeach()
#fatal error C1128: number of sections exceeded object file format limit: compile with /bigobj
if(KOKKOS_ENABLE_CUDA AND WIN32)
LIST(REMOVE_ITEM UnitTestSources ${dir}/TestCuda_DynViewAPI_generic.cpp)
endif()
KOKKOS_ADD_EXECUTABLE_AND_TEST(UnitTest_${Tag} SOURCES ${UnitTestSources})
endif()
endforeach()

View File

@ -60,7 +60,7 @@ ifeq ($(KOKKOS_INTERNAL_USE_CUDA), 1)
TEST_TARGETS += test-cuda
endif
ifeq ($(KOKKOS_INTERNAL_USE_PTHREADS), 1)
ifeq ($(KOKKOS_INTERNAL_USE_THREADS), 1)
OBJ_THREADS = UnitTestMain.o gtest-all.o
OBJ_THREADS += TestThreads_Bitset.o
OBJ_THREADS += TestThreads_DualView.o

View File

@ -258,7 +258,7 @@ struct test_dual_view_deep_copy {
}
};
template <typename Scalar, class Device>
template <typename Scalar, class Device, bool Initialize>
struct test_dualview_resize {
using scalar_type = Scalar;
using execution_space = Device;
@ -274,7 +274,10 @@ struct test_dualview_resize {
/* Covers case "Resize on Device" */
a.modify_device();
Kokkos::resize(a, factor * n, factor * m);
if (Initialize)
Kokkos::resize(Kokkos::WithoutInitializing, a, factor * n, factor * m);
else
Kokkos::resize(a, factor * n, factor * m);
ASSERT_EQ(a.extent(0), n * factor);
ASSERT_EQ(a.extent(1), m * factor);
@ -300,12 +303,15 @@ struct test_dualview_resize {
// Check
ASSERT_EQ(a_h_sum, a_d_sum);
ASSERT_EQ(a_h_sum, a.extent(0) * a.extent(1));
ASSERT_EQ(a_h_sum, scalar_type(a.extent(0) * a.extent(1)));
/* Covers case "Resize on Host" */
a.modify_host();
Kokkos::resize(a, n / factor, m / factor);
if (Initialize)
Kokkos::resize(Kokkos::WithoutInitializing, a, n / factor, m / factor);
else
Kokkos::resize(a, n / factor, m / factor);
ASSERT_EQ(a.extent(0), n / factor);
ASSERT_EQ(a.extent(1), m / factor);
@ -330,7 +336,7 @@ struct test_dualview_resize {
}
// Check
ASSERT_EQ(a_h_sum, a.extent(0) * a.extent(1));
ASSERT_EQ(a_h_sum, scalar_type(a.extent(0) * a.extent(1)));
ASSERT_EQ(a_h_sum, a_d_sum);
} // end run_me
@ -340,7 +346,7 @@ struct test_dualview_resize {
}
};
template <typename Scalar, class Device>
template <typename Scalar, class Device, bool Initialize>
struct test_dualview_realloc {
using scalar_type = Scalar;
using execution_space = Device;
@ -351,7 +357,10 @@ struct test_dualview_realloc {
const unsigned int m = 5;
ViewType a("A", n, m);
Kokkos::realloc(a, n, m);
if (Initialize)
Kokkos::realloc(Kokkos::WithoutInitializing, a, n, m);
else
Kokkos::realloc(a, n, m);
Kokkos::deep_copy(a.d_view, 1);
a.modify_device();
@ -375,7 +384,7 @@ struct test_dualview_realloc {
}
// Check
ASSERT_EQ(a_h_sum, a.extent(0) * a.extent(1));
ASSERT_EQ(a_h_sum, scalar_type(a.extent(0) * a.extent(1)));
ASSERT_EQ(a_h_sum, a_d_sum);
} // end run_me
@ -405,12 +414,14 @@ void test_dualview_deep_copy() {
template <typename Scalar, typename Device>
void test_dualview_realloc() {
Impl::test_dualview_realloc<Scalar, Device>();
Impl::test_dualview_realloc<Scalar, Device, false>();
Impl::test_dualview_realloc<Scalar, Device, true>();
}
template <typename Scalar, typename Device>
void test_dualview_resize() {
Impl::test_dualview_resize<Scalar, Device>();
Impl::test_dualview_resize<Scalar, Device, false>();
Impl::test_dualview_resize<Scalar, Device, true>();
}
TEST(TEST_CATEGORY, dualview_combination) {

View File

@ -712,7 +712,8 @@ class TestDynViewAPI {
using host_view_space = typename View0::host_mirror_space;
static void run_tests() {
run_test_resize_realloc();
run_test_resize_realloc<false>();
run_test_resize_realloc<true>();
run_test_mirror();
run_test_mirror_and_copy();
run_test_scalar();
@ -722,6 +723,7 @@ class TestDynViewAPI {
run_test_subview();
run_test_subview_strided();
run_test_vector();
run_test_as_view_of_rank_n();
}
static void run_operator_test_rank12345() {
@ -738,21 +740,28 @@ class TestDynViewAPI {
TestViewOperator_LeftAndRight<int, device, 6>::testit(2, 3, 4, 2, 3, 4);
}
template <bool Initialize>
static void run_test_resize_realloc() {
dView0 drv0("drv0", 10, 20, 30);
ASSERT_EQ(drv0.rank(), 3);
ASSERT_EQ(drv0.rank(), 3u);
Kokkos::resize(drv0, 5, 10);
ASSERT_EQ(drv0.rank(), 2);
ASSERT_EQ(drv0.extent(0), 5);
ASSERT_EQ(drv0.extent(1), 10);
ASSERT_EQ(drv0.extent(2), 1);
if (Initialize)
Kokkos::resize(Kokkos::WithoutInitializing, drv0, 5, 10);
else
Kokkos::resize(drv0, 5, 10);
ASSERT_EQ(drv0.rank(), 2u);
ASSERT_EQ(drv0.extent(0), 5u);
ASSERT_EQ(drv0.extent(1), 10u);
ASSERT_EQ(drv0.extent(2), 1u);
Kokkos::realloc(drv0, 10, 20);
ASSERT_EQ(drv0.rank(), 2);
ASSERT_EQ(drv0.extent(0), 10);
ASSERT_EQ(drv0.extent(1), 20);
ASSERT_EQ(drv0.extent(2), 1);
if (Initialize)
Kokkos::realloc(Kokkos::WithoutInitializing, drv0, 10, 20);
else
Kokkos::realloc(drv0, 10, 20);
ASSERT_EQ(drv0.rank(), 2u);
ASSERT_EQ(drv0.extent(0), 10u);
ASSERT_EQ(drv0.extent(1), 20u);
ASSERT_EQ(drv0.extent(2), 1u);
}
static void run_test_mirror() {
@ -961,6 +970,199 @@ class TestDynViewAPI {
}
}
static void run_test_as_view_of_rank_n() {
Kokkos::View<int, Kokkos::HostSpace> error_flag_host("error_flag");
error_flag_host() = 0;
auto error_flag =
Kokkos::create_mirror_view_and_copy(DeviceType(), error_flag_host);
dView0 d("d");
#if defined(KOKKOS_ENABLE_CXX11_DISPATCH_LAMBDA)
// Rank 0
Kokkos::resize(d);
auto policy0 = Kokkos::RangePolicy<DeviceType>(DeviceType(), 0, 1);
View0 v0 = Kokkos::Impl::as_view_of_rank_n<0>(d);
// Assign values after calling as_view_of_rank_n() function under
// test to ensure aliasing
Kokkos::parallel_for(
policy0, KOKKOS_LAMBDA(int) { d() = 13; });
ASSERT_EQ(v0.size(), d.size());
ASSERT_EQ(v0.data(), d.data());
Kokkos::parallel_for(
policy0, KOKKOS_LAMBDA(int) {
if (d() != v0()) error_flag() = 1;
});
Kokkos::deep_copy(error_flag_host, error_flag);
ASSERT_EQ(error_flag_host(), 0);
// Rank 1
Kokkos::resize(d, 1);
auto policy1 =
Kokkos::RangePolicy<DeviceType>(DeviceType(), 0, d.extent(0));
View1 v1 = Kokkos::Impl::as_view_of_rank_n<1>(d);
Kokkos::parallel_for(
policy1, KOKKOS_LAMBDA(int i0) { d(i0) = i0; });
for (unsigned int rank = 0; rank < d.rank(); ++rank)
ASSERT_EQ(v1.extent(rank), d.extent(rank));
ASSERT_EQ(v1.data(), d.data());
Kokkos::parallel_for(
policy1, KOKKOS_LAMBDA(int i0) {
if (d(i0) != v1(i0)) error_flag() = 1;
});
Kokkos::deep_copy(error_flag_host, error_flag);
ASSERT_EQ(error_flag_host(), 0);
// Rank 2
Kokkos::resize(d, 1, 2);
auto policy2 = Kokkos::MDRangePolicy<DeviceType, Kokkos::Rank<2>>(
{0, 0}, {d.extent(0), d.extent(1)});
View2 v2 = Kokkos::Impl::as_view_of_rank_n<2>(d);
Kokkos::parallel_for(
policy2, KOKKOS_LAMBDA(int i0, int i1) { d(i0, i1) = i0 + 10 * i1; });
for (unsigned int rank = 0; rank < d.rank(); ++rank)
ASSERT_EQ(v2.extent(rank), d.extent(rank));
ASSERT_EQ(v2.data(), d.data());
Kokkos::parallel_for(
policy2, KOKKOS_LAMBDA(int i0, int i1) {
if (d(i0, i1) != v2(i0, i1)) error_flag() = 1;
});
Kokkos::deep_copy(error_flag_host, error_flag);
ASSERT_EQ(error_flag_host(), 0);
// Rank 3
Kokkos::resize(d, 1, 2, 3);
auto policy3 = Kokkos::MDRangePolicy<DeviceType, Kokkos::Rank<3>>(
{0, 0, 0}, {d.extent(0), d.extent(1), d.extent(2)});
View3 v3 = Kokkos::Impl::as_view_of_rank_n<3>(d);
Kokkos::parallel_for(
policy3, KOKKOS_LAMBDA(int i0, int i1, int i2) {
d(i0, i1, i2) = i0 + 10 * i1 + 100 * i2;
});
for (unsigned int rank = 0; rank < d.rank(); ++rank)
ASSERT_EQ(v3.extent(rank), d.extent(rank));
ASSERT_EQ(v3.data(), d.data());
Kokkos::parallel_for(
policy3, KOKKOS_LAMBDA(int i0, int i1, int i2) {
if (d(i0, i1, i2) != v3(i0, i1, i2)) error_flag() = 1;
});
Kokkos::deep_copy(error_flag_host, error_flag);
ASSERT_EQ(error_flag_host(), 0);
// Rank 4
Kokkos::resize(d, 1, 2, 3, 4);
auto policy4 = Kokkos::MDRangePolicy<DeviceType, Kokkos::Rank<4>>(
{0, 0, 0, 0}, {d.extent(0), d.extent(1), d.extent(2), d.extent(3)});
View4 v4 = Kokkos::Impl::as_view_of_rank_n<4>(d);
Kokkos::parallel_for(
policy4, KOKKOS_LAMBDA(int i0, int i1, int i2, int i3) {
d(i0, i1, i2, i3) = i0 + 10 * i1 + 100 * i2 + 1000 * i3;
});
for (unsigned int rank = 0; rank < d.rank(); ++rank)
ASSERT_EQ(v4.extent(rank), d.extent(rank));
ASSERT_EQ(v4.data(), d.data());
Kokkos::parallel_for(
policy4, KOKKOS_LAMBDA(int i0, int i1, int i2, int i3) {
if (d(i0, i1, i2, i3) != v4(i0, i1, i2, i3)) error_flag() = 1;
});
Kokkos::deep_copy(error_flag_host, error_flag);
ASSERT_EQ(error_flag_host(), 0);
// Rank 5
Kokkos::resize(d, 1, 2, 3, 4, 5);
auto policy5 = Kokkos::MDRangePolicy<DeviceType, Kokkos::Rank<5>>(
{0, 0, 0, 0, 0},
{d.extent(0), d.extent(1), d.extent(2), d.extent(3), d.extent(4)});
View5 v5 = Kokkos::Impl::as_view_of_rank_n<5>(d);
Kokkos::parallel_for(
policy5, KOKKOS_LAMBDA(int i0, int i1, int i2, int i3, int i4) {
d(i0, i1, i2, i3, i4) =
i0 + 10 * i1 + 100 * i2 + 1000 * i3 + 10000 * i4;
});
for (unsigned int rank = 0; rank < d.rank(); ++rank)
ASSERT_EQ(v5.extent(rank), d.extent(rank));
ASSERT_EQ(v5.data(), d.data());
Kokkos::parallel_for(
policy5, KOKKOS_LAMBDA(int i0, int i1, int i2, int i3, int i4) {
if (d(i0, i1, i2, i3, i4) != v5(i0, i1, i2, i3, i4)) error_flag() = 1;
});
Kokkos::deep_copy(error_flag_host, error_flag);
ASSERT_EQ(error_flag_host(), 0);
// Rank 6
Kokkos::resize(d, 1, 2, 3, 4, 5, 6);
auto policy6 = Kokkos::MDRangePolicy<DeviceType, Kokkos::Rank<6>>(
{0, 0, 0, 0, 0, 0}, {d.extent(0), d.extent(1), d.extent(2), d.extent(3),
d.extent(4), d.extent(5)});
View6 v6 = Kokkos::Impl::as_view_of_rank_n<6>(d);
Kokkos::parallel_for(
policy6, KOKKOS_LAMBDA(int i0, int i1, int i2, int i3, int i4, int i5) {
d(i0, i1, i2, i3, i4, i5) =
i0 + 10 * i1 + 100 * i2 + 1000 * i3 + 10000 * i4 + 100000 * i5;
});
for (unsigned int rank = 0; rank < d.rank(); ++rank)
ASSERT_EQ(v6.extent(rank), d.extent(rank));
ASSERT_EQ(v6.data(), d.data());
Kokkos::parallel_for(
policy6, KOKKOS_LAMBDA(int i0, int i1, int i2, int i3, int i4, int i5) {
if (d(i0, i1, i2, i3, i4, i5) != v6(i0, i1, i2, i3, i4, i5))
error_flag() = 1;
});
Kokkos::deep_copy(error_flag_host, error_flag);
ASSERT_EQ(error_flag_host(), 0);
// Rank 7
Kokkos::resize(d, 1, 2, 3, 4, 5, 6, 7);
// MDRangePolicy only accepts Rank < 7
#if 0
auto policy7 = Kokkos::MDRangePolicy<DeviceType, Kokkos::Rank<7>>(
{0, 0, 0, 0, 0, 0, 0},
{d.extent(0), d.extent(1), d.extent(2), d.extent(3), d.extent(4),
d.extent(5), d.extent(6)});
View7 v7 = Kokkos::Impl::as_view_of_rank_n<7>(d);
Kokkos::parallel_for(
policy7,
KOKKOS_LAMBDA(int i0, int i1, int i2, int i3, int i4, int i5, int i6) {
d(i0, i1, i2, i3, i4, i5, i6) = i0 + 10 * i1 + 100 * i2 + 1000 * i3 +
10000 * i4 + 100000 * i5 +
1000000 * i6;
});
for (unsigned int rank = 0; rank < d.rank(); ++rank)
ASSERT_EQ(v7.extent(rank), d.extent(rank));
ASSERT_EQ(v7.data(), d.data());
Kokkos::parallel_for(
policy7,
KOKKOS_LAMBDA(int i0, int i1, int i2, int i3, int i4, int i5, int i6) {
if (d(i0, i1, i2, i3, i4, i5, i6) != v7(i0, i1, i2, i3, i4, i5, i6))
error_flag() = 1;
});
Kokkos::deep_copy(error_flag_host, error_flag);
ASSERT_EQ(error_flag_host(), 0);
#endif // MDRangePolict Rank < 7
#endif // defined(KOKKOS_ENABLE_CXX11_DISPATCH_LAMBDA)
// Error checking test
EXPECT_ANY_THROW({ auto v_copy = Kokkos::Impl::as_view_of_rank_n<2>(d); });
}
static void run_test_scalar() {
using hView0 = typename dView0::HostMirror; // HostMirror of DynRankView is
// a DynRankView
@ -1071,10 +1273,10 @@ class TestDynViewAPI {
dView0 d_uninitialized(
Kokkos::view_alloc(Kokkos::WithoutInitializing, "uninit"), 10, 20);
ASSERT_NE(d_uninitialized.data(), nullptr);
ASSERT_EQ(d_uninitialized.rank(), 2);
ASSERT_EQ(d_uninitialized.extent(0), 10);
ASSERT_EQ(d_uninitialized.extent(1), 20);
ASSERT_EQ(d_uninitialized.extent(2), 1);
ASSERT_EQ(d_uninitialized.rank(), 2u);
ASSERT_EQ(d_uninitialized.extent(0), 10u);
ASSERT_EQ(d_uninitialized.extent(1), 20u);
ASSERT_EQ(d_uninitialized.extent(2), 1u);
dView0 dx, dy, dz;
hView0 hx, hy, hz;
@ -1107,8 +1309,8 @@ class TestDynViewAPI {
ASSERT_EQ(dy.extent(0), unsigned(N1)); // Okay with UVM
ASSERT_EQ(hx.extent(0), unsigned(N1));
ASSERT_EQ(hy.extent(0), unsigned(N1));
ASSERT_EQ(dx.rank(), 3); // Okay with UVM
ASSERT_EQ(hx.rank(), 3);
ASSERT_EQ(dx.rank(), 3u); // Okay with UVM
ASSERT_EQ(hx.rank(), 3u);
dx = dView0("dx", N0, N1, N2, N3);
dy = dView0("dy", N0, N1, N2, N3);
@ -1119,15 +1321,15 @@ class TestDynViewAPI {
ASSERT_EQ(dy.extent(0), unsigned(N0));
ASSERT_EQ(hx.extent(0), unsigned(N0));
ASSERT_EQ(hy.extent(0), unsigned(N0));
ASSERT_EQ(dx.rank(), 4);
ASSERT_EQ(dy.rank(), 4);
ASSERT_EQ(hx.rank(), 4);
ASSERT_EQ(hy.rank(), 4);
ASSERT_EQ(dx.rank(), 4u);
ASSERT_EQ(dy.rank(), 4u);
ASSERT_EQ(hx.rank(), 4u);
ASSERT_EQ(hy.rank(), 4u);
ASSERT_EQ(dx.use_count(), size_t(1));
ASSERT_EQ(dx.use_count(), 1);
dView0_unmanaged unmanaged_dx = dx;
ASSERT_EQ(dx.use_count(), size_t(1));
ASSERT_EQ(dx.use_count(), 1);
dView0_unmanaged unmanaged_from_ptr_dx = dView0_unmanaged(
dx.data(), dx.extent(0), dx.extent(1), dx.extent(2), dx.extent(3));
@ -1139,24 +1341,24 @@ class TestDynViewAPI {
}
const_dView0 const_dx = dx;
ASSERT_EQ(dx.use_count(), size_t(2));
ASSERT_EQ(dx.use_count(), 2);
{
const_dView0 const_dx2;
const_dx2 = const_dx;
ASSERT_EQ(dx.use_count(), size_t(3));
ASSERT_EQ(dx.use_count(), 3);
const_dx2 = dy;
ASSERT_EQ(dx.use_count(), size_t(2));
ASSERT_EQ(dx.use_count(), 2);
const_dView0 const_dx3(dx);
ASSERT_EQ(dx.use_count(), size_t(3));
ASSERT_EQ(dx.use_count(), 3);
dView0_unmanaged dx4_unmanaged(dx);
ASSERT_EQ(dx.use_count(), size_t(3));
ASSERT_EQ(dx.use_count(), 3);
}
ASSERT_EQ(dx.use_count(), size_t(2));
ASSERT_EQ(dx.use_count(), 2);
ASSERT_NE(dx.data(), nullptr);
ASSERT_NE(const_dx.data(), nullptr);
@ -1336,18 +1538,18 @@ class TestDynViewAPI {
// View - DynRankView Interoperability tests
// deep_copy from view to dynrankview
const int testdim = 4;
constexpr size_t testdim = 4;
dView0 dxx("dxx", testdim);
View1 vxx("vxx", testdim);
auto hvxx = Kokkos::create_mirror_view(vxx);
for (int i = 0; i < testdim; ++i) {
for (size_t i = 0; i < testdim; ++i) {
hvxx(i) = i;
}
Kokkos::deep_copy(vxx, hvxx);
Kokkos::deep_copy(dxx, vxx);
auto hdxx = Kokkos::create_mirror_view(dxx);
Kokkos::deep_copy(hdxx, dxx);
for (int i = 0; i < testdim; ++i) {
for (size_t i = 0; i < testdim; ++i) {
ASSERT_EQ(hvxx(i), hdxx(i));
}
@ -1362,7 +1564,7 @@ class TestDynViewAPI {
ASSERT_EQ(rank(hdxx), rank(hvdxx));
ASSERT_EQ(hvdxx.extent(0), testdim);
ASSERT_EQ(hdxx.extent(0), hvdxx.extent(0));
for (int i = 0; i < testdim; ++i) {
for (size_t i = 0; i < testdim; ++i) {
ASSERT_EQ(hvxx(i), hvdxx(i));
}
}
@ -1432,51 +1634,51 @@ class TestDynViewAPI {
unsigned order[] = {6, 5, 4, 3, 2, 1, 0},
dimen[] = {N0, N1, N2, 2, 2, 2, 2}; // LayoutRight equivalent
sdView d7("d7", Kokkos::LayoutStride::order_dimensions(7, order, dimen));
ASSERT_EQ(d7.rank(), 7);
ASSERT_EQ(d7.rank(), 7u);
sdView ds0 = Kokkos::subdynrankview(d7, 1, 1, 1, 1, 1, 1, 1);
ASSERT_EQ(ds0.rank(), 0);
ASSERT_EQ(ds0.rank(), 0u);
// Basic test - ALL
sdView dsALL = Kokkos::subdynrankview(
d7, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL(),
Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
ASSERT_EQ(dsALL.rank(), 7);
ASSERT_EQ(dsALL.rank(), 7u);
// Send a value to final rank returning rank 6 subview
sdView dsm1 =
Kokkos::subdynrankview(d7, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL(),
Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL(), 1);
ASSERT_EQ(dsm1.rank(), 6);
ASSERT_EQ(dsm1.rank(), 6u);
// Send a std::pair as argument to a rank
sdView dssp = Kokkos::subdynrankview(
d7, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL(),
Kokkos::ALL(), Kokkos::ALL(), std::pair<unsigned, unsigned>(1, 2));
ASSERT_EQ(dssp.rank(), 7);
ASSERT_EQ(dssp.rank(), 7u);
// Send a kokkos::pair as argument to a rank; take default layout as input
dView0 dd0("dd0", N0, N1, N2, 2, 2, 2, 2); // default layout
ASSERT_EQ(dd0.rank(), 7);
ASSERT_EQ(dd0.rank(), 7u);
sdView dtkp = Kokkos::subdynrankview(
dd0, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL(),
Kokkos::ALL(), Kokkos::ALL(), Kokkos::pair<unsigned, unsigned>(0, 1));
ASSERT_EQ(dtkp.rank(), 7);
ASSERT_EQ(dtkp.rank(), 7u);
// Return rank 7 subview, taking a pair as one argument, layout stride input
sdView ds7 = Kokkos::subdynrankview(
d7, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL(),
Kokkos::ALL(), Kokkos::ALL(), Kokkos::pair<unsigned, unsigned>(0, 1));
ASSERT_EQ(ds7.rank(), 7);
ASSERT_EQ(ds7.rank(), 7u);
// Default Layout DynRankView
dView dv6("dv6", N0, N1, N2, N3, 2, 2);
ASSERT_EQ(dv6.rank(), 6);
ASSERT_EQ(dv6.rank(), 6u);
// DynRankView with LayoutRight
using drView = Kokkos::DynRankView<T, Kokkos::LayoutRight, device>;
drView dr5("dr5", N0, N1, N2, 2, 2);
ASSERT_EQ(dr5.rank(), 5);
ASSERT_EQ(dr5.rank(), 5u);
// LayoutStride but arranged as LayoutRight
// NOTE: unused arg_layout dimensions must be set toKOKKOS_INVALID_INDEX so
@ -1489,7 +1691,7 @@ class TestDynViewAPI {
ls.dimension[6] = KOKKOS_INVALID_INDEX;
ls.dimension[7] = KOKKOS_INVALID_INDEX;
sdView d5("d5", ls);
ASSERT_EQ(d5.rank(), 5);
ASSERT_EQ(d5.rank(), 5u);
// LayoutStride arranged as LayoutRight - commented out as example that
// fails unit test
@ -1522,7 +1724,7 @@ class TestDynViewAPI {
sdView ds5 = Kokkos::subdynrankview(d5, Kokkos::ALL(), Kokkos::ALL(),
Kokkos::ALL(), Kokkos::ALL(),
Kokkos::pair<unsigned, unsigned>(0, 1));
ASSERT_EQ(ds5.rank(), 5);
ASSERT_EQ(ds5.rank(), 5u);
// Pass in extra ALL arguments beyond the rank of the DynRank View.
// This behavior is allowed - ignore the extra ALL arguments when
@ -1554,7 +1756,7 @@ class TestDynViewAPI {
Kokkos::ALL(), 0, Kokkos::ALL());
ASSERT_EQ(ds4.rank(), ds4plus.rank());
ASSERT_EQ(ds4.rank(), 4);
ASSERT_EQ(ds4.rank(), 4u);
ASSERT_EQ(ds4.extent(0), ds4plus.extent(0));
ASSERT_EQ(ds4.extent(4), ds4plus.extent(4));
ASSERT_EQ(ds4.extent(5), ds4plus.extent(5));
@ -1601,8 +1803,8 @@ class TestDynViewAPI {
ASSERT_EQ(yl4.extent(1), xl4.extent(3));
ASSERT_EQ(yr4.extent(0), xr4.extent(1));
ASSERT_EQ(yr4.extent(1), xr4.extent(3));
ASSERT_EQ(yl4.rank(), 2);
ASSERT_EQ(yr4.rank(), 2);
ASSERT_EQ(yl4.rank(), 2u);
ASSERT_EQ(yr4.rank(), 2u);
ASSERT_EQ(&yl4(4, 4) - &xl4(1, 4, 2, 4), 0);
ASSERT_EQ(&yr4(4, 4) - &xr4(1, 4, 2, 4), 0);

View File

@ -93,7 +93,7 @@ struct TestDynamicView {
ASSERT_TRUE(d3.is_allocated());
}
view_type da("da", 1024, arg_total_size);
ASSERT_EQ(da.size(), 0);
ASSERT_EQ(da.size(), 0u);
// Init
unsigned da_size = arg_total_size / 8;
da.resize_serial(da_size);
@ -145,7 +145,7 @@ struct TestDynamicView {
// Case 2: min_chunk_size is NOT a power of 2
{
view_type da("da", 1023, arg_total_size);
ASSERT_EQ(da.size(), 0);
ASSERT_EQ(da.size(), 0u);
// Init
unsigned da_size = arg_total_size / 8;
da.resize_serial(da_size);
@ -197,7 +197,7 @@ struct TestDynamicView {
// Case 3: resize reduces the size
{
view_type da("da", 1023, arg_total_size);
ASSERT_EQ(da.size(), 0);
ASSERT_EQ(da.size(), 0u);
// Init
unsigned da_size = arg_total_size / 2;
da.resize_serial(da_size);

View File

@ -50,10 +50,6 @@
#include <Kokkos_Core.hpp>
#include <Kokkos_ErrorReporter.hpp>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
namespace Test {
// Just save the data in the report. Informative text goes in the
@ -174,7 +170,8 @@ struct ErrorReporterDriver : public ErrorReporterDriverBase<DeviceType> {
KOKKOS_INLINE_FUNCTION
void operator()(const int work_idx) const {
if (driver_base::error_condition(work_idx)) {
double val = M_PI * static_cast<double>(work_idx);
double val =
Kokkos::Experimental::pi_v<double> * static_cast<double>(work_idx);
typename driver_base::report_type report = {work_idx, -2 * work_idx, val};
driver_base::m_errorReporter.add_report(work_idx, report);
}
@ -200,7 +197,8 @@ struct ErrorReporterDriverUseLambda
Kokkos::RangePolicy<execution_space>(0, test_size),
KOKKOS_CLASS_LAMBDA(const int work_idx) {
if (driver_base::error_condition(work_idx)) {
double val = M_PI * static_cast<double>(work_idx);
double val = Kokkos::Experimental::pi_v<double> *
static_cast<double>(work_idx);
typename driver_base::report_type report = {work_idx, -2 * work_idx,
val};
driver_base::m_errorReporter.add_report(work_idx, report);
@ -224,7 +222,8 @@ struct ErrorReporterDriverNativeOpenMP
#pragma omp parallel for
for (int work_idx = 0; work_idx < test_size; ++work_idx) {
if (driver_base::error_condition(work_idx)) {
double val = M_PI * static_cast<double>(work_idx);
double val =
Kokkos::Experimental::pi_v<double> * static_cast<double>(work_idx);
typename driver_base::report_type report = {work_idx, -2 * work_idx,
val};
driver_base::m_errorReporter.add_report(work_idx, report);

View File

@ -91,8 +91,8 @@ void test_offsetview_construction() {
ASSERT_EQ(ov.begin(1), -2);
ASSERT_EQ(ov.end(1), 3);
ASSERT_EQ(ov.extent(0), 5);
ASSERT_EQ(ov.extent(1), 5);
ASSERT_EQ(ov.extent(0), 5u);
ASSERT_EQ(ov.extent(1), 5u);
#if defined(KOKKOS_ENABLE_CUDA_LAMBDA) || !defined(KOKKOS_ENABLE_CUDA)
{
@ -357,7 +357,6 @@ void test_offsetview_unmanaged_construction() {
ASSERT_EQ(bb, ii);
}
#ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST
{
using offset_view_type = Kokkos::Experimental::OffsetView<Scalar*, Device>;
@ -397,7 +396,6 @@ void test_offsetview_unmanaged_construction() {
ASSERT_THROW(offset_view_type(&s, {0, 0, 0}, {1, 1, 1}),
std::runtime_error);
}
#endif // KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST
}
template <typename Scalar, typename Device>

View File

@ -67,6 +67,8 @@ struct test_scatter_view_impl_cls<DeviceType, Layout, Duplication, Contribution,
using orig_view_type = Kokkos::View<NumberType * [12], Layout, DeviceType>;
using size_type = typename Kokkos::HostSpace::size_type;
scatter_view_type scatter_view;
int scatterSize;
@ -79,21 +81,7 @@ struct test_scatter_view_impl_cls<DeviceType, Layout, Duplication, Contribution,
auto host_view =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), orig);
Kokkos::fence();
for (typename decltype(host_view)::size_type i = 0; i < host_view.extent(0);
++i) {
host_view(i, 0) = 0.0;
host_view(i, 1) = 0.0;
host_view(i, 2) = 0.0;
host_view(i, 3) = 0.0;
host_view(i, 4) = 0.0;
host_view(i, 5) = 0.0;
host_view(i, 6) = 0.0;
host_view(i, 7) = 0.0;
host_view(i, 8) = 0.0;
host_view(i, 9) = 0.0;
host_view(i, 10) = 0.0;
host_view(i, 11) = 0.0;
}
Kokkos::deep_copy(host_view, 0);
Kokkos::fence();
Kokkos::deep_copy(orig, host_view);
}
@ -171,34 +159,40 @@ struct test_scatter_view_impl_cls<DeviceType, Layout, Duplication, Contribution,
auto host_view =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), orig);
Kokkos::fence();
for (typename decltype(host_view)::size_type i = 0; i < host_view.extent(0);
++i) {
auto val0 = host_view(i, 0);
auto val1 = host_view(i, 1);
auto val2 = host_view(i, 2);
auto val3 = host_view(i, 3);
auto val4 = host_view(i, 4);
auto val5 = host_view(i, 5);
auto val6 = host_view(i, 6);
auto val7 = host_view(i, 7);
auto val8 = host_view(i, 8);
auto val9 = host_view(i, 9);
auto val10 = host_view(i, 10);
auto val11 = host_view(i, 11);
EXPECT_NEAR(val0, NumberType(80), 1e-14);
EXPECT_NEAR(val1, NumberType(20), 1e-14);
EXPECT_NEAR(val2, NumberType(-20), 1e-14);
EXPECT_NEAR(val3, NumberType(20), 1e-14);
EXPECT_NEAR(val4, NumberType(-20), 1e-14);
EXPECT_NEAR(val5, NumberType(-100), 1e-14);
EXPECT_NEAR(val6, NumberType(40), 1e-14);
EXPECT_NEAR(val7, NumberType(20), 1e-14);
EXPECT_NEAR(val8, NumberType(-20), 1e-14);
EXPECT_NEAR(val9, NumberType(-20), 1e-14);
EXPECT_NEAR(val10, NumberType(20), 1e-14);
EXPECT_NEAR(val11, NumberType(-60), 1e-14);
for (size_type i = 0; i < host_view.extent(0); ++i) {
for (size_type j = 0; j < host_view.extent(1); ++j) {
EXPECT_NEAR(host_view(i, j), NumberType(ref[j]), 1e-14)
<< "Data differs at indices " << i << ", " << j;
}
}
}
// check for correct padding
void validateResultsForSubview(
orig_view_type orig, std::pair<size_type, size_type>& subRangeDim0,
std::pair<size_type, size_type>& subRangeDim1) {
auto host_view =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), orig);
Kokkos::fence();
for (size_type i = 0; i < host_view.extent(0); ++i) {
for (size_type j = 0; j < host_view.extent(1); ++j) {
auto val = host_view(i, j);
if ((i >= std::get<0>(subRangeDim0) && i < std::get<1>(subRangeDim0)) &&
(j >= std::get<0>(subRangeDim1) && j < std::get<1>(subRangeDim1))) {
// is in subview
EXPECT_NEAR(val, NumberType(ref[j]), 1e-14)
<< "Data differs at indices " << i << ", " << j;
} else {
// is outside of subview
EXPECT_NEAR(val, NumberType(0), 1e-14)
<< "Data differs at indices " << i << ", " << j;
}
}
}
}
private:
NumberType ref[12] = {80, 20, -20, 20, -20, -100, 40, 20, -20, -20, 20, -60};
};
template <typename DeviceType, typename Layout, typename Duplication,
@ -214,6 +208,8 @@ struct test_scatter_view_impl_cls<DeviceType, Layout, Duplication, Contribution,
using orig_view_type = Kokkos::View<NumberType * [3], Layout, DeviceType>;
using size_type = typename Kokkos::HostSpace::size_type;
scatter_view_type scatter_view;
int scatterSize;
@ -226,8 +222,7 @@ struct test_scatter_view_impl_cls<DeviceType, Layout, Duplication, Contribution,
auto host_view =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), orig);
Kokkos::fence();
for (typename decltype(host_view)::size_type i = 0; i < host_view.extent(0);
++i) {
for (size_type i = 0; i < host_view.extent(0); ++i) {
host_view(i, 0) = 1.0;
host_view(i, 1) = 1.0;
host_view(i, 2) = 1.0;
@ -260,14 +255,45 @@ struct test_scatter_view_impl_cls<DeviceType, Layout, Duplication, Contribution,
auto host_view =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), orig);
Kokkos::fence();
for (typename decltype(host_view)::size_type i = 0; i < host_view.extent(0);
++i) {
for (size_type i = 0; i < host_view.extent(0); ++i) {
auto val0 = host_view(i, 0);
auto val1 = host_view(i, 1);
auto val2 = host_view(i, 2);
EXPECT_TRUE(std::fabs((val0 - 65536.0) / 65536.0) < 1e-14);
EXPECT_TRUE(std::fabs((val1 - 256.0) / 256.0) < 1e-14);
EXPECT_TRUE(std::fabs((val2 - 1.0) / 1.0) < 1e-14);
EXPECT_TRUE(std::fabs((val0 - 65536.0) / 65536.0) < 1e-14)
<< "Data differs at index " << i;
EXPECT_TRUE(std::fabs((val1 - 256.0) / 256.0) < 1e-14)
<< "Data differs at index " << i;
EXPECT_TRUE(std::fabs((val2 - 1.0) / 1.0) < 1e-14)
<< "Data differs at index " << i;
}
}
// check for correct padding
void validateResultsForSubview(
orig_view_type orig, std::pair<size_type, size_type>& subRangeDim0,
std::pair<size_type, size_type>& subRangeDim1) {
(void)subRangeDim1;
auto host_view =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), orig);
Kokkos::fence();
for (size_type i = 0; i < host_view.extent(0); ++i) {
auto val0 = host_view(i, 0);
auto val1 = host_view(i, 1);
auto val2 = host_view(i, 2);
if (i >= std::get<0>(subRangeDim0) && i < std::get<1>(subRangeDim0)) {
// is in subview
EXPECT_TRUE(std::fabs((val0 - 65536.0) / 65536.0) < 1e-14);
EXPECT_TRUE(std::fabs((val1 - 256.0) / 256.0) < 1e-14);
EXPECT_TRUE(std::fabs((val2 - 1.0) / 1.0) < 1e-14);
} else {
// is outside of subview
EXPECT_NEAR(val0, NumberType(1), 1e-14)
<< "Data differs at index " << i;
EXPECT_NEAR(val1, NumberType(1), 1e-14)
<< "Data differs at index " << i;
EXPECT_NEAR(val2, NumberType(1), 1e-14)
<< "Data differs at index " << i;
}
}
}
};
@ -285,6 +311,8 @@ struct test_scatter_view_impl_cls<DeviceType, Layout, Duplication, Contribution,
using orig_view_type = Kokkos::View<NumberType * [3], Layout, DeviceType>;
using size_type = typename Kokkos::HostSpace::size_type;
scatter_view_type scatter_view;
int scatterSize;
@ -297,8 +325,7 @@ struct test_scatter_view_impl_cls<DeviceType, Layout, Duplication, Contribution,
auto host_view =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), orig);
Kokkos::fence();
for (typename decltype(host_view)::size_type i = 0; i < host_view.extent(0);
++i) {
for (size_type i = 0; i < host_view.extent(0); ++i) {
host_view(i, 0) = 999999.0;
host_view(i, 1) = 999999.0;
host_view(i, 2) = 999999.0;
@ -331,14 +358,48 @@ struct test_scatter_view_impl_cls<DeviceType, Layout, Duplication, Contribution,
auto host_view =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), orig);
Kokkos::fence();
for (typename decltype(host_view)::size_type i = 0; i < host_view.extent(0);
++i) {
for (size_type i = 0; i < host_view.extent(0); ++i) {
auto val0 = host_view(i, 0);
auto val1 = host_view(i, 1);
auto val2 = host_view(i, 2);
EXPECT_TRUE(std::fabs((val0 - 4.0) / 4.0) < 1e-14);
EXPECT_TRUE(std::fabs((val1 - 2.0) / 2.0) < 1e-14);
EXPECT_TRUE(std::fabs((val2 - 1.0) / 1.0) < 1e-14);
EXPECT_TRUE(std::fabs((val0 - 4.0) / 4.0) < 1e-14)
<< "Data differs at index " << i;
EXPECT_TRUE(std::fabs((val1 - 2.0) / 2.0) < 1e-14)
<< "Data differs at index " << i;
EXPECT_TRUE(std::fabs((val2 - 1.0) / 1.0) < 1e-14)
<< "Data differs at index " << i;
}
}
// check for correct padding
void validateResultsForSubview(
orig_view_type orig, std::pair<size_type, size_type>& subRangeDim0,
std::pair<size_type, size_type>& subRangeDim1) {
(void)subRangeDim1;
auto host_view =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), orig);
Kokkos::fence();
for (size_type i = 0; i < host_view.extent(0); ++i) {
auto val0 = host_view(i, 0);
auto val1 = host_view(i, 1);
auto val2 = host_view(i, 2);
if (i >= std::get<0>(subRangeDim0) && i < std::get<1>(subRangeDim0)) {
// is in subview
EXPECT_TRUE(std::fabs((val0 - 4.0) / 4.0) < 1e-14)
<< "Data differs at index " << i;
EXPECT_TRUE(std::fabs((val1 - 2.0) / 2.0) < 1e-14)
<< "Data differs at index " << i;
EXPECT_TRUE(std::fabs((val2 - 1.0) / 1.0) < 1e-14)
<< "Data differs at index " << i;
} else {
// is outside of subview
EXPECT_NEAR(val0, NumberType(999999), 1e-14)
<< "Data differs at index " << i;
EXPECT_NEAR(val1, NumberType(999999), 1e-14)
<< "Data differs at index " << i;
EXPECT_NEAR(val2, NumberType(999999), 1e-14)
<< "Data differs at index " << i;
}
}
}
};
@ -356,6 +417,8 @@ struct test_scatter_view_impl_cls<DeviceType, Layout, Duplication, Contribution,
using orig_view_type = Kokkos::View<NumberType * [3], Layout, DeviceType>;
using size_type = typename Kokkos::HostSpace::size_type;
scatter_view_type scatter_view;
int scatterSize;
@ -368,8 +431,7 @@ struct test_scatter_view_impl_cls<DeviceType, Layout, Duplication, Contribution,
auto host_view =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), orig);
Kokkos::fence();
for (typename decltype(host_view)::size_type i = 0; i < host_view.extent(0);
++i) {
for (size_type i = 0; i < host_view.extent(0); ++i) {
host_view(i, 0) = 0.0;
host_view(i, 1) = 0.0;
host_view(i, 2) = 0.0;
@ -401,14 +463,104 @@ struct test_scatter_view_impl_cls<DeviceType, Layout, Duplication, Contribution,
auto host_view =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), orig);
Kokkos::fence();
for (typename decltype(host_view)::size_type i = 0; i < host_view.extent(0);
++i) {
for (size_type i = 0; i < host_view.extent(0); ++i) {
auto val0 = host_view(i, 0);
auto val1 = host_view(i, 1);
auto val2 = host_view(i, 2);
EXPECT_TRUE(std::fabs((val0 - 16.0) / 16.0) < 1e-14);
EXPECT_TRUE(std::fabs((val1 - 8.0) / 8.0) < 1e-14);
EXPECT_TRUE(std::fabs((val2 - 4.0) / 4.0) < 1e-14);
EXPECT_TRUE(std::fabs((val0 - 16.0) / 16.0) < 1e-14)
<< "Data differs at index " << i;
EXPECT_TRUE(std::fabs((val1 - 8.0) / 8.0) < 1e-14)
<< "Data differs at index " << i;
EXPECT_TRUE(std::fabs((val2 - 4.0) / 4.0) < 1e-14)
<< "Data differs at index " << i;
}
}
// check for correct padding
void validateResultsForSubview(
orig_view_type orig, std::pair<size_type, size_type>& subRangeDim0,
std::pair<size_type, size_type>& subRangeDim1) {
(void)subRangeDim1;
auto host_view =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), orig);
Kokkos::fence();
for (size_type i = 0; i < host_view.extent(0); ++i) {
auto val0 = host_view(i, 0);
auto val1 = host_view(i, 1);
auto val2 = host_view(i, 2);
if (i >= std::get<0>(subRangeDim0) && i < std::get<1>(subRangeDim0)) {
// is in subview
EXPECT_TRUE(std::fabs((val0 - 16.0) / 16.0) < 1e-14)
<< "Data differs at index " << i;
EXPECT_TRUE(std::fabs((val1 - 8.0) / 8.0) < 1e-14)
<< "Data differs at index " << i;
EXPECT_TRUE(std::fabs((val2 - 4.0) / 4.0) < 1e-14)
<< "Data differs at index " << i;
} else {
// is outside of subview
EXPECT_NEAR(val0, NumberType(0), 1e-14)
<< "Data differs at index " << i;
EXPECT_NEAR(val1, NumberType(0), 1e-14)
<< "Data differs at index " << i;
EXPECT_NEAR(val2, NumberType(0), 1e-14)
<< "Data differs at index " << i;
}
}
}
};
// Test ScatterView on subview
template <typename DeviceType, typename Layout, typename Op,
typename NumberType>
struct test_default_scatter_sub_view {
public:
using default_duplication = Kokkos::Impl::Experimental::DefaultDuplication<
typename DeviceType::execution_space>;
using Duplication = typename default_duplication::type;
using Contribution = typename Kokkos::Impl::Experimental::DefaultContribution<
typename DeviceType::execution_space, Duplication>::type;
using scatter_view_def =
typename test_scatter_view_impl_cls<DeviceType, Layout, Duplication,
Contribution, Op,
NumberType>::scatter_view_type;
using orig_view_def =
typename test_scatter_view_impl_cls<DeviceType, Layout, Duplication,
Contribution, Op,
NumberType>::orig_view_type;
using size_type = typename Kokkos::HostSpace::size_type;
void run_test(int n) {
// Test creation via create_scatter_view overload 1
{
orig_view_def original_view("original_view", n);
auto rangeDim0 = std::pair<size_type, size_type>(0 + 1, n - 1);
auto rangeDim1 =
std::pair<size_type, size_type>(0, original_view.extent(1));
auto original_sub_view =
Kokkos::subview(original_view, rangeDim0, rangeDim1);
scatter_view_def scatter_view =
Kokkos::Experimental::create_scatter_view(Op{}, original_sub_view);
test_scatter_view_impl_cls<DeviceType, Layout, Duplication, Contribution,
Op, NumberType>
scatter_view_test_impl(scatter_view);
scatter_view_test_impl.initialize(original_view);
scatter_view_test_impl.run_parallel(original_sub_view.extent(0));
Kokkos::Experimental::contribute(original_sub_view, scatter_view);
scatter_view.reset_except(original_sub_view);
scatter_view_test_impl.run_parallel(original_sub_view.extent(0));
Kokkos::Experimental::contribute(original_sub_view, scatter_view);
Kokkos::fence();
scatter_view_test_impl.validateResultsForSubview(original_view, rangeDim0,
rangeDim1);
}
}
};
@ -674,14 +826,24 @@ void test_scatter_view(int64_t n) {
test_default_sv;
test_default_sv.run_test(n);
}
// run same test but on a subview (this covers support for padded
// ScatterViews)
{
test_default_scatter_sub_view<DeviceType, Kokkos::LayoutRight, ScatterType,
NumberType>
test_default_scatter_view_subview;
test_default_scatter_view_subview.run_test(n);
}
TestDuplicatedScatterView<DeviceType, ScatterType, NumberType> duptest(n);
}
TEST(TEST_CATEGORY, scatterview) {
test_scatter_view<TEST_EXECSPACE, Kokkos::Experimental::ScatterSum, double>(
10);
test_scatter_view<TEST_EXECSPACE, Kokkos::Experimental::ScatterSum,
unsigned int>(10);
test_scatter_view<TEST_EXECSPACE, Kokkos::Experimental::ScatterSum, int>(10);
test_scatter_view<TEST_EXECSPACE, Kokkos::Experimental::ScatterProd>(10);
test_scatter_view<TEST_EXECSPACE, Kokkos::Experimental::ScatterMin>(10);
test_scatter_view<TEST_EXECSPACE, Kokkos::Experimental::ScatterMax>(10);
@ -698,10 +860,11 @@ TEST(TEST_CATEGORY, scatterview) {
#endif
#endif
test_scatter_view<TEST_EXECSPACE, Kokkos::Experimental::ScatterSum, double>(
big_n);
test_scatter_view<TEST_EXECSPACE, Kokkos::Experimental::ScatterSum,
unsigned int>(big_n);
test_scatter_view<TEST_EXECSPACE, Kokkos::Experimental::ScatterSum, int>(
big_n);
test_scatter_view<TEST_EXECSPACE, Kokkos::Experimental::ScatterProd>(big_n);
test_scatter_view<TEST_EXECSPACE, Kokkos::Experimental::ScatterMin>(big_n);
test_scatter_view<TEST_EXECSPACE, Kokkos::Experimental::ScatterMax>(big_n);
@ -712,8 +875,7 @@ TEST(TEST_CATEGORY, scatterview_devicetype) {
Kokkos::Device<TEST_EXECSPACE, typename TEST_EXECSPACE::memory_space>;
test_scatter_view<device_type, Kokkos::Experimental::ScatterSum, double>(10);
test_scatter_view<device_type, Kokkos::Experimental::ScatterSum,
unsigned int>(10);
test_scatter_view<device_type, Kokkos::Experimental::ScatterSum, int>(10);
test_scatter_view<device_type, Kokkos::Experimental::ScatterProd>(10);
test_scatter_view<device_type, Kokkos::Experimental::ScatterMin>(10);
test_scatter_view<device_type, Kokkos::Experimental::ScatterMax>(10);
@ -734,7 +896,7 @@ TEST(TEST_CATEGORY, scatterview_devicetype) {
test_scatter_view<device_device_type, Kokkos::Experimental::ScatterSum,
double>(10);
test_scatter_view<device_device_type, Kokkos::Experimental::ScatterSum,
unsigned int>(10);
int>(10);
test_scatter_view<device_device_type, Kokkos::Experimental::ScatterProd>(
10);
test_scatter_view<device_device_type, Kokkos::Experimental::ScatterMin>(10);
@ -743,8 +905,8 @@ TEST(TEST_CATEGORY, scatterview_devicetype) {
Kokkos::Device<device_execution_space, host_accessible_space>;
test_scatter_view<host_device_type, Kokkos::Experimental::ScatterSum,
double>(10);
test_scatter_view<host_device_type, Kokkos::Experimental::ScatterSum,
unsigned int>(10);
test_scatter_view<host_device_type, Kokkos::Experimental::ScatterSum, int>(
10);
test_scatter_view<host_device_type, Kokkos::Experimental::ScatterProd>(10);
test_scatter_view<host_device_type, Kokkos::Experimental::ScatterMin>(10);
test_scatter_view<host_device_type, Kokkos::Experimental::ScatterMax>(10);

View File

@ -105,8 +105,8 @@ void run_test_graph() {
auto rowView = hx.rowConst(i);
ASSERT_EQ(rowView.length, graph[i].size());
for (size_t j = 0; j < rowView.length; ++j) {
ASSERT_EQ(rowView.colidx(j), graph[i][j]);
ASSERT_EQ(rowView(j), graph[i][j]);
ASSERT_EQ(rowView.colidx(j), (size_t)graph[i][j]);
ASSERT_EQ(rowView(j), (size_t)graph[i][j]);
}
}
}

View File

@ -294,9 +294,7 @@ void test_deep_copy(uint32_t num_nodes) {
}
}
// FIXME_SYCL wrong results on Nvidia GPUs but correct on Host and Intel GPUs
// WORKAROUND MSVC
#if !defined(_WIN32) && !defined(KOKKOS_ENABLE_SYCL)
#if !defined(_WIN32)
TEST(TEST_CATEGORY, UnorderedMap_insert) {
for (int i = 0; i < 500; ++i) {
test_insert<TEST_EXECSPACE>(100000, 90000, 100, true);

View File

@ -60,7 +60,7 @@ struct test_vector_insert {
template <typename Vector>
void run_test(Vector& a) {
int n = a.size();
auto n = a.size();
auto it = a.begin();
if (n > 0) {
@ -97,7 +97,7 @@ struct test_vector_insert {
#endif
ASSERT_EQ(a.size(), n + 1 + n + 5);
ASSERT_EQ(std::distance(it_return, a.begin() + 17), 0);
ASSERT_EQ(std::distance(it_return, a.begin() + 17), 0u);
Vector b;
@ -109,7 +109,7 @@ struct test_vector_insert {
#else
b.insert(b.begin(), 7, 9);
#endif
ASSERT_EQ(b.size(), 7);
ASSERT_EQ(b.size(), 7u);
ASSERT_EQ(b[0], scalar_type(9));
it = a.begin();
@ -121,7 +121,7 @@ struct test_vector_insert {
it_return = a.insert(it, b.begin(), b.end());
#endif
ASSERT_EQ(a.size(), n + 1 + n + 5 + 7);
ASSERT_EQ(std::distance(it_return, a.begin() + 27 + n), 0);
ASSERT_EQ(std::distance(it_return, a.begin() + 27 + n), 0u);
// Testing insert at end via all three function interfaces
a.insert(a.end(), 11);

View File

@ -0,0 +1,183 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#include <gtest/gtest.h>
#include <Kokkos_Core.hpp>
#include <Kokkos_DualView.hpp>
#include <Kokkos_DynRankView.hpp>
#include <Kokkos_ScatterView.hpp>
#include <../../core/unit_test/tools/include/ToolTestingUtilities.hpp>
TEST(TEST_CATEGORY, resize_realloc_no_init_dualview) {
using namespace Kokkos::Test::Tools;
listen_tool_events(Config::DisableAll(), Config::EnableKernels());
Kokkos::DualView<int*** * [1][2][3][4], TEST_EXECSPACE> bla("bla", 5, 6, 7,
8);
auto success = validate_absence(
[&]() {
Kokkos::resize(Kokkos::WithoutInitializing, bla, 5, 6, 7, 9);
Kokkos::realloc(Kokkos::WithoutInitializing, bla, 8, 8, 8, 8);
},
[&](BeginParallelForEvent event) {
if (event.descriptor().find("initialization") != std::string::npos)
return MatchDiagnostic{true, {"Found begin event"}};
return MatchDiagnostic{false};
},
[&](EndParallelForEvent event) {
if (event.descriptor().find("initialization") != std::string::npos)
return MatchDiagnostic{true, {"Found end event"}};
return MatchDiagnostic{false};
});
ASSERT_TRUE(success);
listen_tool_events(Config::DisableAll());
}
TEST(TEST_CATEGORY, resize_realloc_no_alloc_dualview) {
using namespace Kokkos::Test::Tools;
listen_tool_events(Config::DisableAll(), Config::EnableKernels(),
Config::EnableAllocs());
Kokkos::DualView<int*** * [1][2][3][4], TEST_EXECSPACE> bla("bla", 8, 7, 6,
5);
auto success = validate_absence(
[&]() {
Kokkos::resize(bla, 8, 7, 6, 5);
Kokkos::realloc(Kokkos::WithoutInitializing, bla, 8, 7, 6, 5);
},
[&](BeginParallelForEvent) {
return MatchDiagnostic{true, {"Found begin event"}};
},
[&](EndParallelForEvent) {
return MatchDiagnostic{true, {"Found end event"}};
},
[&](AllocateDataEvent) {
return MatchDiagnostic{true, {"Found alloc event"}};
},
[&](DeallocateDataEvent) {
return MatchDiagnostic{true, {"Found dealloc event"}};
});
ASSERT_TRUE(success);
listen_tool_events(Config::DisableAll());
}
TEST(TEST_CATEGORY, resize_realloc_no_init_dynrankview) {
using namespace Kokkos::Test::Tools;
listen_tool_events(Config::DisableAll(), Config::EnableKernels());
Kokkos::DynRankView<int, TEST_EXECSPACE> bla("bla", 5, 6, 7, 8);
auto success = validate_absence(
[&]() {
Kokkos::resize(Kokkos::WithoutInitializing, bla, 5, 6, 7, 9);
Kokkos::realloc(Kokkos::WithoutInitializing, bla, 8, 8, 8, 8);
},
[&](BeginParallelForEvent event) {
if (event.descriptor().find("initialization") != std::string::npos)
return MatchDiagnostic{true, {"Found begin event"}};
return MatchDiagnostic{false};
},
[&](EndParallelForEvent event) {
if (event.descriptor().find("initialization") != std::string::npos)
return MatchDiagnostic{true, {"Found end event"}};
return MatchDiagnostic{false};
});
ASSERT_TRUE(success);
listen_tool_events(Config::DisableAll());
}
TEST(TEST_CATEGORY, resize_realloc_no_init_scatterview) {
using namespace Kokkos::Test::Tools;
listen_tool_events(Config::DisableAll(), Config::EnableKernels());
Kokkos::Experimental::ScatterView<
int*** * [1][2][3], typename TEST_EXECSPACE::array_layout, TEST_EXECSPACE>
bla("bla", 4, 5, 6, 7);
auto success = validate_absence(
[&]() {
Kokkos::resize(Kokkos::WithoutInitializing, bla, 4, 5, 6, 8);
Kokkos::realloc(Kokkos::WithoutInitializing, bla, 8, 8, 8, 8);
},
[&](BeginParallelForEvent event) {
if (event.descriptor().find("initialization") != std::string::npos)
return MatchDiagnostic{true, {"Found begin event"}};
return MatchDiagnostic{false};
},
[&](EndParallelForEvent event) {
if (event.descriptor().find("initialization") != std::string::npos)
return MatchDiagnostic{true, {"Found end event"}};
return MatchDiagnostic{false};
});
ASSERT_TRUE(success);
listen_tool_events(Config::DisableAll());
}
TEST(TEST_CATEGORY, resize_realloc_no_alloc_scatterview) {
using namespace Kokkos::Test::Tools;
listen_tool_events(Config::DisableAll(), Config::EnableKernels(),
Config::EnableAllocs());
Kokkos::Experimental::ScatterView<
int*** * [1][2][3], typename TEST_EXECSPACE::array_layout, TEST_EXECSPACE>
bla("bla", 7, 6, 5, 4);
auto success = validate_absence(
[&]() {
Kokkos::resize(bla, 7, 6, 5, 4);
Kokkos::realloc(Kokkos::WithoutInitializing, bla, 7, 6, 5, 4);
},
[&](BeginParallelForEvent) {
return MatchDiagnostic{true, {"Found begin event"}};
},
[&](EndParallelForEvent) {
return MatchDiagnostic{true, {"Found end event"}};
},
[&](AllocateDataEvent) {
return MatchDiagnostic{true, {"Found alloc event"}};
},
[&](DeallocateDataEvent) {
return MatchDiagnostic{true, {"Found dealloc event"}};
});
ASSERT_TRUE(success);
listen_tool_events(Config::DisableAll());
}