Piyush Kumar
Piyush Kumar

Reputation: 167

Profiling info for an opencl command?

I am trying to measure the execution time of a command using profiling info. This is my code

cl_event profEvent;
cl_ulong timeStart,timeStop;
ciErr=clEnqueueNDRangeKernel(cqCommandQueue,ckKernel,1,NULL,&szGlobalWorkSize,NULL,0,NULL,profEvent);
ciErr=clWaitForEvents(1,&profEvent);
clGetEventProfilingInfo(profEvent,CL_PROFILING_COMMAND_END,sizeof(timeStop),&timeStop,NULL);
clGetEventProfilingInfo(profEvent,CL_PROFILING_COMMAND_START,sizeof(timeStart),&timeStart,NULL);
printf("\nstart=%ld",timeStart);
printf("\nstop=%ld",timeStop);
printf("\nTime after profiling in SUB is \t\t%Ld",timeStart-timeStop);

As per the stuff found over net, this should work fine, but I am getting the following output

start=6492816
stop=0
Time after profiling in SUB is          6492816

error -58 in NDRANget

Now -58 indicates invalid event and I am unable to figure this thing out how to get the event working? Please show me how to correct this problem.

Thanks Piyush

Upvotes: 0

Views: 167

Answers (1)

DarkZeros
DarkZeros

Reputation: 8410

The event has to be passed as a pointer, so it can return the event object in the call.

It should be like this:

ciErr=clEnqueueNDRangeKernel(cqCommandQueue,ckKernel,1,NULL,&szGlobalWorkSize,NULL,0,NULL,&profEvent);

Upvotes: 1

Related Questions