VTK-m  2.2
Hints.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_cont_internal_Hints_h
11 #define vtk_m_cont_internal_Hints_h
12 
13 #include <vtkm/Assert.h>
14 #include <vtkm/List.h>
15 
17 
18 namespace vtkm
19 {
20 namespace cont
21 {
22 namespace internal
23 {
24 
36 template <typename Derived_, typename Tag_, typename DeviceList_>
37 struct HintBase
38 {
39  using Derived = Derived_;
40  using Tag = Tag_;
41  using DeviceList = DeviceList_;
42 };
43 
44 struct HintTagThreadsPerBlock
45 {
46 };
47 
52 template <vtkm::IdComponent MaxThreads_, typename DeviceList_ = vtkm::ListUniversal>
53 struct HintThreadsPerBlock
54  : HintBase<HintThreadsPerBlock<MaxThreads_, DeviceList_>, HintTagThreadsPerBlock, DeviceList_>
55 {
56  static constexpr vtkm::IdComponent MaxThreads = MaxThreads_;
57 };
58 
64 template <typename... Hints>
65 struct HintList : vtkm::List<Hints...>
66 {
67  using List = vtkm::List<Hints...>;
68 };
69 
70 template <typename T>
71 struct IsHintList : std::false_type
72 {
73 };
74 template <typename... Hints>
75 struct IsHintList<HintList<Hints...>> : std::true_type
76 {
77 };
78 
85 #define VTKM_IS_HINT_LIST(T) VTKM_STATIC_ASSERT(::vtkm::cont::internal::IsHintList<T>::value)
86 
87 namespace detail
88 {
89 
90 template <typename Device, typename HintTag>
91 struct FindHintOperators
92 {
94 
95  template <typename Hint>
96  using HintMatches = vtkm::internal::meta::And<std::is_same<typename Hint::Tag, HintTag>,
98  template <typename Found, typename Next>
99  using ReduceOperator = typename std::conditional<HintMatches<Next>::value, Next, Found>::type;
100 };
101 
102 } // namespace detail
103 
114 template <typename HList, typename DefaultHint, typename Device>
115 using HintFind = vtkm::ListReduce<
116  typename HList::List,
117  detail::FindHintOperators<Device, typename DefaultHint::Tag>::template ReduceOperator,
118  DefaultHint>;
119 
120 }
121 }
122 } // namespace vtkm::cont::internal
123 
124 #endif // vtk_m_cont_internal_Hints_h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::IdComponent
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
DeviceAdapterTag.h
Assert.h
vtkm::ListReduce
typename detail::ListReduceImpl< List, Operator, Initial >::type ListReduce
Reduces a list to a single type using an operator.
Definition: List.h:819
vtkm::ListHas
typename detail::ListHasImpl< List, T >::type ListHas
Checks to see if the given T is in the list pointed to by List.
Definition: List.h:577
vtkm::List
A template used to hold a list of types.
Definition: List.h:39
List.h
VTKM_IS_DEVICE_ADAPTER_TAG
#define VTKM_IS_DEVICE_ADAPTER_TAG(tag)
Checks that the argument is a proper device adapter tag.
Definition: DeviceAdapterTag.h:194