22 inline namespace _V1 {
25 const async_handler &AsyncHandler,
const property_list &PropList) {
26 const std::vector<device> Devs = SyclContext.get_devices();
32 const device &SyclDevice = *std::max_element(Devs.begin(), Devs.end(), Comp);
34 impl = std::make_shared<detail::queue_impl>(
41 impl = std::make_shared<detail::queue_impl>(
48 impl = std::make_shared<detail::queue_impl>(
54 :
queue(SyclContext, deviceSelector,
60 :
queue(SyclContext, SyclDevice,
67 impl = std::make_shared<detail::queue_impl>(
72 cl_command_queue
queue::get()
const {
return impl->get(); }
79 return impl->getCommandGraph()
87 auto Graph = impl->getCommandGraph();
91 "ext_oneapi_get_graph() can only be called on recording queues.");
98 bool queue::is_host()
const {
99 bool IsHost = impl->is_host();
100 assert(!IsHost &&
"queue::is_host should not be called in implementation.");
109 return impl->memset(impl, Ptr, Value, Count, {});
115 return impl->memset(impl, Ptr, Value, Count, {DepEvent});
119 const std::vector<event> &DepEvents,
122 return impl->memset(impl, Ptr, Value, Count, DepEvents);
128 return impl->memcpy(impl, Dest, Src, Count, {}, CodeLoc);
134 return impl->memcpy(impl, Dest, Src, Count, {DepEvent}, CodeLoc);
138 const std::vector<event> &DepEvents,
141 return impl->memcpy(impl, Dest, Src, Count, DepEvents, CodeLoc);
153 return impl->mem_advise(impl, Ptr, Length,
pi_mem_advice(Advice), {});
159 return impl->mem_advise(impl, Ptr, Length,
pi_mem_advice(Advice), {DepEvent});
163 const std::vector<event> &DepEvents,
166 return impl->mem_advise(impl, Ptr, Length,
pi_mem_advice(Advice), DepEvents);
169 event queue::discard_or_return(
const event &Event) {
170 if (!(impl->MDiscardEvents))
173 auto Impl = std::make_shared<event_impl>(event_impl::HES_Discarded);
174 return detail::createSyclObjFromImpl<event>(Impl);
177 event queue::submit_impl(std::function<
void(
handler &)> CGH,
178 const detail::code_location &CodeLoc) {
179 return impl->submit(CGH, impl, CodeLoc);
182 event queue::submit_impl(std::function<
void(handler &)> CGH, queue SecondQueue,
183 const detail::code_location &CodeLoc) {
184 return impl->submit(CGH, impl, SecondQueue.impl, CodeLoc);
187 event queue::submit_impl_and_postprocess(
188 std::function<
void(handler &)> CGH,
const detail::code_location &CodeLoc,
189 const SubmitPostProcessF &PostProcess) {
190 return impl->submit(CGH, impl, CodeLoc, &PostProcess);
193 event queue::submit_impl_and_postprocess(
194 std::function<
void(handler &)> CGH, queue SecondQueue,
195 const detail::code_location &CodeLoc,
196 const SubmitPostProcessF &PostProcess) {
197 return impl->submit(CGH, impl, SecondQueue.impl, CodeLoc, &PostProcess);
205 impl->wait_and_throw(CodeLoc);
214 assert(!QueueImpl->getCommandGraph() &&
215 "Should not be called in on graph recording.");
217 auto LastEvent = QueueImpl->getLastEvent();
218 if (QueueImpl->MDiscardEvents) {
219 std::cout <<
"Discard event enabled" << std::endl;
228 if (!LastEventImpl->isContextInitialized()) {
229 LastEventImpl->associateWithQueue(QueueImpl);
230 LastEventImpl->setSubmissionTime();
232 return detail::createSyclObjFromImpl<event>(LastEventImpl);
261 begin(WaitList), end(WaitList), [&](
const event &Event) ->
bool {
263 return !EventImpl->isContextInitialized() || EventImpl->isNOP();
265 if (
is_in_order() && !impl->getCommandGraph() && AllEventsEmptyOrNop)
272 template <
typename Param>
275 return impl->get_info<Param>();
278 #define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, Picode) \
279 template __SYCL_EXPORT ReturnT queue::get_info<info::queue::Desc>() const;
281 #include <sycl/info/queue_traits.def>
283 #undef __SYCL_PARAM_TRAITS_SPEC
285 template <
typename Param>
288 return impl->get_backend_info<Param>();
291 #define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, Picode) \
292 template __SYCL_EXPORT ReturnT \
293 queue::get_backend_info<info::DescType::Desc>() const;
295 #include <sycl/info/sycl_backend_traits.def>
297 #undef __SYCL_PARAM_TRAITS_SPEC
300 return impl->has_property<PropertyT>();
304 return impl->get_property<PropertyT>();
307 #define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \
308 template __SYCL_EXPORT bool queue::has_property<NS_QUALIFIER::PROP_NAME>() \
310 template __SYCL_EXPORT NS_QUALIFIER::PROP_NAME \
311 queue::get_property<NS_QUALIFIER::PROP_NAME>() const;
313 #define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \
314 __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME)
316 #include <sycl/properties/queue_properties.def>
319 return impl->has_property<property::queue::in_order>();
327 return impl->getNative(NativeHandleDesc);
330 event queue::memcpyToDeviceGlobal(
void *DeviceGlobalPtr,
const void *Src,
331 bool IsDeviceImageScope,
size_t NumBytes,
333 const std::vector<event> &DepEvents) {
334 return impl->memcpyToDeviceGlobal(impl, DeviceGlobalPtr, Src,
335 IsDeviceImageScope, NumBytes, Offset,
339 event queue::memcpyFromDeviceGlobal(
void *Dest,
const void *DeviceGlobalPtr,
340 bool IsDeviceImageScope,
size_t NumBytes,
342 const std::vector<event> &DepEvents) {
343 return impl->memcpyFromDeviceGlobal(impl, Dest, DeviceGlobalPtr,
344 IsDeviceImageScope, NumBytes, Offset,
348 bool queue::device_has(aspect Aspect)
const {
350 return impl->getDeviceImplPtr()->has(Aspect);
354 return impl->has_property<
362 "ext_oneapi_get_last_event() can only be called on in-order queues.");
363 if (impl->MDiscardEvents)
366 "ext_oneapi_get_last_event() cannot be called on queues with the "
367 "ext::oneapi::property::queue::discard_events property.");
368 return impl->getLastEvent();
374 "ext_oneapi_set_external_event() can only be called "
375 "on in-order queues.");
376 if (impl->MDiscardEvents)
379 "ext_oneapi_set_external_event() cannot be called on queues with the "
380 "ext::oneapi::property::queue::discard_events property.");
381 return impl->setExternalEvent(external_event);
390 return std::hash<unsigned long long>()(
The context class represents a SYCL context on which kernel functions may be executed.
Data type that manages the code_location information in TLS.
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Graph in the modifiable state.
Command group handler class.
void ext_oneapi_barrier()
Prevents any commands submitted afterward to this queue from executing until all commands previously ...
Objects of the property_list class are containers for the SYCL properties.
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
bool ext_oneapi_empty() const
Allows to check status of the queue (completed vs noncompleted).
const property_list & PropList
event memcpy(void *Dest, const void *Src, size_t Count, const detail::code_location &CodeLoc=detail::code_location::current())
Copies data from one memory region to another, each is either a host pointer or a pointer within USM ...
queue(const property_list &PropList={})
Constructs a SYCL queue instance using the device returned by an instance of default_selector.
bool is_in_order() const
Returns whether the queue is in order or OoO.
event memset(void *Ptr, int Value, size_t Count, const detail::code_location &CodeLoc=detail::code_location::current())
Fills the memory pointed by a USM pointer with the value specified.
pi_native_handle getNative(int32_t &NativeHandleDesc) const
const device_selector const async_handler & AsyncHandler
device get_device() const
backend get_backend() const noexcept
Returns the backend associated with this queue.
void ext_oneapi_set_external_event(const event &external_event)
bool ext_codeplay_supports_fusion() const
Returns true if the queue was created with the ext::codeplay::experimental::property::queue::enable_f...
void wait_and_throw_proxy(const detail::code_location &CodeLoc)
Proxy method for wait_and_throw to forward the code location information to the implementation.
event ext_oneapi_get_last_event() const
event ext_oneapi_submit_barrier(const detail::code_location &CodeLoc=detail::code_location::current())
Prevents any commands submitted afterward to this queue from executing until all commands previously ...
ext::oneapi::experimental::queue_state ext_oneapi_get_state() const
context get_context() const
bool has_property() const noexcept
detail::is_queue_info_desc< Param >::return_type get_info() const
Queries SYCL queue for information.
event mem_advise(const void *Ptr, size_t Length, pi_mem_advice Advice, const detail::code_location &CodeLoc=detail::code_location::current())
Provides additional information to the underlying runtime about how different allocations are used.
detail::is_backend_info_desc< Param >::return_type get_backend_info() const
Queries SYCL queue for SYCL backend-specific information.
const device_selector & DeviceSelector
ext::oneapi::experimental::command_graph< ext::oneapi::experimental::graph_state::modifiable > ext_oneapi_get_graph() const
std::enable_if_t< std::is_invocable_r_v< void, T, handler & >, event > submit(T CGF, const detail::code_location &CodeLoc=detail::code_location::current())
Submits a command group function object to the queue, in order to be scheduled for execution on the d...
PropertyT get_property() const
void wait_proxy(const detail::code_location &CodeLoc)
Proxy method for wait to forward the code location information to the implementation.
void throw_asynchronous()
Checks if any asynchronous errors have been produced by the queue and if so reports them to the async...
__SYCL_EXTERN_STREAM_ATTRS ostream cout
Linked to standard output.
constexpr tuple_element< I, tuple< Types... > >::type & get(sycl::detail::tuple< Types... > &Arg) noexcept
backend getImplBackend(const T &Impl)
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
T createSyclObjFromImpl(decltype(T::impl) ImplObj)
std::shared_ptr< sycl::detail::queue_impl > QueueImplPtr
@ modifiable
In modifiable state, commands can be added to graph.
static event getBarrierEventForInorderQueueHelper(const detail::QueueImplPtr QueueImpl)
std::function< void(sycl::exception_list)> async_handler
std::error_code make_error_code(sycl::errc E) noexcept
Constructs an error code using e and sycl_category()
uintptr_t pi_native_handle
_pi_mem_advice pi_mem_advice
bool all_of(const simd_mask< _Tp, _Abi > &) noexcept
_Abi const simd< _Tp, _Abi > & noexcept
size_t operator()(const sycl::queue &Q) const