File: test_axis.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 (50 lines) | stat: -rw-r--r-- 1,433 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
/*
 * 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/stencil/frontend/axis.hpp>

#include <type_traits>

#include <gtest/gtest.h>

using namespace gridtools;
using namespace stencil;
using namespace core;

constexpr int level_offset_limit = 2;

template <uint_t Splitter, int_t Offset>
using level_t = level<Splitter, Offset, level_offset_limit>;

TEST(test_axis, ctor) {
    using axis_t = axis<2, axis_config::offset_limit<level_offset_limit>>;
    auto axis_ = axis_t((uint_t)5, (uint_t)4);

    EXPECT_EQ(5, axis_.interval_size(0));
    EXPECT_EQ(4, axis_.interval_size(1));
}

namespace intervals {
    using axis_t = axis<3, axis_config::offset_limit<level_offset_limit>>;

    template <class T, uint_t FromSplitter, int_t FromOffset, uint_t ToSplitter, int_t ToOffset>
    constexpr bool testee =
        std::is_same_v<T, interval<level_t<FromSplitter, FromOffset>, level_t<ToSplitter, ToOffset>>>;

    // full interval
    static_assert(testee<axis_t::full_interval, 0, 1, 3, -1>);

    // intervals by id
    static_assert(testee<axis_t::get_interval<0>, 0, 1, 1, -1>);
    static_assert(testee<axis_t::get_interval<1>, 1, 1, 2, -1>);

    // hull of multiple intervals
    static_assert(testee<axis_t::get_interval<1, 2>, 1, 1, 3, -1>);
} // namespace intervals