DPC++ Runtime
Runtime libraries for oneAPI DPC++
handler_impl.hpp
Go to the documentation of this file.
1 //==---------------- handler_impl.hpp - SYCL handler -----------------------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
11 #include "sycl/handler.hpp"
12 #include <detail/cg.hpp>
14 #include <memory>
16 
17 namespace sycl {
18 inline namespace _V1 {
19 namespace ext::oneapi::experimental::detail {
20 class dynamic_parameter_impl;
21 }
22 namespace detail {
23 
24 using KernelBundleImplPtr = std::shared_ptr<detail::kernel_bundle_impl>;
25 
26 enum class HandlerSubmissionState : std::uint8_t {
27  NO_STATE = 0,
30 };
31 
32 class handler_impl {
33 public:
34  handler_impl(std::shared_ptr<queue_impl> SubmissionPrimaryQueue,
35  std::shared_ptr<queue_impl> SubmissionSecondaryQueue,
36  bool EventNeeded)
37  : MSubmissionPrimaryQueue(std::move(SubmissionPrimaryQueue)),
38  MSubmissionSecondaryQueue(std::move(SubmissionSecondaryQueue)),
39  MEventNeeded(EventNeeded) {};
40 
42  std::shared_ptr<ext::oneapi::experimental::detail::graph_impl> Graph)
43  : MGraph{Graph} {}
44 
45  handler_impl() = default;
46 
49  throw sycl::exception(
51  "Kernel bundle cannot be explicitly set after a specialization "
52  "constant has been set");
54  }
55 
57  if (MSubmissionState ==
60  "Specialization constants cannot be set after "
61  "explicitly setting the used kernel bundle");
63  }
64 
66  return MSubmissionState ==
68  }
69 
72 
76  std::shared_ptr<queue_impl> MSubmissionPrimaryQueue;
77 
82  std::shared_ptr<queue_impl> MSubmissionSecondaryQueue;
83 
86  bool MEventNeeded = true;
87 
88  // Stores auxiliary resources used by internal operations.
89  std::vector<std::shared_ptr<const void>> MAuxiliaryResources;
90 
91  std::shared_ptr<detail::kernel_bundle_impl> MKernelBundle;
92 
93  ur_usm_advice_flags_t MAdvice;
94 
95  // 2D memory operation information.
96  size_t MSrcPitch;
97  size_t MDstPitch;
98  size_t MWidth;
99  size_t MHeight;
100 
102  size_t MOffset = 0;
105  bool MIsDeviceImageScoped = false;
106 
107  // Program scope pipe information.
108 
109  // Pipe name that uniquely identifies a pipe.
110  std::string HostPipeName;
111  // Pipe host pointer, the address of its constexpr __pipe member.
112  void *HostPipePtr = nullptr;
113  // Host pipe read write operation is blocking.
114  bool HostPipeBlocking = false;
115  // The size of returned type for each read.
116  size_t HostPipeTypeSize = 0;
117  // If the pipe operation is read or write, 1 for read 0 for write.
118  bool HostPipeRead = true;
119 
120  ur_kernel_cache_config_t MKernelCacheConfig = UR_KERNEL_CACHE_CONFIG_DEFAULT;
121 
122  bool MKernelIsCooperative = false;
124 
125  // Extra information for bindless image copy
126  ur_image_desc_t MSrcImageDesc;
127  ur_image_desc_t MDstImageDesc;
128  ur_image_format_t MSrcImageFormat;
129  ur_image_format_t MDstImageFormat;
130  ur_exp_image_copy_flags_t MImageCopyFlags;
131 
132  ur_rect_offset_t MSrcOffset;
133  ur_rect_offset_t MDestOffset;
134  ur_rect_region_t MCopyExtent;
135 
136  // Extra information for semaphore interoperability
137  ur_exp_interop_semaphore_handle_t MInteropSemaphoreHandle;
138  std::optional<uint64_t> MWaitValue;
139  std::optional<uint64_t> MSignalValue;
140 
141  // The user facing node type, used for operations which are recorded to a
142  // graph. Since some operations may actually be a different type than the user
143  // submitted, e.g. a fill() which is performed as a kernel submission. This is
144  // used to pass the type that the user expects to graph nodes when they are
145  // created for later query by users.
148 
149  // Storage for any SYCL Graph dynamic parameters which have been flagged for
150  // registration in the CG, along with the argument index for the parameter.
151  std::vector<std::pair<
154 
155  // Track whether an NDRange was used when submitting a kernel (as opposed to a
156  // range), needed for graph update
157  bool MNDRangeUsed = false;
158 
164 
166  std::vector<detail::ArgDesc> MArgs;
167 
171  std::vector<detail::ArgDesc> MAssociatedAccesors;
172 
175 
180 
182  std::shared_ptr<ext::oneapi::experimental::detail::graph_impl> MGraph;
185  std::shared_ptr<ext::oneapi::experimental::detail::exec_graph_impl>
188  std::shared_ptr<ext::oneapi::experimental::detail::node_impl> MSubgraphNode;
190  std::unique_ptr<detail::CG> MGraphNodeCG;
191 
193  std::shared_ptr<detail::HostTask> MHostTask;
196  std::vector<detail::EventImplPtr> MEventsWaitWithBarrier;
197 };
198 
199 } // namespace detail
200 } // namespace _V1
201 } // namespace sycl
detail::NDRDescT MNDRDesc
Struct that encodes global size, local size, ...
std::shared_ptr< queue_impl > MSubmissionSecondaryQueue
Shared pointer to the secondary queue implementation.
std::vector< std::shared_ptr< const void > > MAuxiliaryResources
detail::CGType MCGType
Type of the command group, e.g.
ur_usm_advice_flags_t MAdvice
std::optional< uint64_t > MSignalValue
HandlerSubmissionState MSubmissionState
Registers mutually exclusive submission states.
std::unique_ptr< detail::CG > MGraphNodeCG
Storage for the CG created when handling graph nodes added explicitly.
std::shared_ptr< ext::oneapi::experimental::detail::node_impl > MSubgraphNode
Storage for a node created from a subgraph submission.
bool MIsDeviceImageScoped
Boolean flag for whether the device_global had the device_image_scope property.
std::shared_ptr< detail::HostTask > MHostTask
Storage for lambda/function when using HostTask.
std::shared_ptr< queue_impl > MSubmissionPrimaryQueue
Shared pointer to the primary queue implementation.
sycl::ext::oneapi::experimental::node_type MUserFacingNodeType
ur_kernel_cache_config_t MKernelCacheConfig
ur_exp_image_copy_flags_t MImageCopyFlags
std::shared_ptr< ext::oneapi::experimental::detail::graph_impl > MGraph
The graph that is associated with this handler.
std::shared_ptr< detail::kernel_bundle_impl > MKernelBundle
handler_impl(std::shared_ptr< queue_impl > SubmissionPrimaryQueue, std::shared_ptr< queue_impl > SubmissionSecondaryQueue, bool EventNeeded)
detail::CG::StorageInitHelper CGData
The storage for the arguments passed.
size_t MOffset
Offset into a device_global for copy operations.
std::vector< detail::ArgDesc > MArgs
The list of arguments for the kernel.
std::optional< uint64_t > MWaitValue
std::vector< detail::ArgDesc > MAssociatedAccesors
The list of associated accessors with this handler.
std::shared_ptr< ext::oneapi::experimental::detail::exec_graph_impl > MExecGraph
If we are submitting a graph using ext_oneapi_graph this will be the graph to be executed.
bool MEventNeeded
Bool stores information about whether the event resulting from the corresponding work is required.
ur_exp_interop_semaphore_handle_t MInteropSemaphoreHandle
std::vector< detail::EventImplPtr > MEventsWaitWithBarrier
The list of valid SYCL events that need to complete before barrier command can be executed.
handler_impl(std::shared_ptr< ext::oneapi::experimental::detail::graph_impl > Graph)
std::vector< std::pair< ext::oneapi::experimental::detail::dynamic_parameter_impl *, int > > MDynamicParameters
CGType
Type of the command group.
Definition: cg_types.hpp:42
std::shared_ptr< detail::kernel_bundle_impl > KernelBundleImplPtr
std::error_code make_error_code(sycl::errc E) noexcept
Constructs an error code using e and sycl_category()
Definition: exception.cpp:65
Definition: access.hpp:18