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
57namespace Kokkos {
58
59// Forward declarations used in Impl::TaskQueue
60
61template <typename ValueType, typename Scheduler>
62class BasicFuture;
63
64template <class Space, class Queue>
65class SimpleTaskScheduler;
66
67template <class Space, class Queue>
68class BasicTaskScheduler;
69
70template <typename Space>
71struct is_scheduler : public std::false_type {};
72
73template <class Space, class Queue>
74struct is_scheduler<BasicTaskScheduler<Space, Queue>> : public std::true_type {
75};
76
77template <class Space, class Queue>
78struct is_scheduler<SimpleTaskScheduler<Space, Queue>> : public std::true_type {
79};
80
81enum class TaskPriority : int { High = 0, Regular = 1, Low = 2 };
82
83} // namespace Kokkos
84
85//----------------------------------------------------------------------------
86
87namespace Kokkos {
88
89template <class Device>
90class MemoryPool;
91
92namespace Impl {
93
94template <class TaskQueueTraits>
95class TaskNode;
96
97class 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 */
113template <typename Space, typename ResultType, typename FunctorType>
114class Task;
115
116class TaskQueueBase;
117
118template <typename Space, typename MemorySpace>
119class TaskQueue;
120
121template <typename ExecSpace, typename MemorySpace>
122class TaskQueueMultiple;
123
124template <typename ExecSpace, typename MemSpace, typename TaskQueueTraits,
125 class MemoryPool =
126 Kokkos::MemoryPool<Kokkos::Device<ExecSpace, MemSpace>>>
127class SingleTaskQueue;
128
129template <typename ExecSpace, typename MemSpace, typename TaskQueueTraits,
130 class MemoryPool>
131class MultipleTaskQueue;
132
133struct TaskQueueTraitsLockBased;
134
135template <size_t CircularBufferSize = 64>
136struct TaskQueueTraitsChaseLev;
137
138template <typename ResultType>
139struct TaskResult;
140
141struct TaskSchedulerBase;
142
143template <class ExecSpace>
144struct default_tasking_memory_space_for_execution_space {
145 using type = typename ExecSpace::memory_space;
146};
147
148#if defined(KOKKOS_ENABLE_CUDA)
149template <>
150struct default_tasking_memory_space_for_execution_space<Kokkos::Cuda> {
151 using type = Kokkos::CudaUVMSpace;
152};
153#endif
154
155template <class ExecSpace>
156using 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
164namespace Kokkos {
165
166template <typename Space>
167using DeprecatedTaskScheduler = BasicTaskScheduler<
168 Space,
169 Impl::TaskQueue<
170 Space,
171 Impl::default_tasking_memory_space_for_execution_space_t<Space>>>;
172
173template <typename Space>
174using DeprecatedTaskSchedulerMultiple = BasicTaskScheduler<
175 Space,
176 Impl::TaskQueueMultiple<
177 Space,
178 Impl::default_tasking_memory_space_for_execution_space_t<Space>>>;
179
180template <typename Space>
181using TaskScheduler = SimpleTaskScheduler<
182 Space,
183 Impl::SingleTaskQueue<
184 Space, Impl::default_tasking_memory_space_for_execution_space_t<Space>,
185 Impl::TaskQueueTraitsLockBased>>;
186
187template <typename Space>
188using 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
197template <typename Space>
198using 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
207template <class Space, class QueueType>
208void wait(BasicTaskScheduler<Space, QueueType> const&);
209
210namespace Impl {
211
212struct TaskSchedulerBase {};
213
214class TaskQueueBase {};
215
216template <typename Scheduler, typename EnableIfConstraint = void>
217class TaskQueueSpecializationConstrained {};
218
219template <typename Scheduler>
220struct TaskQueueSpecialization : TaskQueueSpecializationConstrained<Scheduler> {
221};
222
223template <int, typename>
224struct 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 */