@@ -24,75 +24,148 @@ using ContextImplPtr = std::shared_ptr<cl::sycl::detail::context_impl>;
24
24
class queue_impl ;
25
25
using QueueImplPtr = std::shared_ptr<cl::sycl::detail::queue_impl>;
26
26
27
- // Profiling info for the host execution.
27
+ // / Profiling info for the host execution.
28
28
class HostProfilingInfo {
29
29
cl_ulong StartTime = 0 ;
30
30
cl_ulong EndTime = 0 ;
31
31
32
32
public:
33
+ // / Returns event's start time.
34
+ // /
35
+ // / @return event's start time in nanoseconds.
33
36
cl_ulong getStartTime () const { return StartTime; }
37
+ // / Returns event's end time.
38
+ // /
39
+ // / @return event's end time in nanoseconds.
34
40
cl_ulong getEndTime () const { return EndTime; }
35
41
42
+ // / Measures event's start time.
36
43
void start ();
44
+ // / Measures event's end time.
37
45
void end ();
38
46
};
39
47
40
48
class event_impl {
41
49
public:
50
+ // / Constructs a ready SYCL event.
51
+ // /
52
+ // / If the constructed SYCL event is waited on it will complete immediately.
42
53
event_impl () = default ;
43
- event_impl (cl_event CLEvent, const context &SyclContext);
54
+ // / Constructs an event instance from a plug-in event handle.
55
+ // /
56
+ // / The SyclContext must match the plug-in context associated with the ClEvent.
57
+ // /
58
+ // / @param Event is a valid instance of plug-in event.
59
+ // / @param SyclContext is an instance of SYCL context.
60
+ event_impl (RT::PiEvent Event, const context &SyclContext);
44
61
event_impl (QueueImplPtr Queue);
45
62
46
- // Threat all devices that don't support interoperability as host devices to
47
- // avoid attempts to call method get on such events.
63
+ // / Checks if this event is a SYCL host event.
64
+ // /
65
+ // / All devices that do not support OpenCL interoperability are treated as
66
+ // / host device to avoid attempts to call method get on such events.
67
+ //
68
+ // / @return true if this event is a SYCL host event.
48
69
bool is_host () const ;
49
70
71
+ // / Returns a valid OpenCL event interoperability handle.
72
+ // /
73
+ // / @return a valid instance of OpenCL cl_event.
50
74
cl_event get () const ;
51
75
52
- // Self is needed in order to pass shared_ptr to Scheduler.
76
+ // / Waits for the event.
77
+ // /
78
+ // / Self is needed in order to pass shared_ptr to Scheduler.
79
+ // /
80
+ // / @param Self is a pointer to this event.
53
81
void wait (std::shared_ptr<cl::sycl::detail::event_impl> Self) const ;
54
82
83
+ // / Waits for the event.
84
+ // /
85
+ // / If any uncaught asynchronous errors occurred on the context that the event
86
+ // / is waiting on executions from, then call that context's asynchronous error
87
+ // / handler with those errors.
88
+ // / Self is needed in order to pass shared_ptr to Scheduler.
89
+ // /
90
+ // / @param Self is a pointer to this event.
55
91
void wait_and_throw (std::shared_ptr<cl::sycl::detail::event_impl> Self);
56
92
93
+ // / Queries this event for profiling information.
94
+ // /
95
+ // / If the requested info is not available when this member function is called
96
+ // / due to incompletion of command groups associated with the event, then the
97
+ // / call to this member function will block until the requested info is
98
+ // / available. If the queue which submitted the command group this event is
99
+ // / associated with was not constructed with the
100
+ // / property::queue::enable_profiling property, an invalid_object_error SYCL
101
+ // / exception is thrown.
102
+ // /
103
+ // / @return depends on template parameter.
57
104
template <info::event_profiling param>
58
105
typename info::param_traits<info::event_profiling, param>::return_type
59
106
get_profiling_info () const ;
60
107
108
+ // / Queries this SYCL event for information.
109
+ // /
110
+ // / @return depends on the information being requested.
61
111
template <info::event param>
62
112
typename info::param_traits<info::event, param>::return_type get_info () const ;
63
113
64
114
~event_impl ();
65
115
116
+ // / Waits for the event with respect to device type.
66
117
void waitInternal () const ;
67
118
119
+ // / Marks this event as completed.
68
120
void setComplete ();
69
121
70
- // Warning. Returned reference will be invalid if event_impl was destroyed.
122
+ // / Returns raw interoperability event handle. Returned reference will be]
123
+ // / invalid if event_impl was destroyed.
124
+ // /
125
+ // / @return a reference to an instance of plug-in event handle.
71
126
RT::PiEvent &getHandleRef ();
127
+ // / Returns raw interoperability event handle. Returned reference will be]
128
+ // / invalid if event_impl was destroyed.
129
+ // /
130
+ // / @return a const reference to an instance of plug-in event handle.
72
131
const RT::PiEvent &getHandleRef () const ;
73
132
133
+ // / Returns context that is associated with this event.
134
+ // /
135
+ // / @return a shared pointer to a valid context_impl.
74
136
const ContextImplPtr &getContextImpl ();
75
137
76
- // Warning. Provided cl_context inside ContextImplPtr must be associated
77
- // with the cl_event object stored in this class
138
+ // / Associate event with the context.
139
+ // /
140
+ // / Provided PiContext inside ContextImplPtr must be associated
141
+ // / with the PiEvent object stored in this class
142
+ // /
143
+ // / @param Context is a shared pointer to an instance of valid context_impl.
78
144
void setContextImpl (const ContextImplPtr &Context);
79
145
80
- void *getCommand () { return m_Command; }
146
+ // / Returns command that is associated with the event.
147
+ // /
148
+ // / @return a generic pointer to Command object instance.
149
+ void *getCommand () { return MCommand; }
81
150
82
- void setCommand (void *Command) { m_Command = Command; }
151
+ // / Associates this event with the command.
152
+ // /
153
+ // / @param Command is a generic pointer to Command object instance.
154
+ void setCommand (void *Command) { MCommand = Command; }
83
155
84
- HostProfilingInfo *getHostProfilingInfo () {
85
- return m_HostProfilingInfo.get ();
86
- }
156
+ // / Returns host profiling information.
157
+ // /
158
+ // / @return a pointer to HostProfilingInfo instance.
159
+ HostProfilingInfo *getHostProfilingInfo () { return MHostProfilingInfo.get (); }
87
160
88
161
private:
89
- RT::PiEvent m_Event = nullptr ;
90
- ContextImplPtr m_Context ;
91
- QueueImplPtr m_Queue ;
92
- bool m_OpenCLInterop = false ;
93
- bool m_HostEvent = true ;
94
- std::unique_ptr<HostProfilingInfo> m_HostProfilingInfo ;
95
- void *m_Command = nullptr ;
162
+ RT::PiEvent MEvent = nullptr ;
163
+ ContextImplPtr MContext ;
164
+ QueueImplPtr MQueue ;
165
+ bool MOpenCLInterop = false ;
166
+ bool MHostEvent = true ;
167
+ std::unique_ptr<HostProfilingInfo> MHostProfilingInfo ;
168
+ void *MCommand = nullptr ;
96
169
};
97
170
98
171
} // namespace detail
0 commit comments