1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// SPDX-FileCopyrightText: Copyright Contributors to the Kokkos project
#include <gtest/gtest.h>
#include <Kokkos_Macros.hpp>
#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
import kokkos.core;
#else
#include <Kokkos_Core.hpp>
#endif
namespace {
TEST(TEST_CATEGORY_DEATH, view_subview_constructor_layout_compatibility) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
int N = 10;
using LR = Kokkos::LayoutRight;
using LL = Kokkos::LayoutLeft;
using LS = Kokkos::LayoutStride;
Kokkos::View<int**, LL> a1("A1", N, N);
{
// Using subview dims (ALL, 1). For a LayoutLeft,
// any subview layout should be appropriate.
(void)Kokkos::View<int*, LL>(a1, Kokkos::ALL, 1);
(void)Kokkos::View<int*, LS>(a1, Kokkos::ALL, 1);
// FIXME: This doesn't compile for BasicView, but should
//(void)Kokkos::View<int*, LR>(a, Kokkos::ALL, 1);
}
{
// Using subview dims (1, ALL). For a LayoutLeft,
// resulting subview must be strided.
const std::string msg = "View assignment must have compatible layouts";
ASSERT_DEATH(((void)Kokkos::View<int*, LL>(a1, 1, Kokkos::ALL)), msg);
(void)Kokkos::View<int*, LS>(a1, 1, Kokkos::ALL);
ASSERT_DEATH(((void)Kokkos::View<int*, LR>(a1, 1, Kokkos::ALL)), msg);
}
Kokkos::View<int**, LL> a2("A2", 1, N);
{
// Using subview dims (0, ALL). Any subview layout should be appropriate.
(void)Kokkos::View<int*, LL>(a2, 0, Kokkos::ALL);
(void)Kokkos::View<int*, LS>(a2, 0, Kokkos::ALL);
(void)Kokkos::View<int*, LR>(a2, 0, Kokkos::ALL);
}
}
} // namespace
|