Kokkos Core Kernels Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Kokkos_TaskScheduler_fwd.hpp
1 //@HEADER
2 // ************************************************************************
3 //
4 // Kokkos v. 4.0
5 // Copyright (2022) National Technology & Engineering
6 // Solutions of Sandia, LLC (NTESS).
7 //
8 // Under the terms of Contract DE-NA0003525 with NTESS,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
12 // See https://kokkos.org/LICENSE for license information.
13 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
14 //
15 //@HEADER
16 
17 #ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
18 #include <Kokkos_Macros.hpp>
19 static_assert(false,
20  "Including non-public Kokkos header files is not allowed.");
21 #endif
22 #ifndef KOKKOS_TASKSCHEDULER_FWD_HPP
23 #define KOKKOS_TASKSCHEDULER_FWD_HPP
24 
25 //----------------------------------------------------------------------------
26 
27 #include <cstddef>
28 #include <Kokkos_Macros.hpp>
29 #if defined(KOKKOS_ENABLE_TASKDAG)
30 
31 #include <Kokkos_Core_fwd.hpp>
32 //----------------------------------------------------------------------------
33 
34 namespace Kokkos {
35 
36 // Forward declarations used in Impl::TaskQueue
37 
38 template <typename ValueType, typename Scheduler>
39 class BasicFuture;
40 
41 template <class Space, class Queue>
42 class SimpleTaskScheduler;
43 
44 template <class Space, class Queue>
45 class BasicTaskScheduler;
46 
47 template <typename Space>
48 struct is_scheduler : public std::false_type {};
49 
50 template <class Space, class Queue>
51 struct is_scheduler<BasicTaskScheduler<Space, Queue>> : public std::true_type {
52 };
53 
54 template <class Space, class Queue>
55 struct is_scheduler<SimpleTaskScheduler<Space, Queue>> : public std::true_type {
56 };
57 
58 enum class TaskPriority : int { High = 0, Regular = 1, Low = 2 };
59 
60 } // namespace Kokkos
61 
62 //----------------------------------------------------------------------------
63 
64 namespace Kokkos {
65 
66 template <class Device>
67 class MemoryPool;
68 
69 namespace Impl {
70 
71 template <class TaskQueueTraits>
72 class TaskNode;
73 
74 class TaskBase;
75 
76 /*\brief Implementation data for task data management, access, and execution.
77  * (Deprecated)
78  * CRTP Inheritance structure to allow static_cast from the
79  * task root type and a task's FunctorType.
80  *
81  * TaskBase< Space , ResultType , FunctorType >
82  * : TaskBase< Space , ResultType , void >
83  * , FunctorType
84  * { ... };
85  *
86  * TaskBase< Space , ResultType , void >
87  * : TaskBase< Space , void , void >
88  * { ... };
89  */
90 template <typename Space, typename ResultType, typename FunctorType>
91 class Task;
92 
93 class TaskQueueBase;
94 
95 template <typename Space, typename MemorySpace>
96 class TaskQueue;
97 
98 template <typename ExecSpace, typename MemorySpace>
99 class TaskQueueMultiple;
100 
101 template <typename ExecSpace, typename MemSpace, typename TaskQueueTraits,
102  class MemoryPool =
103  Kokkos::MemoryPool<Kokkos::Device<ExecSpace, MemSpace>>>
104 class SingleTaskQueue;
105 
106 template <typename ExecSpace, typename MemSpace, typename TaskQueueTraits,
107  class MemoryPool>
108 class MultipleTaskQueue;
109 
110 struct TaskQueueTraitsLockBased;
111 
112 template <size_t CircularBufferSize = 64>
113 struct TaskQueueTraitsChaseLev;
114 
115 template <typename ResultType>
116 struct TaskResult;
117 
118 struct TaskSchedulerBase;
119 
120 template <class ExecSpace>
121 struct default_tasking_memory_space_for_execution_space {
122  using type = typename ExecSpace::memory_space;
123 };
124 
125 #if defined(KOKKOS_ENABLE_CUDA)
126 template <>
127 struct default_tasking_memory_space_for_execution_space<Kokkos::Cuda> {
128  using type = Kokkos::CudaUVMSpace;
129 };
130 #endif
131 
132 template <class ExecSpace>
133 using default_tasking_memory_space_for_execution_space_t =
134  typename default_tasking_memory_space_for_execution_space<ExecSpace>::type;
135 
136 } // namespace Impl
137 } // namespace Kokkos
138 
139 //----------------------------------------------------------------------------
140 
141 namespace Kokkos {
142 
143 template <typename Space>
144 using DeprecatedTaskScheduler = BasicTaskScheduler<
145  Space,
146  Impl::TaskQueue<
147  Space,
148  Impl::default_tasking_memory_space_for_execution_space_t<Space>>>;
149 
150 template <typename Space>
151 using DeprecatedTaskSchedulerMultiple = BasicTaskScheduler<
152  Space,
153  Impl::TaskQueueMultiple<
154  Space,
155  Impl::default_tasking_memory_space_for_execution_space_t<Space>>>;
156 
157 template <typename Space>
158 using TaskScheduler = SimpleTaskScheduler<
159  Space,
160  Impl::SingleTaskQueue<
161  Space, Impl::default_tasking_memory_space_for_execution_space_t<Space>,
162  Impl::TaskQueueTraitsLockBased>>;
163 
164 template <typename Space>
165 using TaskSchedulerMultiple = SimpleTaskScheduler<
166  Space,
167  Impl::MultipleTaskQueue<
168  Space, Impl::default_tasking_memory_space_for_execution_space_t<Space>,
169  Impl::TaskQueueTraitsLockBased,
170  Kokkos::MemoryPool<Kokkos::Device<
171  Space,
172  Impl::default_tasking_memory_space_for_execution_space_t<Space>>>>>;
173 
174 template <typename Space>
175 using ChaseLevTaskScheduler = SimpleTaskScheduler<
176  Space,
177  Impl::MultipleTaskQueue<
178  Space, Impl::default_tasking_memory_space_for_execution_space_t<Space>,
179  Impl::TaskQueueTraitsChaseLev<>,
180  Kokkos::MemoryPool<Kokkos::Device<
181  Space,
182  Impl::default_tasking_memory_space_for_execution_space_t<Space>>>>>;
183 
184 template <class Space, class QueueType>
185 void wait(BasicTaskScheduler<Space, QueueType> const&);
186 
187 namespace Impl {
188 
189 struct TaskSchedulerBase {};
190 
191 class TaskQueueBase {};
192 
193 template <typename Scheduler, typename EnableIfConstraint = void>
194 class TaskQueueSpecializationConstrained {};
195 
196 template <typename Scheduler>
197 struct TaskQueueSpecialization : TaskQueueSpecializationConstrained<Scheduler> {
198 };
199 
200 template <int, typename>
201 struct TaskPolicyData;
202 
203 } // end namespace Impl
204 
205 } // namespace Kokkos
206 
207 //----------------------------------------------------------------------------
208 
209 #endif /* #if defined( KOKKOS_ENABLE_TASKDAG ) */
210 #endif /* #ifndef KOKKOS_TASKSCHEDULER_FWD_HPP */