forked from alpaka-group/alpaka3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalignment.cpp
More file actions
55 lines (42 loc) · 1.44 KB
/
alignment.cpp
File metadata and controls
55 lines (42 loc) · 1.44 KB
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
50
51
52
53
54
55
/* Copyright 2025 René Widera
* SPDX-License-Identifier: MPL-2.0
*/
#include <alpaka/alpaka.hpp>
#include <catch2/catch_test_macros.hpp>
#include <cstdint>
#include <iostream>
#include <string>
#include <tuple>
/** @file
*
* This file is testing the alignment of the Simd type
* We do not use constexpr because depending on the implementation the underlying native types are not constexpr.
*/
TEST_CASE("simd alignment", "[simd alignment]")
{
using namespace alpaka;
[[maybe_unused]] auto s1 = Simd{3, 7, 4};
CHECK(alignof(ALPAKA_TYPEOF(s1)) == 4u);
[[maybe_unused]] auto s2 = Simd<double, 3u>{3., 7., 4.};
CHECK(alignof(ALPAKA_TYPEOF(s2)) == 8u);
constexpr auto v1 = Vec{1.f, 2.f, 3.f};
[[maybe_unused]] auto s3 = Simd{v1, v1, v1, v1};
CHECK(alignof(ALPAKA_TYPEOF(v1)) == 4u);
CHECK(alignof(ALPAKA_TYPEOF(s3)) == 4u);
constexpr auto v2 = Vec{1.f, 2.f};
[[maybe_unused]] auto s4 = Simd{v2, v2, v2};
CHECK(alignof(ALPAKA_TYPEOF(v2)) == 4u);
CHECK(alignof(ALPAKA_TYPEOF(s4)) == 4u);
[[maybe_unused]] auto s5 = Simd{v2, v2, v2, v2};
CHECK(alignof(ALPAKA_TYPEOF(s5)) == 32u);
[[maybe_unused]] auto s6 = Simd{v2, v2, v2, v2, v2};
CHECK(alignof(ALPAKA_TYPEOF(s6)) == 4u);
struct Foo
{
char8_t c0;
char8_t c1;
char8_t c2;
};
auto s7 = Simd{Foo{'a', 'b', 'c'}, Foo{'d', 'e', 'f'}, Foo{'g', 'h', 'i'}};
CHECK(alignof(ALPAKA_TYPEOF(s7)) == 1u);
}