#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 (sycl::detail::pi::PiEvent Event, const context &SyclContext) | |
Constructs an event instance from a plug-in event handle. More... | |
event_impl (const QueueImplPtr &Queue) | |
bool | is_host () |
Checks if this event is a SYCL host event. More... | |
void | wait (std::shared_ptr< sycl::detail::event_impl > Self) |
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... | |
~event_impl () | |
void | waitInternal () |
Waits for the event with respect to device type. More... | |
void | setComplete () |
Marks this event as completed. More... | |
sycl::detail::pi::PiEvent & | getHandleRef () |
Returns raw interoperability event handle. More... | |
const sycl::detail::pi::PiEvent & | getHandleRef () const |
Returns raw interoperability event handle. 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... | |
pi_native_handle | 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... | |
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 | isInitialized () const noexcept |
Checks if an event is in a fully intialized state. More... | |
bool | isCompleted () |
Checks if this event is complete. More... | |
void | attachEventToComplete (const EventImplPtr &Event) |
bool | isContextInitialized () const noexcept |
ContextImplPtr | getContextImplPtr () |
void | setSyncPoint (sycl::detail::pi::PiExtSyncPoint SyncPoint) |
sycl::detail::pi::PiExtSyncPoint | 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 | setEventFromSubmitedExecCommandBuffer (bool value) |
bool | isEventFromSubmitedExecCommandBuffer () const |
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 | ensureContextInitialized () |
Protected Attributes | |
bool | MIsInitialized = true |
bool | MIsContextInitialized = false |
sycl::detail::pi::PiEvent | MEvent = nullptr |
uint64_t | MSubmitTime = 0 |
uint64_t | MHostBaseTime = 0 |
ContextImplPtr | MContext |
bool | MHostEvent = true |
std::unique_ptr< HostProfilingInfo > | MHostProfilingInfo |
void * | MCommand = nullptr |
std::weak_ptr< queue_impl > | MQueue |
const bool | MIsProfilingEnabled = false |
const 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::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 | MEventFromSubmitedExecCommandBuffer = false |
Indicates that the event results from a command graph submission. More... | |
sycl::detail::pi::PiExtSyncPoint | MSyncPoint |
Friends | |
std::vector< sycl::detail::pi::PiEvent > | getOrWaitEvents (std::vector< sycl::event > DepEvents, std::shared_ptr< sycl::detail::context_impl > Context) |
Definition at line 39 of file event_impl.hpp.
Enumerator | |
---|---|
HES_NotComplete | |
HES_Complete | |
HES_Discarded |
Definition at line 41 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 52 of file event_impl.hpp.
sycl::_V1::detail::event_impl::event_impl | ( | sycl::detail::pi::PiEvent | 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 132 of file event_impl.cpp.
References sycl::_V1::detail::codeToString(), getPlugin(), sycl::_V1::make_error_code(), MContext, MEvent, PI_EVENT_INFO_CONTEXT, and piEventGetInfo().
sycl::_V1::detail::event_impl::event_impl | ( | const QueueImplPtr & | Queue | ) |
Definition at line 157 of file event_impl.cpp.
sycl::_V1::detail::event_impl::~event_impl | ( | ) |
Definition at line 56 of file event_impl.cpp.
References getPlugin(), MEvent, and piEventRelease().
|
inline |
Definition at line 254 of file event_impl.hpp.
References MMutex, and MPostCompleteEvents.
|
protected |
Definition at line 267 of file event_impl.cpp.
References sycl::_V1::make_error_code(), MEventFromSubmitedExecCommandBuffer, MIsProfilingEnabled, and MQueue.
void sycl::_V1::detail::event_impl::cleanDepEventsThroughOneLevel | ( | ) |
Cleans dependencies of this event's dependencies.
Definition at line 450 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 444 of file event_impl.cpp.
References MMutex, MPreparedDepsEvents, and MPreparedHostDepsEvents.
|
protected |
Definition at line 36 of file event_impl.cpp.
References sycl::_V1::detail::Scheduler::getDefaultHostQueue(), sycl::_V1::detail::queue_impl::getDefaultOrNew(), sycl::_V1::detail::Scheduler::getInstance(), sycl::_V1::detail::getSyclObjImpl(), MHostEvent, MIsContextInitialized, and setContextImpl().
Referenced by getContextImpl(), getContextImplPtr(), getNative(), and getPlugin().
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 417 of file event_impl.cpp.
References getPlugin(), MEvent, MIsFlushed, MQueue, PI_EVENT_INFO_COMMAND_EXECUTION_STATUS, PI_EVENT_QUEUED, piEventGetInfo(), and piQueueFlush().
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, an invalid_object_error SYCL exception 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 153 of file event_impl.hpp.
References MCommand.
|
inline |
Definition at line 281 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 114 of file event_impl.cpp.
References ensureContextInitialized(), and MContext.
|
inline |
Definition at line 261 of file event_impl.hpp.
References ensureContextInitialized(), and MContext.
sycl::detail::pi::PiEvent & sycl::_V1::detail::event_impl::getHandleRef | ( | ) |
Returns raw interoperability event handle.
Returned reference will be] invalid if event_impl was destroyed.
Definition at line 109 of file event_impl.cpp.
References MEvent.
Referenced by getNative().
const sycl::detail::pi::PiEvent& sycl::_V1::detail::event_impl::getHandleRef | ( | ) | const |
Returns raw interoperability event handle.
Returned reference will be] invalid if event_impl was destroyed.
|
inline |
Returns host profiling information.
Definition at line 165 of file event_impl.hpp.
References MHostProfilingInfo.
pi_native_handle sycl::_V1::detail::event_impl::getNative | ( | ) |
Gets the native handle of the SYCL event.
Definition at line 383 of file event_impl.cpp.
References ensureContextInitialized(), getHandleRef(), getPlugin(), MContext, MEvent, MIsInitialized, sycl::_V1::opencl, piEventCreate, piEventRetain(), and piextEventGetNativeHandle().
const PluginPtr & sycl::_V1::detail::event_impl::getPlugin | ( | ) |
Definition at line 119 of file event_impl.cpp.
References ensureContextInitialized(), and MContext.
Referenced by event_impl(), flushIfNeeded(), getNative(), waitInternal(), and ~event_impl().
|
inline |
Returns vector of event dependencies.
Definition at line 175 of file event_impl.hpp.
References MPreparedDepsEvents.
|
inline |
Returns vector of host event dependencies.
Definition at line 182 of file event_impl.hpp.
References MPreparedHostDepsEvents.
uint64_t sycl::_V1::detail::event_impl::getSubmissionTime | ( | ) |
Definition at line 489 of file event_impl.cpp.
References MSubmitTime.
|
inline |
Definition at line 238 of file event_impl.hpp.
References MSubmittedQueue.
|
inline |
Definition at line 273 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 399 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 211 of file event_impl.hpp.
References MWorkerQueue.
|
protected |
Definition at line 212 of file event_impl.cpp.
Referenced by wait().
|
protected |
Definition at line 176 of file event_impl.cpp.
References MCommand, MEvent, and sycl::_V1::detail::Command::MTraceEvent.
Referenced by wait().
bool sycl::_V1::detail::event_impl::is_host | ( | ) |
Checks if this event is a SYCL host event.
All devices that do not support OpenCL interoperability are treated as host device to avoid attempts to call method get on such events.
Definition at line 50 of file event_impl.cpp.
References MHostEvent.
bool sycl::_V1::detail::event_impl::isCompleted | ( | ) |
Checks if this event is complete.
Definition at line 491 of file event_impl.cpp.
References sycl::_V1::info::complete.
|
inlinenoexcept |
Definition at line 259 of file event_impl.hpp.
References MIsContextInitialized.
|
inline |
Checks if this event is discarded by SYCL implementation.
Definition at line 205 of file event_impl.hpp.
References HES_Discarded, and MState.
|
inline |
Definition at line 289 of file event_impl.hpp.
References MEventFromSubmitedExecCommandBuffer.
|
inlinenoexcept |
Checks if an event is in a fully intialized state.
Default-constructed events will return true only after having initialized its native event, while other events will assume that they are fully initialized at construction, relying on external sources to supply member data.
Definition at line 247 of file event_impl.hpp.
References MIsInitialized.
|
inline |
|
inline |
Definition at line 275 of file event_impl.hpp.
References MGraph.
void sycl::_V1::detail::event_impl::setComplete | ( | ) |
Marks this event as completed.
Definition at line 81 of file event_impl.cpp.
References cv, HES_Complete, HES_NotComplete, MEvent, MHostEvent, MMutex, and MState.
void sycl::_V1::detail::event_impl::setContextImpl | ( | const ContextImplPtr & | Context | ) |
Associate event with the context.
Provided PiContext inside ContextImplPtr must be associated with the PiEvent object stored in this class
Context | is a shared pointer to an instance of valid context_impl. |
Definition at line 126 of file event_impl.cpp.
References MContext, MHostEvent, and MIsContextInitialized.
Referenced by ensureContextInitialized().
|
inline |
Definition at line 285 of file event_impl.hpp.
References MEventFromSubmitedExecCommandBuffer.
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 481 of file event_impl.cpp.
References sycl::_V1::detail::getTimestamp(), MFallbackProfiling, MHostBaseTime, and MIsProfilingEnabled.
void sycl::_V1::detail::event_impl::setStateIncomplete | ( | ) |
Clear the event state.
Definition at line 124 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 460 of file event_impl.cpp.
References sycl::_V1::feature_not_supported, sycl::_V1::detail::getTimestamp(), sycl::_V1::make_error_code(), MFallbackProfiling, MIsProfilingEnabled, MQueue, MSubmitTime, and sycl::_V1::profiling.
|
inline |
Sets original queue used for submission.
Definition at line 223 of file event_impl.hpp.
References MSubmittedQueue.
|
inline |
Definition at line 268 of file event_impl.hpp.
References MSyncPoint.
|
inline |
Sets worker queue for command.
Definition at line 216 of file event_impl.hpp.
References MWorkerQueue.
void sycl::_V1::detail::event_impl::wait | ( | std::shared_ptr< sycl::detail::event_impl > | Self | ) |
Waits for the event.
Self is needed in order to pass shared_ptr to Scheduler.
Self | is a pointer to this event. |
Definition at line 228 of file event_impl.cpp.
References sycl::_V1::detail::Scheduler::getInstance(), HES_Discarded, instrumentationEpilog(), instrumentationProlog(), sycl::_V1::invalid, sycl::_V1::make_error_code(), MCommand, MEvent, 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 259 of file event_impl.cpp.
References MSubmittedQueue, and wait().
void sycl::_V1::detail::event_impl::waitInternal | ( | ) |
Waits for the event with respect to device type.
Definition at line 61 of file event_impl.cpp.
References cv, getPlugin(), HES_Complete, HES_Discarded, sycl::_V1::invalid, sycl::_V1::make_error_code(), MEvent, MHostEvent, MMutex, MPostCompleteEvents, MState, and piEventsWait().
Referenced by wait().
|
friend |
|
protected |
Definition at line 338 of file event_impl.hpp.
Referenced by setComplete(), and waitInternal().
|
protected |
Definition at line 314 of file event_impl.hpp.
Referenced by getCommand(), instrumentationProlog(), setCommand(), and wait().
|
protected |
Definition at line 311 of file event_impl.hpp.
Referenced by event_impl(), getContextImpl(), getContextImplPtr(), getNative(), getPlugin(), and setContextImpl().
|
protected |
Definition at line 307 of file event_impl.hpp.
Referenced by event_impl(), flushIfNeeded(), getHandleRef(), getNative(), instrumentationProlog(), setComplete(), wait(), waitInternal(), and ~event_impl().
|
protected |
Indicates that the event results from a command graph submission.
Definition at line 344 of file event_impl.hpp.
Referenced by checkProfilingPreconditions(), isEventFromSubmitedExecCommandBuffer(), and setEventFromSubmitedExecCommandBuffer().
|
protected |
Definition at line 317 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 342 of file event_impl.hpp.
Referenced by getCommandGraph(), setCommandGraph(), and wait().
|
protected |
Definition at line 310 of file event_impl.hpp.
Referenced by setHostEnqueueTime().
|
protected |
Definition at line 312 of file event_impl.hpp.
Referenced by ensureContextInitialized(), is_host(), setComplete(), setContextImpl(), and waitInternal().
|
protected |
Definition at line 313 of file event_impl.hpp.
Referenced by getHostProfilingInfo().
|
protected |
Definition at line 306 of file event_impl.hpp.
Referenced by ensureContextInitialized(), isContextInitialized(), and setContextImpl().
|
protected |
Indicates that the task associated with this event has been submitted by the queue to the device.
Definition at line 330 of file event_impl.hpp.
Referenced by flushIfNeeded().
|
protected |
Definition at line 305 of file event_impl.hpp.
Referenced by getNative(), and isInitialized().
|
protected |
Definition at line 316 of file event_impl.hpp.
Referenced by checkProfilingPreconditions(), setHostEnqueueTime(), and setSubmissionTime().
|
protected |
Definition at line 337 of file event_impl.hpp.
Referenced by attachEventToComplete(), cleanDepEventsThroughOneLevel(), cleanupDependencyEvents(), getWaitList(), setComplete(), and waitInternal().
|
protected |
Definition at line 326 of file event_impl.hpp.
Referenced by attachEventToComplete(), and waitInternal().
|
protected |
Dependency events prepared for waiting by backend.
Definition at line 323 of file event_impl.hpp.
Referenced by cleanDepEventsThroughOneLevel(), cleanupDependencyEvents(), getPreparedDepsEvents(), and getWaitList().
|
protected |
Definition at line 324 of file event_impl.hpp.
Referenced by cleanDepEventsThroughOneLevel(), cleanupDependencyEvents(), getPreparedHostDepsEvents(), and getWaitList().
|
protected |
Definition at line 315 of file event_impl.hpp.
Referenced by checkProfilingPreconditions(), flushIfNeeded(), and setSubmissionTime().
|
protected |
Definition at line 335 of file event_impl.hpp.
Referenced by getWaitList(), isDiscarded(), setComplete(), setStateIncomplete(), wait(), and waitInternal().
|
protected |
Definition at line 320 of file event_impl.hpp.
Referenced by getSubmittedQueue(), setSubmittedQueue(), and wait_and_throw().
|
protected |
Definition at line 309 of file event_impl.hpp.
Referenced by getSubmissionTime(), and setSubmissionTime().
|
protected |
Definition at line 349 of file event_impl.hpp.
Referenced by getSyncPoint(), and setSyncPoint().
|
protected |
Definition at line 319 of file event_impl.hpp.
Referenced by getWorkerQueue(), and setWorkerQueue().