Kokkos Core Kernels Package  Version of the Day
Kokkos_TaskScheduler_fwd.hpp
1 /*
2 //@HEADER
3 // ************************************************************************
4 //
5 // Kokkos v. 3.0
6 // Copyright (2020) National Technology & Engineering
7 // Solutions of Sandia, LLC (NTESS).
8 //
9 // Under the terms of Contract DE-NA0003525 with NTESS,
10 // the U.S. Government retains certain rights in this software.
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions are
14 // met:
15 //
16 // 1. Redistributions of source code must retain the above copyright
17 // notice, this list of conditions and the following disclaimer.
18 //
19 // 2. Redistributions in binary form must reproduce the above copyright
20 // notice, this list of conditions and the following disclaimer in the
21 // documentation and/or other materials provided with the distribution.
22 //
23 // 3. Neither the name of the Corporation nor the names of the
24 // contributors may be used to endorse or promote products derived from
25 // this software without specific prior written permission.
26 //
27 // THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
28 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
31 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 //
39 // Questions? Contact Christian R. Trott (crtrott@sandia.gov)
40 //
41 // ************************************************************************
42 //@HEADER
43 */
44 
45 #ifndef KOKKOS_TASKSCHEDULER_FWD_HPP
46 #define KOKKOS_TASKSCHEDULER_FWD_HPP
47 
48 //----------------------------------------------------------------------------
49 
50 #include <cstddef>
51 #include <Kokkos_Macros.hpp>
52 #if defined(KOKKOS_ENABLE_TASKDAG)
53 
54 #include <Kokkos_Core_fwd.hpp>
55 //----------------------------------------------------------------------------
56 
57 namespace Kokkos {
58 
59 // Forward declarations used in Impl::TaskQueue
60 
61 template <typename ValueType, typename Scheduler>
62 class BasicFuture;
63 
64 template <class Space, class Queue>
65 class SimpleTaskScheduler;
66 
67 template <class Space, class Queue>
68 class BasicTaskScheduler;
69 
70 template <typename Space>
71 struct is_scheduler : public std::false_type {};
72 
73 template <class Space, class Queue>
74 struct is_scheduler<BasicTaskScheduler<Space, Queue>> : public std::true_type {
75 };
76 
77 template <class Space, class Queue>
78 struct is_scheduler<SimpleTaskScheduler<Space, Queue>> : public std::true_type {
79 };
80 
81 enum class TaskPriority : int { High = 0, Regular = 1, Low = 2 };
82 
83 } // namespace Kokkos
84 
85 //----------------------------------------------------------------------------
86 
87 namespace Kokkos {
88 
89 template <class Device>
90 class MemoryPool;
91 
92 namespace Impl {
93 
94 template <class TaskQueueTraits>
95 class TaskNode;
96 
97 class TaskBase;
98 
99 /*\brief Implementation data for task data management, access, and execution.
100  * (Deprecated)
101  * CRTP Inheritance structure to allow static_cast from the
102  * task root type and a task's FunctorType.
103  *
104  * TaskBase< Space , ResultType , FunctorType >
105  * : TaskBase< Space , ResultType , void >
106  * , FunctorType
107  * { ... };
108  *
109  * TaskBase< Space , ResultType , void >
110  * : TaskBase< Space , void , void >
111  * { ... };
112  */
113 template <typename Space, typename ResultType, typename FunctorType>
114 class Task;
115 
116 class TaskQueueBase;
117 
118 template <typename Space, typename MemorySpace>
119 class TaskQueue;
120 
121 template <typename ExecSpace, typename MemorySpace>
122 class TaskQueueMultiple;
123 
124 template <typename ExecSpace, typename MemSpace, typename TaskQueueTraits,
125  class MemoryPool =
126  Kokkos::MemoryPool<Kokkos::Device<ExecSpace, MemSpace>>>
127 class SingleTaskQueue;
128 
129 template <typename ExecSpace, typename MemSpace, typename TaskQueueTraits,
130  class MemoryPool>
131 class MultipleTaskQueue;
132 
133 struct TaskQueueTraitsLockBased;
134 
135 template <size_t CircularBufferSize = 64>
136 struct TaskQueueTraitsChaseLev;
137 
138 template <typename ResultType>
139 struct TaskResult;
140 
141 struct TaskSchedulerBase;
142 
143 template <class ExecSpace>
144 struct default_tasking_memory_space_for_execution_space {
145  using type = typename ExecSpace::memory_space;
146 };
147 
148 #if defined(KOKKOS_ENABLE_CUDA)
149 template <>
150 struct default_tasking_memory_space_for_execution_space<Kokkos::Cuda> {
151  using type = Kokkos::CudaUVMSpace;
152 };
153 #endif
154 
155 template <class ExecSpace>
156 using default_tasking_memory_space_for_execution_space_t =
157  typename default_tasking_memory_space_for_execution_space<ExecSpace>::type;
158 
159 } // namespace Impl
160 } // namespace Kokkos
161 
162 //----------------------------------------------------------------------------
163 
164 namespace Kokkos {
165 
166 template <typename Space>
167 using DeprecatedTaskScheduler = BasicTaskScheduler<
168  Space,
169  Impl::TaskQueue<
170  Space,
171  Impl::default_tasking_memory_space_for_execution_space_t<Space>>>;
172 
173 template <typename Space>
174 using DeprecatedTaskSchedulerMultiple = BasicTaskScheduler<
175  Space,
176  Impl::TaskQueueMultiple<
177  Space,
178  Impl::default_tasking_memory_space_for_execution_space_t<Space>>>;
179 
180 template <typename Space>
181 using TaskScheduler = SimpleTaskScheduler<
182  Space,
183  Impl::SingleTaskQueue<
184  Space, Impl::default_tasking_memory_space_for_execution_space_t<Space>,
185  Impl::TaskQueueTraitsLockBased>>;
186 
187 template <typename Space>
188 using TaskSchedulerMultiple = SimpleTaskScheduler<
189  Space,
190  Impl::MultipleTaskQueue<
191  Space, Impl::default_tasking_memory_space_for_execution_space_t<Space>,
192  Impl::TaskQueueTraitsLockBased,
193  Kokkos::MemoryPool<Kokkos::Device<
194  Space,
195  Impl::default_tasking_memory_space_for_execution_space_t<Space>>>>>;
196 
197 template <typename Space>
198 using ChaseLevTaskScheduler = SimpleTaskScheduler<
199  Space,
200  Impl::MultipleTaskQueue<
201  Space, Impl::default_tasking_memory_space_for_execution_space_t<Space>,
202  Impl::TaskQueueTraitsChaseLev<>,
203  Kokkos::MemoryPool<Kokkos::Device<
204  Space,
205  Impl::default_tasking_memory_space_for_execution_space_t<Space>>>>>;
206 
207 template <class Space, class QueueType>
208 void wait(BasicTaskScheduler<Space, QueueType> const&);
209 
210 namespace Impl {
211 
212 struct TaskSchedulerBase {};
213 
214 class TaskQueueBase {};
215 
216 template <typename Scheduler, typename EnableIfConstraint = void>
217 class TaskQueueSpecializationConstrained {};
218 
219 template <typename Scheduler>
220 struct TaskQueueSpecialization : TaskQueueSpecializationConstrained<Scheduler> {
221 };
222 
223 template <int, typename>
224 struct TaskPolicyData;
225 
226 } // end namespace Impl
227 
228 } // namespace Kokkos
229 
230 //----------------------------------------------------------------------------
231 
232 #endif /* #if defined( KOKKOS_ENABLE_TASKDAG ) */
233 #endif /* #ifndef KOKKOS_TASKSCHEDULER_FWD_HPP */
Definition: dummy.cpp:3