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 #ifdef KOKKOS_ENABLE_DEPRECATION_WARNINGS
35 // We allow using deprecated classes in this file
36 KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_PUSH()
37 #endif
38 
39 namespace Kokkos {
40 
41 // Forward declarations used in Impl::TaskQueue
42 
43 template <typename ValueType, typename Scheduler>
44 class KOKKOS_DEPRECATED BasicFuture;
45 
46 template <class Space, class Queue>
47 class KOKKOS_DEPRECATED SimpleTaskScheduler;
48 
49 template <class Space, class Queue>
50 class KOKKOS_DEPRECATED BasicTaskScheduler;
51 
52 template <typename Space>
53 struct KOKKOS_DEPRECATED is_scheduler : public std::false_type {};
54 
55 template <class Space, class Queue>
56 struct KOKKOS_DEPRECATED is_scheduler<BasicTaskScheduler<Space, Queue>>
57  : public std::true_type {};
58 
59 template <class Space, class Queue>
60 struct KOKKOS_DEPRECATED is_scheduler<SimpleTaskScheduler<Space, Queue>>
61  : public std::true_type {};
62 
63 enum class KOKKOS_DEPRECATED TaskPriority : int {
64  High = 0,
65  Regular = 1,
66  Low = 2
67 };
68 
69 } // namespace Kokkos
70 
71 //----------------------------------------------------------------------------
72 
73 namespace Kokkos {
74 
75 template <class Device>
76 class MemoryPool;
77 
78 namespace Impl {
79 
80 template <class TaskQueueTraits>
81 class TaskNode;
82 
83 class TaskBase;
84 
85 /*\brief Implementation data for task data management, access, and execution.
86  * (Deprecated)
87  * CRTP Inheritance structure to allow static_cast from the
88  * task root type and a task's FunctorType.
89  *
90  * TaskBase< Space , ResultType , FunctorType >
91  * : TaskBase< Space , ResultType , void >
92  * , FunctorType
93  * { ... };
94  *
95  * TaskBase< Space , ResultType , void >
96  * : TaskBase< Space , void , void >
97  * { ... };
98  */
99 template <typename Space, typename ResultType, typename FunctorType>
100 class Task;
101 
102 class TaskQueueBase;
103 
104 template <typename Space, typename MemorySpace>
105 class TaskQueue;
106 
107 template <typename ExecSpace, typename MemorySpace>
108 class TaskQueueMultiple;
109 
110 template <typename ExecSpace, typename MemSpace, typename TaskQueueTraits,
111  class MemoryPool =
112  Kokkos::MemoryPool<Kokkos::Device<ExecSpace, MemSpace>>>
113 class SingleTaskQueue;
114 
115 template <typename ExecSpace, typename MemSpace, typename TaskQueueTraits,
116  class MemoryPool>
117 class MultipleTaskQueue;
118 
119 struct TaskQueueTraitsLockBased;
120 
121 template <size_t CircularBufferSize = 64>
122 struct TaskQueueTraitsChaseLev;
123 
124 template <typename ResultType>
125 struct TaskResult;
126 
127 struct TaskSchedulerBase;
128 
129 template <class ExecSpace>
130 struct default_tasking_memory_space_for_execution_space {
131  using type = typename ExecSpace::memory_space;
132 };
133 
134 #if defined(KOKKOS_ENABLE_CUDA)
135 template <>
136 struct default_tasking_memory_space_for_execution_space<Kokkos::Cuda> {
137  using type = Kokkos::CudaUVMSpace;
138 };
139 #endif
140 
141 template <class ExecSpace>
142 using default_tasking_memory_space_for_execution_space_t =
143  typename default_tasking_memory_space_for_execution_space<ExecSpace>::type;
144 
145 } // namespace Impl
146 } // namespace Kokkos
147 
148 //----------------------------------------------------------------------------
149 
150 namespace Kokkos {
151 
152 template <typename Space>
153 using DeprecatedTaskScheduler KOKKOS_DEPRECATED = BasicTaskScheduler<
154  Space,
155  Impl::TaskQueue<
156  Space,
157  Impl::default_tasking_memory_space_for_execution_space_t<Space>>>;
158 
159 template <typename Space>
160 using DeprecatedTaskSchedulerMultiple KOKKOS_DEPRECATED = BasicTaskScheduler<
161  Space,
162  Impl::TaskQueueMultiple<
163  Space,
164  Impl::default_tasking_memory_space_for_execution_space_t<Space>>>;
165 
166 template <typename Space>
167 using TaskScheduler KOKKOS_DEPRECATED = SimpleTaskScheduler<
168  Space,
169  Impl::SingleTaskQueue<
170  Space, Impl::default_tasking_memory_space_for_execution_space_t<Space>,
171  Impl::TaskQueueTraitsLockBased>>;
172 
173 template <typename Space>
174 using TaskSchedulerMultiple KOKKOS_DEPRECATED = SimpleTaskScheduler<
175  Space,
176  Impl::MultipleTaskQueue<
177  Space, Impl::default_tasking_memory_space_for_execution_space_t<Space>,
178  Impl::TaskQueueTraitsLockBased,
179  Kokkos::MemoryPool<Kokkos::Device<
180  Space,
181  Impl::default_tasking_memory_space_for_execution_space_t<Space>>>>>;
182 
183 template <typename Space>
184 using ChaseLevTaskScheduler KOKKOS_DEPRECATED = SimpleTaskScheduler<
185  Space,
186  Impl::MultipleTaskQueue<
187  Space, Impl::default_tasking_memory_space_for_execution_space_t<Space>,
188  Impl::TaskQueueTraitsChaseLev<>,
189  Kokkos::MemoryPool<Kokkos::Device<
190  Space,
191  Impl::default_tasking_memory_space_for_execution_space_t<Space>>>>>;
192 
193 template <class Space, class QueueType>
194 KOKKOS_DEPRECATED void wait(BasicTaskScheduler<Space, QueueType> const&);
195 
196 namespace Impl {
197 
198 struct TaskSchedulerBase {};
199 
200 class TaskQueueBase {};
201 
202 template <typename Scheduler, typename EnableIfConstraint = void>
203 class TaskQueueSpecializationConstrained {};
204 
205 template <typename Scheduler>
206 struct TaskQueueSpecialization : TaskQueueSpecializationConstrained<Scheduler> {
207 };
208 
209 template <int, typename>
210 struct TaskPolicyData;
211 
212 } // end namespace Impl
213 
214 } // namespace Kokkos
215 
216 #ifdef KOKKOS_ENABLE_DEPRECATION_WARNINGS
217 KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_POP()
218 #endif
219 
220 //----------------------------------------------------------------------------
221 
222 #endif /* #if defined( KOKKOS_ENABLE_TASKDAG ) */
223 #endif /* #ifndef KOKKOS_TASKSCHEDULER_FWD_HPP */