forked from kokkos/kokkos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestRangePolicyCTAD.cpp
92 lines (71 loc) · 3.25 KB
/
TestRangePolicyCTAD.cpp
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//@HEADER
// ************************************************************************
//
// Kokkos v. 4.0
// Copyright (2022) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
// See https://kokkos.org/LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//@HEADER
#include <Kokkos_Core.hpp>
#include "Kokkos_Core_fwd.hpp"
#if !defined(KOKKOS_COMPILER_NVCC) || KOKKOS_COMPILER_NVCC >= 1120
namespace {
template <class... Args>
using PolicyMaker = decltype(::Kokkos::RangePolicy(std::declval<Args>()...));
template <class Policy, class... Args>
inline constexpr bool IsSamePolicy =
std::is_same_v<Policy, PolicyMaker<Args...>>;
#define KOKKOS_TEST_RANGE_POLICY(...) static_assert(IsSamePolicy<__VA_ARGS__>)
struct TestRangePolicyCTAD {
struct ImplicitlyConvertibleToDefaultExecutionSpace {
operator Kokkos::DefaultExecutionSpace() const {
return Kokkos::DefaultExecutionSpace();
}
};
static_assert(!Kokkos::is_execution_space_v<
ImplicitlyConvertibleToDefaultExecutionSpace>);
using des = Kokkos::DefaultExecutionSpace;
using nes = ImplicitlyConvertibleToDefaultExecutionSpace;
using i64 = int64_t;
using i32 = int32_t;
using cs = Kokkos::ChunkSize;
// RangePolicy()
// Guard against GGC 8.4 bug
// error: cannot deduce template arguments for ‘RangePolicy’ from ()
// error: template argument 2 is invalid
#if !defined(KOKKOS_COMPILER_GNU) || (KOKKOS_COMPILER_GNU > 900)
KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<> /*, no argument */);
#endif
// RangePolicy(index_type, index_type)
KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, i64, i64);
KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, i64, i32);
KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, i32, i64);
KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, i32, i32);
// RangePolicy(index_type, index_type, Args...)
KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, i64, i64, cs);
KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, i64, i32, cs);
KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, i32, i64, cs);
KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, i32, i32, cs);
// RangePolicy(execution_space, index_type, index_type)
KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, des, i64, i64);
KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, des, i32, i32);
KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, nes, i64, i64);
KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, nes, i32, i32);
// RangePolicy(execution_space, index_type, index_type, Args...)
KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, des, i64, i64, cs);
KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, des, i32, i32, cs);
KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, nes, i64, i64, cs);
KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, nes, i32, i32, cs);
}; // TestRangePolicyCTAD struct
// To eliminate maybe_unused warning on some compilers
const Kokkos::DefaultExecutionSpace des =
TestRangePolicyCTAD::ImplicitlyConvertibleToDefaultExecutionSpace();
} // namespace
#endif