18#ifndef __itkOpenCLEvent_h
19#define __itkOpenCLEvent_h
120 bool IsNull()
const {
return this->m_Id == 0; }
129 bool IsQueued()
const {
return GetStatus() == CL_QUEUED; }
139 bool IsRunning()
const {
return GetStatus() == CL_RUNNING; }
144 bool IsComplete()
const {
return GetStatus() == CL_COMPLETE; }
148 bool IsError()
const {
return GetStatus() < 0; }
173 void ( CL_CALLBACK * pfn_notify )( cl_event, cl_int,
void * ),
174 void * user_data =
nullptr );
219template<
typename charT,
typename traits >
221std::basic_ostream< charT, traits > &
222operator<<( std::basic_ostream< charT, traits > & strm,
225 const cl_event
id =
event.GetEventId();
229 strm <<
"OpenCLEvent()";
233 const cl_command_type command =
event.GetCommandType();
234 const cl_int status =
event.GetStatus();
237 const char * commandName;
240 case CL_COMMAND_NDRANGE_KERNEL:
241 commandName =
"clEnqueueNDRangeKernel";
break;
242 case CL_COMMAND_TASK:
243 commandName =
"clEnqueueTask";
break;
244 case CL_COMMAND_NATIVE_KERNEL:
245 commandName =
"clEnqueueNativeKernel";
break;
246 case CL_COMMAND_READ_BUFFER:
247 commandName =
"clEnqueueReadBuffer";
break;
248 case CL_COMMAND_WRITE_BUFFER:
249 commandName =
"clEnqueueWriteBuffer";
break;
250 case CL_COMMAND_COPY_BUFFER:
251 commandName =
"clEnqueueCopyBuffer";
break;
252 case CL_COMMAND_READ_IMAGE:
253 commandName =
"clEnqueueReadImage";
break;
254 case CL_COMMAND_WRITE_IMAGE:
255 commandName =
"clEnqueueWriteImage";
break;
256 case CL_COMMAND_COPY_IMAGE:
257 commandName =
"clEnqueueCopyImage";
break;
258 case CL_COMMAND_COPY_IMAGE_TO_BUFFER:
259 commandName =
"clEnqueueCopyImageToBuffer";
break;
260 case CL_COMMAND_COPY_BUFFER_TO_IMAGE:
261 commandName =
"clEnqueueCopyBufferToImage";
break;
262 case CL_COMMAND_MAP_BUFFER:
263 commandName =
"clEnqueueMapBuffer";
break;
264 case CL_COMMAND_MAP_IMAGE:
265 commandName =
"clEnqueueMapImage";
break;
266 case CL_COMMAND_UNMAP_MEM_OBJECT:
267 commandName =
"clEnqueueUnmapMemObject";
break;
268 case CL_COMMAND_MARKER:
269 commandName =
"clEnqueueMarker";
break;
270 case CL_COMMAND_ACQUIRE_GL_OBJECTS:
271 commandName =
"clEnqueueAcquireGLObjects";
break;
272 case CL_COMMAND_RELEASE_GL_OBJECTS:
273 commandName =
"clEnqueueReleaseGLObjects";
break;
275 case CL_COMMAND_READ_BUFFER_RECT:
276 commandName =
"clEnqueueReadBufferRect";
break;
277 case CL_COMMAND_WRITE_BUFFER_RECT:
278 commandName =
"clEnqueueWriteBufferRect";
break;
279 case CL_COMMAND_COPY_BUFFER_RECT:
280 commandName =
"clEnqueueCopyBufferRect";
break;
281 case CL_COMMAND_USER:
282 commandName =
"clCreateUserEvent";
break;
285 commandName =
"clEnqueueBarrierWithWaitList";
break;
287 commandName =
"clEnqueueFillImage";
break;
289 commandName =
"clEnqueueFillBuffer";
break;
291 commandName =
"clEnqueueFillImage";
break;
293 commandName =
"Unknown";
break;
297 const char * statusName;
301 statusName =
"completed";
break;
303 statusName =
"running";
break;
305 statusName =
"submitted";
break;
307 statusName =
"queued";
break;
309 statusName =
"Unknown";
break;
311 if( status != CL_COMPLETE )
314 strm <<
"OpenCLEvent(id:" <<
reinterpret_cast< long >( id )
315 <<
" command:" << commandName
316 <<
" status:" << statusName
321 cl_ulong queueTime, runTime, finishTime;
322 if( clGetEventProfilingInfo
323 (
id, CL_PROFILING_COMMAND_QUEUED,
324 sizeof( queueTime ), &queueTime, 0 ) != CL_SUCCESS
325 || clGetEventProfilingInfo
326 (
id, CL_PROFILING_COMMAND_START,
327 sizeof( runTime ), &runTime, 0 ) != CL_SUCCESS
328 || clGetEventProfilingInfo
329 (
id, CL_PROFILING_COMMAND_END,
330 sizeof( finishTime ), &finishTime, 0 ) != CL_SUCCESS )
334 strm <<
"OpenCLEvent(id:" <<
reinterpret_cast< long >( id )
335 <<
" command:" << commandName
336 <<
" status:" << statusName
342 const double fullDuration = ( finishTime - queueTime ) / 1000000.0f;
343 const double runDuration = ( finishTime - runTime ) / 1000000.0f;
344 strm <<
"OpenCLEvent(id:" <<
reinterpret_cast< long >( id )
345 <<
" command:" << commandName
346 <<
" status:" << statusName
347 <<
" full-time:" << fullDuration
348 <<
" ms running-time:" << runDuration
OpenCLEvent class represents an OpenCL event object.
OpenCLEvent & operator=(const OpenCLEvent &other)
cl_ulong GetSubmitTime() const
cl_ulong GetFinishTime() const
cl_ulong GetRunTime() const
cl_command_type GetCommandType() const
cl_ulong GetQueueTime() const
OpenCLEvent(const OpenCLEvent &other)
OpenCLEvent(const cl_event id)
cl_int SetCallback(cl_int type, void(CL_CALLBACK *pfn_notify)(cl_event, cl_int, void *), void *user_data=nullptr)
cl_event GetEventId() const
The OpenCLUserEvent class represents OpenCL user events.
#define CL_COMMAND_FILL_IMAGE
#define CL_COMMAND_MIGRATE_MEM_OBJECTS
#define CL_COMMAND_BARRIER
#define CL_COMMAND_FILL_BUFFER
bool ITKOpenCL_EXPORT operator==(const OpenCLCommandQueue &lhs, const OpenCLCommandQueue &rhs)
bool ITKOpenCL_EXPORT operator!=(const OpenCLCommandQueue &lhs, const OpenCLCommandQueue &rhs)
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &strm, const OpenCLCommandQueue &queue)