forked from alpaka-group/alpaka3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmdIterator.cpp
More file actions
34 lines (26 loc) · 820 Bytes
/
mdIterator.cpp
File metadata and controls
34 lines (26 loc) · 820 Bytes
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
/* Copyright 2024 René Widera
* SPDX-License-Identifier: MPL-2.0
*/
#include <alpaka/alpaka.hpp>
#include <catch2/catch_test_macros.hpp>
using namespace alpaka;
using namespace alpaka::onHost;
TEST_CASE("mdIterator", "")
{
constexpr auto numElements = CVec<size_t, 17, 31>{};
alpaka::concepts::IBuffer auto span = onHost::allocHost<uint32_t>(numElements);
size_t counter = 0u;
for(uint32_t& v : span)
v = counter++;
// validate by using the forward iterator
size_t refence = 0u;
for(uint32_t v : span)
{
CHECK(v == refence);
++refence;
}
// validate without using the forward iterator
meta::ndLoopIncIdx(
numElements,
[&](alpaka::concepts::Vector<size_t, 2> auto idx) { CHECK(span[idx] == linearize(numElements, idx)); });
}