18#ifndef itkOpenCLEvent_h
19#define itkOpenCLEvent_h
123 return this->m_Id == 0;
140 return GetStatus() == CL_QUEUED;
149 return GetStatus() == CL_SUBMITTED;
158 return GetStatus() == CL_RUNNING;
167 return GetStatus() == CL_COMPLETE;
175 return GetStatus() < 0;
204 SetCallback(cl_int type,
void(CL_CALLBACK * pfn_notify)(cl_event, cl_int,
void *),
void * user_data =
nullptr);
254template <
typename charT,
typename traits>
255inline std::basic_ostream<charT, traits> &
258 const cl_event
id =
event.GetEventId();
262 strm <<
"OpenCLEvent()";
266 const cl_command_type command =
event.GetCommandType();
267 const cl_int status =
event.GetStatus();
270 const char * commandName;
273 case CL_COMMAND_NDRANGE_KERNEL:
274 commandName =
"clEnqueueNDRangeKernel";
276 case CL_COMMAND_TASK:
277 commandName =
"clEnqueueTask";
279 case CL_COMMAND_NATIVE_KERNEL:
280 commandName =
"clEnqueueNativeKernel";
282 case CL_COMMAND_READ_BUFFER:
283 commandName =
"clEnqueueReadBuffer";
285 case CL_COMMAND_WRITE_BUFFER:
286 commandName =
"clEnqueueWriteBuffer";
288 case CL_COMMAND_COPY_BUFFER:
289 commandName =
"clEnqueueCopyBuffer";
291 case CL_COMMAND_READ_IMAGE:
292 commandName =
"clEnqueueReadImage";
294 case CL_COMMAND_WRITE_IMAGE:
295 commandName =
"clEnqueueWriteImage";
297 case CL_COMMAND_COPY_IMAGE:
298 commandName =
"clEnqueueCopyImage";
300 case CL_COMMAND_COPY_IMAGE_TO_BUFFER:
301 commandName =
"clEnqueueCopyImageToBuffer";
303 case CL_COMMAND_COPY_BUFFER_TO_IMAGE:
304 commandName =
"clEnqueueCopyBufferToImage";
306 case CL_COMMAND_MAP_BUFFER:
307 commandName =
"clEnqueueMapBuffer";
309 case CL_COMMAND_MAP_IMAGE:
310 commandName =
"clEnqueueMapImage";
312 case CL_COMMAND_UNMAP_MEM_OBJECT:
313 commandName =
"clEnqueueUnmapMemObject";
315 case CL_COMMAND_MARKER:
316 commandName =
"clEnqueueMarker";
318 case CL_COMMAND_ACQUIRE_GL_OBJECTS:
319 commandName =
"clEnqueueAcquireGLObjects";
321 case CL_COMMAND_RELEASE_GL_OBJECTS:
322 commandName =
"clEnqueueReleaseGLObjects";
325 case CL_COMMAND_READ_BUFFER_RECT:
326 commandName =
"clEnqueueReadBufferRect";
328 case CL_COMMAND_WRITE_BUFFER_RECT:
329 commandName =
"clEnqueueWriteBufferRect";
331 case CL_COMMAND_COPY_BUFFER_RECT:
332 commandName =
"clEnqueueCopyBufferRect";
334 case CL_COMMAND_USER:
335 commandName =
"clCreateUserEvent";
339 commandName =
"clEnqueueBarrierWithWaitList";
342 commandName =
"clEnqueueFillImage";
345 commandName =
"clEnqueueFillBuffer";
348 commandName =
"clEnqueueFillImage";
351 commandName =
"Unknown";
356 const char * statusName;
360 statusName =
"completed";
363 statusName =
"running";
366 statusName =
"submitted";
369 statusName =
"queued";
372 statusName =
"Unknown";
375 if (status != CL_COMPLETE)
378 strm <<
"OpenCLEvent(id:" <<
reinterpret_cast<long>(id) <<
" command:" << commandName <<
" status:" << statusName
383 cl_ulong queueTime, runTime, finishTime;
384 if (clGetEventProfilingInfo(
id, CL_PROFILING_COMMAND_QUEUED,
sizeof(queueTime), &queueTime, 0) != CL_SUCCESS ||
385 clGetEventProfilingInfo(
id, CL_PROFILING_COMMAND_START,
sizeof(runTime), &runTime, 0) != CL_SUCCESS ||
386 clGetEventProfilingInfo(
id, CL_PROFILING_COMMAND_END,
sizeof(finishTime), &finishTime, 0) != CL_SUCCESS)
390 strm <<
"OpenCLEvent(id:" <<
reinterpret_cast<long>(id) <<
" command:" << commandName <<
" status:" << statusName
396 const double fullDuration = (finishTime - queueTime) / 1000000.0f;
397 const double runDuration = (finishTime - runTime) / 1000000.0f;
398 strm <<
"OpenCLEvent(id:" <<
reinterpret_cast<long>(id) <<
" command:" << commandName <<
" status:" << statusName
399 <<
" full-time:" << fullDuration <<
" ms running-time:" << runDuration <<
"ms)";
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)