#include <detail/event_impl.hpp>
Public Types | |
enum | HostEventState : int { HES_NotComplete = 0 , HES_Complete , HES_Discarded } |
Public Member Functions | |
event_impl (std::optional< HostEventState > State=HES_Complete) | |
Constructs a ready SYCL event. More... | |
event_impl (ur_event_handle_t Event, const context &SyclContext) | |
Constructs an event instance from a plug-in event handle. More... | |
event_impl (const QueueImplPtr &Queue) | |
void | wait (std::shared_ptr< sycl::detail::event_impl > Self, bool *Success=nullptr) |
Waits for the event. More... | |
void | wait_and_throw (std::shared_ptr< sycl::detail::event_impl > Self) |
Waits for the event. More... | |
template<typename Param > | |
Param::return_type | get_profiling_info () |
Queries this event for profiling information. More... | |
template<typename Param > | |
Param::return_type | get_info () |
Queries this SYCL event for information. More... | |
template<typename Param > | |
Param::return_type | get_backend_info () const |
Queries this SYCL event for SYCL backend-specific information. More... | |
~event_impl () | |
void | waitInternal (bool *Success=nullptr) |
Waits for the event with respect to device type. More... | |
void | setComplete () |
Marks this event as completed. More... | |
ur_event_handle_t | getHandle () const |
Returns raw interoperability event handle. More... | |
void | setHandle (const ur_event_handle_t &UREvent) |
Set event handle for this event object. More... | |
const ContextImplPtr & | getContextImpl () |
Returns context that is associated with this event. More... | |
const PluginPtr & | getPlugin () |
void | setContextImpl (const ContextImplPtr &Context) |
Associate event with the context. More... | |
void | setStateIncomplete () |
Clear the event state. More... | |
void * | getCommand () |
Returns command that is associated with the event. More... | |
void | setCommand (void *Command) |
Associates this event with the command. More... | |
HostProfilingInfo * | getHostProfilingInfo () |
Returns host profiling information. More... | |
ur_native_handle_t | getNative () |
Gets the native handle of the SYCL event. More... | |
std::vector< std::shared_ptr< event_impl > > & | getPreparedDepsEvents () |
Returns vector of event dependencies. More... | |
std::vector< std::shared_ptr< event_impl > > & | getPreparedHostDepsEvents () |
Returns vector of host event dependencies. More... | |
std::vector< EventImplPtr > | getWaitList () |
Returns vector of event_impl that this event_impl depends on. More... | |
void | flushIfNeeded (const QueueImplPtr &UserQueue) |
Performs a flush on the queue associated with this event if the user queue is different and the task associated with this event hasn't been submitted to the device yet. More... | |
void | cleanupDependencyEvents () |
Cleans dependencies of this event_impl. More... | |
void | cleanDepEventsThroughOneLevel () |
Cleans dependencies of this event's dependencies. More... | |
bool | isDiscarded () const |
Checks if this event is discarded by SYCL implementation. More... | |
QueueImplPtr | getWorkerQueue () |
Returns worker queue for command. More... | |
void | setWorkerQueue (const QueueImplPtr &WorkerQueue) |
Sets worker queue for command. More... | |
void | setSubmittedQueue (const QueueImplPtr &SubmittedQueue) |
Sets original queue used for submission. More... | |
bool | isNOP () |
Indicates if this event is not associated with any command and doesn't have native handle. More... | |
void | setSubmissionTime () |
Calling this function queries the current device timestamp and sets it as submission time for the command associated with this event. More... | |
void | setHostEnqueueTime () |
Calling this function to capture the host timestamp to use profiling base time. More... | |
uint64_t | getSubmissionTime () |
QueueImplPtr | getSubmittedQueue () const |
bool | isCompleted () |
Checks if this event is complete. More... | |
bool | isEnqueued () const noexcept |
Checks if associated command is enqueued. More... | |
void | attachEventToComplete (const EventImplPtr &Event) |
void | attachEventToCompleteWeak (const std::weak_ptr< event_impl > &Event) |
bool | isDefaultConstructed () const noexcept |
ContextImplPtr | getContextImplPtr () |
void | setSyncPoint (ur_exp_command_buffer_sync_point_t SyncPoint) |
ur_exp_command_buffer_sync_point_t | getSyncPoint () const |
void | setCommandGraph (std::shared_ptr< ext::oneapi::experimental::detail::graph_impl > Graph) |
std::shared_ptr< ext::oneapi::experimental::detail::graph_impl > | getCommandGraph () const |
void | setEventFromSubmittedExecCommandBuffer (bool value) |
bool | isEventFromSubmittedExecCommandBuffer () const |
void | setProfilingEnabled (bool Value) |
void | setCommandBufferCommand (ur_exp_command_buffer_command_handle_t Command) |
ur_exp_command_buffer_command_handle_t | getCommandBufferCommand () const |
const std::vector< EventImplPtr > & | getPostCompleteEvents () const |
void | setEnqueued () |
bool | isHost () |
void | markAsProfilingTagEvent () |
bool | isProfilingTagEvent () const noexcept |
bool | isInterop () const noexcept |
Protected Member Functions | |
void * | instrumentationProlog (std::string &Name, int32_t StreamID, uint64_t &instance_id) const |
void | instrumentationEpilog (void *TelementryEvent, const std::string &Name, int32_t StreamID, uint64_t IId) const |
void | checkProfilingPreconditions () const |
void | initContextIfNeeded () |
Protected Attributes | |
std::atomic< ur_event_handle_t > | MEvent = nullptr |
uint64_t | MSubmitTime = 0 |
uint64_t | MHostBaseTime = 0 |
ContextImplPtr | MContext |
std::unique_ptr< HostProfilingInfo > | MHostProfilingInfo |
void * | MCommand = nullptr |
std::weak_ptr< queue_impl > | MQueue |
bool | MIsProfilingEnabled = false |
bool | MFallbackProfiling = false |
std::weak_ptr< queue_impl > | MWorkerQueue |
std::weak_ptr< queue_impl > | MSubmittedQueue |
std::vector< EventImplPtr > | MPreparedDepsEvents |
Dependency events prepared for waiting by backend. More... | |
std::vector< EventImplPtr > | MPreparedHostDepsEvents |
std::vector< EventImplPtr > | MPostCompleteEvents |
std::vector< std::weak_ptr< event_impl > > | MWeakPostCompleteEvents |
std::atomic< bool > | MIsFlushed = false |
Indicates that the task associated with this event has been submitted by the queue to the device. More... | |
std::atomic< int > | MState |
std::mutex | MMutex |
std::condition_variable | cv |
std::weak_ptr< ext::oneapi::experimental::detail::graph_impl > | MGraph |
Store the command graph associated with this event, if any. More... | |
bool | MEventFromSubmittedExecCommandBuffer = false |
Indicates that the event results from a command graph submission. More... | |
ur_exp_command_buffer_sync_point_t | MSyncPoint = 0 |
ur_exp_command_buffer_command_handle_t | MCommandBufferCommand = nullptr |
bool | MProfilingTagEvent = false |
std::atomic_bool | MIsEnqueued {false} |
bool | MIsDefaultConstructed = false |
bool | MIsHostEvent = false |
Definition at line 38 of file event_impl.hpp.
Enumerator | |
---|---|
HES_NotComplete | |
HES_Complete | |
HES_Discarded |
Definition at line 40 of file event_impl.hpp.
|
inline |
Constructs a ready SYCL event.
If the constructed SYCL event is waited on it will complete immediately. Normally constructs a host event, use std::nullopt to instead instantiate a device event.
Definition at line 51 of file event_impl.hpp.
References sycl::_V1::detail::SYCLConfig< Config >::get().
sycl::_V1::detail::event_impl::event_impl | ( | ur_event_handle_t | Event, |
const context & | SyclContext | ||
) |
Constructs an event instance from a plug-in event handle.
The SyclContext must match the plug-in context associated with the ClEvent.
Event | is a valid instance of plug-in event. |
SyclContext | is an instance of SYCL context. |
Definition at line 145 of file event_impl.cpp.
References sycl::_V1::detail::codeToString(), getHandle(), getPlugin(), and MContext.
sycl::_V1::detail::event_impl::event_impl | ( | const QueueImplPtr & | Queue | ) |
Definition at line 162 of file event_impl.cpp.
References sycl::_V1::detail::codeToString(), HES_Complete, HES_NotComplete, MHostProfilingInfo, MState, and setContextImpl().
sycl::_V1::detail::event_impl::~event_impl | ( | ) |
Definition at line 45 of file event_impl.cpp.
References __SYCL_REPORT_EXCEPTION_TO_STREAM, getHandle(), and getPlugin().
|
inline |
Definition at line 263 of file event_impl.hpp.
References MMutex, and MPostCompleteEvents.
|
inline |
Definition at line 268 of file event_impl.hpp.
References MMutex, and MWeakPostCompleteEvents.
|
protected |
Definition at line 280 of file event_impl.cpp.
References sycl::_V1::make_error_code(), MIsHostEvent, MIsProfilingEnabled, MProfilingTagEvent, and MQueue.
void sycl::_V1::detail::event_impl::cleanDepEventsThroughOneLevel | ( | ) |
Cleans dependencies of this event's dependencies.
Definition at line 556 of file event_impl.cpp.
References MMutex, MPreparedDepsEvents, and MPreparedHostDepsEvents.
void sycl::_V1::detail::event_impl::cleanupDependencyEvents | ( | ) |
Cleans dependencies of this event_impl.
Definition at line 550 of file event_impl.cpp.
References MMutex, MPreparedDepsEvents, and MPreparedHostDepsEvents.
void sycl::_V1::detail::event_impl::flushIfNeeded | ( | const QueueImplPtr & | UserQueue | ) |
Performs a flush on the queue associated with this event if the user queue is different and the task associated with this event hasn't been submitted to the device yet.
Definition at line 522 of file event_impl.cpp.
References getHandle(), getPlugin(), MIsFlushed, and MQueue.
Param::return_type sycl::_V1::detail::event_impl::get_backend_info | ( | ) | const |
Queries this SYCL event for SYCL backend-specific information.
Param::return_type sycl::_V1::detail::event_impl::get_info | ( | ) |
Queries this SYCL event for information.
Param::return_type sycl::_V1::detail::event_impl::get_profiling_info | ( | ) |
Queries this event for profiling information.
If the requested info is not available when this member function is called due to incompletion of command groups associated with the event, then the call to this member function will block until the requested info is available. If the queue which submitted the command group this event is associated with was not constructed with the property::queue::enable_profiling property, a SYCL exception with errc::invalid error code is thrown.
|
inline |
Returns command that is associated with the event.
Scheduler mutex must be locked in read mode when this is called.
Definition at line 160 of file event_impl.hpp.
References MCommand.
|
inline |
Definition at line 316 of file event_impl.hpp.
References MCommandBufferCommand.
|
inline |
Definition at line 296 of file event_impl.hpp.
References MGraph.
const ContextImplPtr & sycl::_V1::detail::event_impl::getContextImpl | ( | ) |
Returns context that is associated with this event.
Definition at line 128 of file event_impl.cpp.
References initContextIfNeeded(), and MContext.
|
inline |
Definition at line 275 of file event_impl.hpp.
References initContextIfNeeded(), MContext, and MIsDefaultConstructed.
ur_event_handle_t sycl::_V1::detail::event_impl::getHandle | ( | ) | const |
Returns raw interoperability event handle.
Definition at line 122 of file event_impl.cpp.
References MEvent.
Referenced by event_impl(), flushIfNeeded(), getNative(), instrumentationProlog(), isNOP(), setComplete(), wait(), waitInternal(), and ~event_impl().
|
inline |
Returns host profiling information.
Definition at line 172 of file event_impl.hpp.
References MHostProfilingInfo.
ur_native_handle_t sycl::_V1::detail::event_impl::getNative | ( | ) |
Gets the native handle of the SYCL event.
Definition at line 481 of file event_impl.cpp.
References getHandle(), getPlugin(), initContextIfNeeded(), isHost(), MContext, MIsDefaultConstructed, sycl::_V1::opencl, and setHandle().
const PluginPtr & sycl::_V1::detail::event_impl::getPlugin | ( | ) |
Definition at line 133 of file event_impl.cpp.
References initContextIfNeeded(), and MContext.
Referenced by event_impl(), flushIfNeeded(), getNative(), waitInternal(), and ~event_impl().
|
inline |
Definition at line 320 of file event_impl.hpp.
References MPostCompleteEvents.
|
inline |
Returns vector of event dependencies.
Definition at line 182 of file event_impl.hpp.
References MPreparedDepsEvents.
|
inline |
Returns vector of host event dependencies.
Definition at line 189 of file event_impl.hpp.
References MPreparedHostDepsEvents.
uint64_t sycl::_V1::detail::event_impl::getSubmissionTime | ( | ) |
Definition at line 603 of file event_impl.cpp.
References MSubmitTime.
|
inline |
Definition at line 251 of file event_impl.hpp.
References MSubmittedQueue.
|
inline |
Definition at line 288 of file event_impl.hpp.
References MSyncPoint.
std::vector< EventImplPtr > sycl::_V1::detail::event_impl::getWaitList | ( | ) |
Returns vector of event_impl that this event_impl depends on.
Definition at line 504 of file event_impl.cpp.
References HES_Discarded, sycl::_V1::invalid, sycl::_V1::make_error_code(), MMutex, MPreparedDepsEvents, MPreparedHostDepsEvents, and MState.
|
inline |
Returns worker queue for command.
Definition at line 218 of file event_impl.hpp.
References MWorkerQueue.
|
protected |
Definition at line 36 of file event_impl.cpp.
References sycl::_V1::detail::queue_impl::getDefaultOrNew(), sycl::_V1::detail::getSyclObjImpl(), MContext, MIsDefaultConstructed, and setContextImpl().
Referenced by getContextImpl(), getContextImplPtr(), getNative(), and getPlugin().
|
protected |
Definition at line 223 of file event_impl.cpp.
Referenced by wait().
|
protected |
Definition at line 181 of file event_impl.cpp.
References getHandle(), MCommand, MQueue, and sycl::_V1::detail::Command::MTraceEvent.
Referenced by wait().
bool sycl::_V1::detail::event_impl::isCompleted | ( | ) |
Checks if this event is complete.
Definition at line 605 of file event_impl.cpp.
References sycl::_V1::info::complete.
|
inlinenoexcept |
Definition at line 273 of file event_impl.hpp.
References MIsDefaultConstructed.
|
inline |
Checks if this event is discarded by SYCL implementation.
Definition at line 212 of file event_impl.hpp.
References HES_Discarded, and MState.
|
inlinenoexcept |
Checks if associated command is enqueued.
Definition at line 261 of file event_impl.hpp.
References MIsEnqueued.
|
inline |
Definition at line 304 of file event_impl.hpp.
References MEventFromSubmittedExecCommandBuffer.
|
inline |
|
inlinenoexcept |
Definition at line 333 of file event_impl.hpp.
References MCommand, MEvent, MIsEnqueued, and MQueue.
|
inline |
Indicates if this event is not associated with any command and doesn't have native handle.
Definition at line 238 of file event_impl.hpp.
References getHandle(), and MCommand.
|
inlinenoexcept |
Definition at line 330 of file event_impl.hpp.
References MProfilingTagEvent.
|
inline |
Definition at line 328 of file event_impl.hpp.
References MProfilingTagEvent.
void sycl::_V1::detail::event_impl::setCommand | ( | void * | Command | ) |
Associates this event with the command.
Scheduler mutex must be locked in write mode when this is called.
Definition at line 610 of file event_impl.cpp.
References MCommand, and MIsHostEvent.
|
inline |
Definition at line 312 of file event_impl.hpp.
References MCommandBufferCommand.
|
inline |
Definition at line 290 of file event_impl.hpp.
References MGraph.
void sycl::_V1::detail::event_impl::setComplete | ( | ) |
Marks this event as completed.
Definition at line 94 of file event_impl.cpp.
References cv, getHandle(), HES_Complete, HES_NotComplete, MIsHostEvent, MMutex, and MState.
void sycl::_V1::detail::event_impl::setContextImpl | ( | const ContextImplPtr & | Context | ) |
Associate event with the context.
Provided UrContext inside ContextImplPtr must be associated with the UrEvent object stored in this class
Context | is a shared pointer to an instance of valid context_impl. |
Definition at line 140 of file event_impl.cpp.
References MContext, and MIsHostEvent.
Referenced by event_impl(), and initContextIfNeeded().
|
inline |
Definition at line 324 of file event_impl.hpp.
References MIsEnqueued.
|
inline |
Definition at line 300 of file event_impl.hpp.
References MEventFromSubmittedExecCommandBuffer.
void sycl::_V1::detail::event_impl::setHandle | ( | const ur_event_handle_t & | UREvent | ) |
Set event handle for this event object.
Definition at line 124 of file event_impl.cpp.
References MEvent.
Referenced by getNative().
void sycl::_V1::detail::event_impl::setHostEnqueueTime | ( | ) |
Calling this function to capture the host timestamp to use profiling base time.
See MFallbackProfiling
Definition at line 595 of file event_impl.cpp.
References sycl::_V1::detail::getTimestamp(), MFallbackProfiling, MHostBaseTime, and MIsProfilingEnabled.
|
inline |
Definition at line 308 of file event_impl.hpp.
References MIsProfilingEnabled.
void sycl::_V1::detail::event_impl::setStateIncomplete | ( | ) |
Clear the event state.
Definition at line 138 of file event_impl.cpp.
References HES_NotComplete, and MState.
void sycl::_V1::detail::event_impl::setSubmissionTime | ( | ) |
Calling this function queries the current device timestamp and sets it as submission time for the command associated with this event.
Definition at line 566 of file event_impl.cpp.
References sycl::_V1::exception::code(), sycl::_V1::detail::getTimestamp(), sycl::_V1::make_error_code(), MFallbackProfiling, MIsProfilingEnabled, MProfilingTagEvent, MQueue, MSubmitTime, sycl::_V1::profiling, and sycl::_V1::exception::what().
|
inline |
Sets original queue used for submission.
Definition at line 230 of file event_impl.hpp.
References MSubmittedQueue.
|
inline |
Definition at line 283 of file event_impl.hpp.
References MSyncPoint.
|
inline |
Sets worker queue for command.
Definition at line 223 of file event_impl.hpp.
References MWorkerQueue.
void sycl::_V1::detail::event_impl::wait | ( | std::shared_ptr< sycl::detail::event_impl > | Self, |
bool * | Success = nullptr |
||
) |
Waits for the event.
Self is needed in order to pass shared_ptr to Scheduler.
Self | is a pointer to this event. |
Success | is an optional parameter that, when set to a non-null pointer, indicates that failure is a valid outcome for this wait (e.g., in case of a non-blocking read from a pipe), and the value it's pointing to is then set according to the outcome. |
Definition at line 239 of file event_impl.cpp.
References getHandle(), sycl::_V1::detail::Scheduler::getInstance(), HES_Discarded, instrumentationEpilog(), instrumentationProlog(), sycl::_V1::invalid, sycl::_V1::make_error_code(), MCommand, MGraph, MState, sycl::_V1::detail::SYCL_STREAM_NAME, sycl::_V1::detail::Scheduler::waitForEvent(), and waitInternal().
Referenced by wait_and_throw().
void sycl::_V1::detail::event_impl::wait_and_throw | ( | std::shared_ptr< sycl::detail::event_impl > | Self | ) |
Waits for the event.
If any uncaught asynchronous errors occurred on the context that the event is waiting on executions from, then call that context's asynchronous error handler with those errors. Self is needed in order to pass shared_ptr to Scheduler.
Self | is a pointer to this event. |
Definition at line 272 of file event_impl.cpp.
References MSubmittedQueue, and wait().
void sycl::_V1::detail::event_impl::waitInternal | ( | bool * | Success = nullptr | ) |
Waits for the event with respect to device type.
Success | is an optional parameter that, when set to a non-null pointer, indicates that failure is a valid outcome for this wait (e.g., in case of a non-blocking read from a pipe), and the value it's pointing to is then set according to the outcome. |
Definition at line 55 of file event_impl.cpp.
References cv, getHandle(), getPlugin(), HES_Complete, HES_Discarded, sycl::_V1::invalid, sycl::_V1::make_error_code(), MIsHostEvent, MMutex, MPostCompleteEvents, MState, and MWeakPostCompleteEvents.
Referenced by wait().
|
protected |
Definition at line 389 of file event_impl.hpp.
Referenced by setComplete(), and waitInternal().
|
protected |
Definition at line 355 of file event_impl.hpp.
Referenced by getCommand(), instrumentationProlog(), isInterop(), isNOP(), setCommand(), and wait().
|
protected |
Definition at line 405 of file event_impl.hpp.
Referenced by getCommandBufferCommand(), and setCommandBufferCommand().
|
protected |
Definition at line 353 of file event_impl.hpp.
Referenced by event_impl(), getContextImpl(), getContextImplPtr(), getNative(), getPlugin(), initContextIfNeeded(), and setContextImpl().
|
protected |
Definition at line 349 of file event_impl.hpp.
Referenced by getHandle(), isInterop(), and setHandle().
|
protected |
Indicates that the event results from a command graph submission.
Definition at line 395 of file event_impl.hpp.
Referenced by isEventFromSubmittedExecCommandBuffer(), and setEventFromSubmittedExecCommandBuffer().
|
protected |
Definition at line 358 of file event_impl.hpp.
Referenced by setHostEnqueueTime(), and setSubmissionTime().
|
protected |
Store the command graph associated with this event, if any.
This event is also be stored in the graph so a weak_ptr is used.
Definition at line 393 of file event_impl.hpp.
Referenced by getCommandGraph(), setCommandGraph(), and wait().
|
protected |
Definition at line 352 of file event_impl.hpp.
Referenced by setHostEnqueueTime().
|
protected |
Definition at line 354 of file event_impl.hpp.
Referenced by event_impl(), and getHostProfilingInfo().
|
protected |
Definition at line 424 of file event_impl.hpp.
Referenced by getContextImplPtr(), getNative(), initContextIfNeeded(), and isDefaultConstructed().
|
protected |
Definition at line 411 of file event_impl.hpp.
Referenced by isEnqueued(), isInterop(), and setEnqueued().
|
protected |
Indicates that the task associated with this event has been submitted by the queue to the device.
Definition at line 381 of file event_impl.hpp.
Referenced by flushIfNeeded().
|
protected |
Definition at line 425 of file event_impl.hpp.
Referenced by checkProfilingPreconditions(), isHost(), setCommand(), setComplete(), setContextImpl(), and waitInternal().
|
protected |
Definition at line 357 of file event_impl.hpp.
Referenced by checkProfilingPreconditions(), setHostEnqueueTime(), setProfilingEnabled(), and setSubmissionTime().
|
protected |
Definition at line 388 of file event_impl.hpp.
Referenced by attachEventToComplete(), attachEventToCompleteWeak(), cleanDepEventsThroughOneLevel(), cleanupDependencyEvents(), getWaitList(), setComplete(), and waitInternal().
|
protected |
Definition at line 367 of file event_impl.hpp.
Referenced by attachEventToComplete(), getPostCompleteEvents(), and waitInternal().
|
protected |
Dependency events prepared for waiting by backend.
Definition at line 364 of file event_impl.hpp.
Referenced by cleanDepEventsThroughOneLevel(), cleanupDependencyEvents(), getPreparedDepsEvents(), and getWaitList().
|
protected |
Definition at line 365 of file event_impl.hpp.
Referenced by cleanDepEventsThroughOneLevel(), cleanupDependencyEvents(), getPreparedHostDepsEvents(), and getWaitList().
|
protected |
Definition at line 409 of file event_impl.hpp.
Referenced by checkProfilingPreconditions(), isProfilingTagEvent(), markAsProfilingTagEvent(), and setSubmissionTime().
|
protected |
Definition at line 356 of file event_impl.hpp.
Referenced by checkProfilingPreconditions(), flushIfNeeded(), instrumentationProlog(), isInterop(), and setSubmissionTime().
|
protected |
Definition at line 386 of file event_impl.hpp.
Referenced by event_impl(), getWaitList(), isDiscarded(), setComplete(), setStateIncomplete(), wait(), and waitInternal().
|
protected |
Definition at line 361 of file event_impl.hpp.
Referenced by getSubmittedQueue(), setSubmittedQueue(), and wait_and_throw().
|
protected |
Definition at line 351 of file event_impl.hpp.
Referenced by getSubmissionTime(), and setSubmissionTime().
|
protected |
Definition at line 400 of file event_impl.hpp.
Referenced by getSyncPoint(), and setSyncPoint().
|
protected |
Definition at line 377 of file event_impl.hpp.
Referenced by attachEventToCompleteWeak(), and waitInternal().
|
protected |
Definition at line 360 of file event_impl.hpp.
Referenced by getWorkerQueue(), and setWorkerQueue().