Skip to content

Commit 2c9f15f

Browse files
committed
1D test with for_each
1 parent 33311c8 commit 2c9f15f

File tree

1 file changed

+44
-6
lines changed

1 file changed

+44
-6
lines changed

tests/for_each.cpp

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,49 @@ TEST(ForEachSerialHost, TwoDimensions)
8484
EXPECT_EQ(std::count(storage.begin(), storage.end(), 1), dom.size());
8585
}
8686

87-
void TestAnnotatedForEachSerialDevice(ddc::ChunkSpan<
88-
int,
89-
DDomXY,
90-
Kokkos::layout_right,
91-
typename Kokkos::DefaultExecutionSpace::memory_space> view)
87+
void TestAnnotatedForEachSerialDevice1D(ddc::ChunkSpan<
88+
int,
89+
DDomX,
90+
Kokkos::layout_right,
91+
typename Kokkos::DefaultExecutionSpace::memory_space> view)
92+
{
93+
ddc::parallel_for_each(
94+
Kokkos::DefaultExecutionSpace(),
95+
DDom0D(),
96+
KOKKOS_LAMBDA([[maybe_unused]] DElem0D unused_elem) {
97+
Kokkos::printf("%i\n", view.template extent<DDimX>());
98+
ddc::annotated_for_each(view.domain(), [=](DElemX const ix) {
99+
Kokkos::printf("lul");
100+
view(ix) = 1;
101+
});
102+
});
103+
}
104+
105+
TEST(AnnotatedForEachSerialDevice, OneDimension)
106+
{
107+
DDomX const dom(lbound_x, nelems_x);
108+
Kokkos::View<int*, Kokkos::LayoutRight, Kokkos::DefaultExecutionSpace> const
109+
storage("", dom.size());
110+
ddc::ChunkSpan<
111+
int,
112+
DDomX,
113+
Kokkos::layout_right,
114+
typename Kokkos::DefaultExecutionSpace::memory_space> const view(storage.data(), dom);
115+
TestAnnotatedForEachSerialDevice1D(view);
116+
EXPECT_EQ(
117+
Kokkos::Experimental::
118+
count(Kokkos::DefaultExecutionSpace(),
119+
Kokkos::Experimental::begin(storage),
120+
Kokkos::Experimental::end(storage),
121+
1),
122+
dom.size());
123+
}
124+
125+
void TestAnnotatedForEachSerialDevice2D(ddc::ChunkSpan<
126+
int,
127+
DDomXY,
128+
Kokkos::layout_right,
129+
typename Kokkos::DefaultExecutionSpace::memory_space> view)
92130
{
93131
ddc::parallel_for_each(
94132
Kokkos::DefaultExecutionSpace(),
@@ -108,7 +146,7 @@ TEST(AnnotatedForEachSerialDevice, TwoDimensions)
108146
DDomXY,
109147
Kokkos::layout_right,
110148
typename Kokkos::DefaultExecutionSpace::memory_space> const view(storage.data(), dom);
111-
TestAnnotatedForEachSerialDevice(view);
149+
TestAnnotatedForEachSerialDevice2D(view);
112150
EXPECT_EQ(
113151
Kokkos::Experimental::
114152
count(Kokkos::DefaultExecutionSpace(),

0 commit comments

Comments
 (0)