Update Kokkos library to v2.7.00
This commit is contained in:
@ -862,19 +862,11 @@ public:
|
||||
|
||||
TestViewAPI()
|
||||
{
|
||||
run_test_mirror();
|
||||
run_test();
|
||||
run_test_scalar();
|
||||
run_test_const();
|
||||
run_test_subview();
|
||||
run_test_subview_strided();
|
||||
run_test_vector();
|
||||
|
||||
}
|
||||
|
||||
static void run_test_view_operator_a() {
|
||||
{TestViewOperator< T, device > f; Kokkos::parallel_for(int(N0),f);}
|
||||
#ifndef KOKKOS_ENABLE_OPENMPTARGET
|
||||
TestViewOperator_LeftAndRight< int[2][3][4][2][3][4][2][3], device > f8; f8.testit();
|
||||
TestViewOperator_LeftAndRight< int[2][3][4][2][3][4][2], device > f7; f7.testit();
|
||||
TestViewOperator_LeftAndRight< int[2][3][4][2][3][4], device >f6; f6.testit();
|
||||
TestViewOperator_LeftAndRight< int[2][3][4][2][3], device >f5; f5.testit();
|
||||
TestViewOperator_LeftAndRight< int[2][3][4][2], device >f4; f4.testit();
|
||||
@ -882,8 +874,18 @@ public:
|
||||
TestViewOperator_LeftAndRight< int[2][3], device >f2; f2.testit();
|
||||
TestViewOperator_LeftAndRight< int[2], device >f1; f1.testit();
|
||||
#endif
|
||||
TestViewMirror< Kokkos::LayoutLeft, device >::testit();
|
||||
TestViewMirror< Kokkos::LayoutRight, device >::testit();
|
||||
}
|
||||
|
||||
static void run_test_view_operator_b() {
|
||||
#ifndef KOKKOS_ENABLE_OPENMPTARGET
|
||||
TestViewOperator_LeftAndRight< int[2][3][4][2][3][4][2], device > f7; f7.testit();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void run_test_view_operator_c() {
|
||||
#ifndef KOKKOS_ENABLE_OPENMPTARGET
|
||||
TestViewOperator_LeftAndRight< int[2][3][4][2][3][4][2][3], device > f8; f8.testit();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void run_test_mirror()
|
||||
@ -897,6 +899,9 @@ public:
|
||||
mirror_type am = Kokkos::create_mirror_view( a );
|
||||
mirror_type ax = Kokkos::create_mirror( a );
|
||||
ASSERT_EQ( & a(), & am() );
|
||||
|
||||
TestViewMirror< Kokkos::LayoutLeft, device >::testit();
|
||||
TestViewMirror< Kokkos::LayoutRight, device >::testit();
|
||||
}
|
||||
|
||||
static void run_test_scalar()
|
||||
@ -995,11 +1000,15 @@ public:
|
||||
|
||||
{
|
||||
// Destruction of this view should be harmless.
|
||||
|
||||
const_dView4 unmanaged_from_ptr_const_dx( dx.data(),
|
||||
dx.extent(0),
|
||||
dx.extent(1),
|
||||
dx.extent(0)
|
||||
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE
|
||||
,dx.extent(1),
|
||||
dx.extent(2),
|
||||
dx.extent(3) );
|
||||
dx.extent(3)
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
const_dView4 const_dx = dx;
|
||||
@ -1180,7 +1189,9 @@ return;
|
||||
ASSERT_TRUE( dx.data() == 0 );
|
||||
ASSERT_TRUE( dy.data() == 0 );
|
||||
ASSERT_TRUE( dz.data() == 0 );
|
||||
}
|
||||
|
||||
static void run_test_deep_copy_empty() {
|
||||
// Check Deep Copy of LayoutLeft to LayoutRight
|
||||
{
|
||||
Kokkos::View<double*,Kokkos::LayoutLeft> dll("dll",10);
|
||||
@ -1204,7 +1215,6 @@ return;
|
||||
Kokkos::deep_copy(d,h);
|
||||
Kokkos::deep_copy(h,d);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
typedef T DataType[2];
|
||||
@ -1381,163 +1391,4 @@ return;
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined(KOKKOS_ENABLE_ROCM)
|
||||
TEST_F( TEST_CATEGORY, view_api )
|
||||
{
|
||||
TestViewAPI< double, TEST_EXECSPACE >();
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_F( TEST_CATEGORY, view_remap )
|
||||
{
|
||||
enum { N0 = 3, N1 = 2, N2 = 8, N3 = 9 };
|
||||
|
||||
#ifdef KOKKOS_ENABLE_CUDA
|
||||
#define EXECSPACE std::conditional<std::is_same<TEST_EXECSPACE,Kokkos::Cuda>::value,Kokkos::CudaHostPinnedSpace,TEST_EXECSPACE>::type
|
||||
#else
|
||||
#ifdef KOKKOS_ENABLE_ROCM
|
||||
#define EXECSPACE std::conditional<std::is_same<TEST_EXECSPACE,Kokkos::Experimental::ROCm>::value,Kokkos::Experimental::ROCmHostPinnedSpace,TEST_EXECSPACE>::type
|
||||
#else
|
||||
#if defined(KOKKOS_ENABLE_OPENMPTARGET)
|
||||
#define EXECSPACE Kokkos::HostSpace
|
||||
#else
|
||||
#define EXECSPACE TEST_EXECSPACE
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef Kokkos::View< double*[N1][N2][N3],
|
||||
Kokkos::LayoutRight,
|
||||
EXECSPACE > output_type;
|
||||
|
||||
typedef Kokkos::View< int**[N2][N3],
|
||||
Kokkos::LayoutLeft,
|
||||
EXECSPACE > input_type;
|
||||
|
||||
typedef Kokkos::View< int*[N0][N2][N3],
|
||||
Kokkos::LayoutLeft,
|
||||
EXECSPACE > diff_type;
|
||||
|
||||
output_type output( "output", N0 );
|
||||
input_type input ( "input", N0, N1 );
|
||||
diff_type diff ( "diff", N0 );
|
||||
|
||||
Kokkos::fence();
|
||||
int value = 0;
|
||||
|
||||
for ( size_t i3 = 0; i3 < N3; ++i3 )
|
||||
for ( size_t i2 = 0; i2 < N2; ++i2 )
|
||||
for ( size_t i1 = 0; i1 < N1; ++i1 )
|
||||
for ( size_t i0 = 0; i0 < N0; ++i0 )
|
||||
{
|
||||
input( i0, i1, i2, i3 ) = ++value;
|
||||
}
|
||||
|
||||
Kokkos::fence();
|
||||
// Kokkos::deep_copy( diff, input ); // Throw with incompatible shape.
|
||||
Kokkos::deep_copy( output, input );
|
||||
Kokkos::fence();
|
||||
|
||||
value = 0;
|
||||
|
||||
for ( size_t i3 = 0; i3 < N3; ++i3 )
|
||||
for ( size_t i2 = 0; i2 < N2; ++i2 )
|
||||
for ( size_t i1 = 0; i1 < N1; ++i1 )
|
||||
for ( size_t i0 = 0; i0 < N0; ++i0 )
|
||||
{
|
||||
++value;
|
||||
ASSERT_EQ( value, ( (int) output( i0, i1, i2, i3 ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F( TEST_CATEGORY, view_mirror_nonconst )
|
||||
{
|
||||
Kokkos::View<int*, TEST_EXECSPACE> d_view("d_view", 10);
|
||||
Kokkos::View<const int*, TEST_EXECSPACE> d_view_const = d_view;
|
||||
auto h_view = Kokkos::create_mirror(d_view_const);
|
||||
Kokkos::deep_copy(h_view, d_view_const);
|
||||
auto h_view2 = Kokkos::create_mirror(Kokkos::HostSpace(), d_view_const);
|
||||
Kokkos::deep_copy(h_view2, d_view_const);
|
||||
}
|
||||
|
||||
template <typename DataType, typename ... Extents>
|
||||
void test_left_stride(Extents ... extents) {
|
||||
using view_type = Kokkos::View<DataType, Kokkos::LayoutLeft, Kokkos::HostSpace>;
|
||||
view_type view("view", extents...);
|
||||
size_t expected_stride = 1;
|
||||
size_t all_strides[view_type::rank + 1];
|
||||
view.stride(all_strides);
|
||||
for (int i = 0; i < view_type::rank; ++i) {
|
||||
ASSERT_EQ(view.stride(i), expected_stride);
|
||||
ASSERT_EQ(all_strides[i], expected_stride);
|
||||
expected_stride *= view.extent(i);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename DataType, typename ... Extents>
|
||||
void test_right_stride(Extents ... extents) {
|
||||
using view_type = Kokkos::View<DataType, Kokkos::LayoutRight, Kokkos::HostSpace>;
|
||||
view_type view("view", extents...);
|
||||
size_t expected_stride = 1;
|
||||
size_t all_strides[view_type::rank + 1];
|
||||
view.stride(all_strides);
|
||||
for (int ri = 0; ri < view_type::rank; ++ri) {
|
||||
auto i = view_type::rank - 1 - ri;
|
||||
ASSERT_EQ(view.stride(i), expected_stride);
|
||||
ASSERT_EQ(all_strides[i], expected_stride);
|
||||
expected_stride *= view.extent(i);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename DataType, typename ... Extents>
|
||||
void test_stride(Extents ... extents) {
|
||||
test_right_stride<DataType>(extents...);
|
||||
test_left_stride<DataType>(extents...);
|
||||
}
|
||||
|
||||
TEST_F( TEST_CATEGORY, view_stride_method )
|
||||
{
|
||||
test_stride<double[3]>();
|
||||
test_stride<double*>(3);
|
||||
test_stride<double[3][7][13]>();
|
||||
test_stride<double***>(3, 7, 13);
|
||||
// factorial(8) = 40320
|
||||
test_stride<double[1][2][3][4][5][6][7][8]>();
|
||||
test_stride<double********>(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
}
|
||||
|
||||
inline void test_anonymous_space() {
|
||||
/* apparently TEST_EXECSPACE is sometimes a memory space. */
|
||||
using ExecSpace = TEST_EXECSPACE::execution_space;
|
||||
int host_array[10];
|
||||
Kokkos::View<int[10], Kokkos::AnonymousSpace> host_anon_stat_view(host_array);
|
||||
Kokkos::View<int*, Kokkos::AnonymousSpace> host_anon_dyn_view(host_array, 10);
|
||||
Kokkos::View<int*, Kokkos::HostSpace> host_view("host_view", 10);
|
||||
Kokkos::View<int*, Kokkos::AnonymousSpace> host_anon_assign_view = host_view;
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
host_anon_stat_view(i) = host_anon_dyn_view(i) = 142;
|
||||
host_anon_assign_view(i) = 142;
|
||||
}
|
||||
Kokkos::View<int**, Kokkos::LayoutRight, ExecSpace> d_view("d_view", 100, 10);
|
||||
#ifdef KOKKOS_ENABLE_CXX11_DISPATCH_LAMBDA
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<ExecSpace, int>(0, 100), KOKKOS_LAMBDA(int i) {
|
||||
int* ptr = &(d_view(i, 0));
|
||||
Kokkos::View<int[10], Kokkos::AnonymousSpace> d_anon_stat_view(ptr);
|
||||
Kokkos::View<int*, Kokkos::AnonymousSpace> d_anon_dyn_view(ptr, 10);
|
||||
auto sub = Kokkos::subview(d_view, i, Kokkos::ALL());
|
||||
Kokkos::View<int*, Kokkos::AnonymousSpace> d_anon_assign_view = sub;
|
||||
for (int j = 0; j < 10; ++j) {
|
||||
d_anon_stat_view(j) = 50;
|
||||
d_anon_assign_view(j) += 50;
|
||||
d_anon_dyn_view(j) += 42;
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_F( TEST_CATEGORY, anonymous_space )
|
||||
{
|
||||
test_anonymous_space();
|
||||
}
|
||||
|
||||
} // namespace Test
|
||||
|
||||
Reference in New Issue
Block a user