File: test_layout_map.cpp

package info (click to toggle)
gridtools 2.3.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 29,480 kB
  • sloc: cpp: 228,792; python: 17,561; javascript: 9,164; ansic: 4,101; sh: 850; makefile: 231; f90: 201
file content (69 lines) | stat: -rw-r--r-- 1,922 bytes parent folder | download | duplicates (2)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * GridTools
 *
 * Copyright (c) 2014-2023, ETH Zurich
 * All rights reserved.
 *
 * Please, refer to the LICENSE file in the root directory.
 * SPDX-License-Identifier: BSD-3-Clause
 */
#include <gridtools/common/layout_map.hpp>

using namespace gridtools;

namespace simple_layout {
    typedef layout_map<0, 1, 2> layout1;

    // test length
    static_assert(layout1::masked_length == 3);
    static_assert(layout1::unmasked_length == 3);

    // test find method
    static_assert(layout1::find(0) == 0);
    static_assert(layout1::find(1) == 1);
    static_assert(layout1::find(2) == 2);

    // test at method
    static_assert(layout1::at(0) == 0);
    static_assert(layout1::at(1) == 1);
    static_assert(layout1::at(2) == 2);
} // namespace simple_layout

namespace extended_layout {
    typedef layout_map<3, 2, 1, 0> layout2;

    // test length
    static_assert(layout2::masked_length == 4);
    static_assert(layout2::unmasked_length == 4);

    // test find method
    static_assert(layout2::find(0) == 3);
    static_assert(layout2::find(1) == 2);
    static_assert(layout2::find(2) == 1);
    static_assert(layout2::find(3) == 0);

    // test at method
    static_assert(layout2::at(0) == 3);
    static_assert(layout2::at(1) == 2);
    static_assert(layout2::at(2) == 1);
    static_assert(layout2::at(3) == 0);
} // namespace extended_layout

namespace masked_layout {
    typedef layout_map<2, -1, 1, 0> layout3;

    // test length
    static_assert(layout3::masked_length == 4);
    static_assert(layout3::unmasked_length == 3);

    // test find method
    static_assert(layout3::find(0) == 3);
    static_assert(layout3::find(1) == 2);
    static_assert(layout3::find(2) == 0);

    // test at method
    static_assert(layout3::at(0) == 2);
    static_assert(layout3::at(1) == -1);
    static_assert(layout3::at(2) == 1);
    static_assert(layout3::at(3) == 0);
} // namespace masked_layout