clGetEventProfilingInfo error

Hi all

I’m trying to compute a kernel execution time. Following the example of the OpenCL Programing Guide my code look like this:

cl_event eventGlobal;
errcode_ret = clEnqueueNDRangeKernel ( hCmdQueue, hKernelGlobal, 2, 0, szGlobalWorkSize, szLocalWorkSize, 0, 0, &eventGlobal);
oclCheckError ( errcode_ret, CL_SUCCESS );
cl_ulong end, start;

errcode_ret = clWaitForEvents(1, &eventGlobal);
oclCheckError(errcode_ret, CL_SUCCESS);
errcode_ret = clGetEventProfilingInfo(eventGlobal, CL_PROFILING_COMMAND_END, sizeof(cl_ulong), &end, 0);
errcode_ret |= clGetEventProfilingInfo(eventGlobal, CL_PROFILING_COMMAND_START, sizeof(cl_ulong), &start, 0);
oclCheckError(errcode_ret, CL_SUCCESS);
cout<<"Global kernel time: "<<(end-start)*1.0e-6f<<"(ms)"<<endl;

The problem is that the errcode_ret returned from clGetEventProfilingInfo is always CL_INVALID_VALUE. I review the code several times but I can’t find the INVALID_VALUE error.

The rest of the code works fine, I mean, kernel execution is fine, the result is ok…

Does anyone know where the problem is?

Thank you.

Has your command queue been created with profiling support?
Furthermore I guess you should wait command processing end before querying end time.

edit : oups :slight_smile: I missed the clWaitForEVENTS

No :oops: That was the mistake. I didn’t read that the queue must be created with param CL_QUEUE_PROFILING_ENABLE in order to set the profilings enabled.

Thank you very much. Everything works fine now.

Ok :slight_smile: