/
ArborXTest_TreeTypeTraits.hpp
85 lines (71 loc) · 2.92 KB
/
ArborXTest_TreeTypeTraits.hpp
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
/****************************************************************************
* Copyright (c) 2017-2022 by the ArborX authors *
* All rights reserved. *
* *
* This file is part of the ArborX library. ArborX is *
* distributed under a BSD 3-clause license. For the licensing terms see *
* the LICENSE file in the top-level directory. *
* *
* SPDX-License-Identifier: BSD-3-Clause *
****************************************************************************/
#ifndef ARBORX_TEST_TREE_TYPE_TRAITS_HPP
#define ARBORX_TEST_TREE_TYPE_TRAITS_HPP
#include <ArborX.hpp>
#include <tuple>
// NOTE Because std::tuple does not take template template parameters
template <template <class...> class...>
struct Tuple
{};
#ifndef ARBORX_TEST_TREE_TYPES
// NOTE Emulate resulting name from using ArborX::BoundingVolumeHierarchy as
// template parameter in Boost.Test
template <class MemorySpace>
using ArborX__BoundingVolumeHierarchy =
ArborX::BoundingVolumeHierarchy<MemorySpace>;
#define ARBORX_TEST_TREE_TYPES Tuple<ArborX__BoundingVolumeHierarchy>
#endif
#ifndef ARBORX_TEST_DEVICE_TYPES
#define ARBORX_TEST_DEVICE_TYPES \
std::tuple<Kokkos::DefaultExecutionSpace::device_type>
#endif
template <template <class...> class Tree, class DeviceType>
struct TreeExecutionAndMemorySpaces
// NOTE The name of this class will be part of the resulting name of the unit
// test produced by Boost.Test, such as
//
// clang-format off
// test_case_name<this_class_name<ArborX__BVH_ Kokkos__Device<Kokkos__Cuda_ Kokkos__CudaSpace>>>*
// clang-format on
{
static_assert(Kokkos::is_device<DeviceType>{});
using device_type = DeviceType;
using execution_space = typename DeviceType::execution_space;
using memory_space = typename DeviceType::memory_space;
using type = Tree<memory_space>;
};
template <class...>
struct Concatenate;
template <class... Ts, class... Us>
struct Concatenate<std::tuple<Ts...>, std::tuple<Us...>>
{
using type = std::tuple<Ts..., Us...>;
};
template <class T, class U>
struct CartesianProduct;
template <class... Us>
struct CartesianProduct<Tuple<>, std::tuple<Us...>>
{
using type = std::tuple<>;
};
template <template <class...> class T, template <class...> class... Ts,
class... Us>
struct CartesianProduct<Tuple<T, Ts...>, std::tuple<Us...>>
{
using type = typename Concatenate<
std::tuple<TreeExecutionAndMemorySpaces<T, Us>...>,
typename CartesianProduct<Tuple<Ts...>, std::tuple<Us...>>::type>::type;
};
using TreeTypeTraitsList =
typename CartesianProduct<ARBORX_TEST_TREE_TYPES,
ARBORX_TEST_DEVICE_TYPES>::type;
#endif