Reputation: 11
We met a weird problem:The program worked as expected at start then got block after running for a long time.(10000 times or more).
Command queue:
clEnqueueWriteBuffer(CL_TRUE) * 3 times;
clEnqueueNDRangeKernel() * N times;
clEnqueueReadBuffer();
we use clSetEventCallback to confirm which Command queue is finish and the result is {clEnqueueWriteBuffer(CL_TRUE) * 3 times}’callback function was called correctly and program block at the first clEnqueueNDRangeKernel() function. No matter what kernel function executed,just as what we tried:
kernel_func(__global int *a)
{
unsigned int i = get_global_id(0);
a[i] = 1;
}.
We try to figure out/solve/cover the bug. 1.figure out the bug that makes our program blocked. 2.query the event' status and jump out the function if the queues ware not completed within a certain period time . For now,
We tried to Use clGetEventinfo() to query the clEnqueueNDRangeKernel()'event status. But status didn't change/refresh unless we use an api with block attribute such as clEnqueueWriteBuffer(..CL_TRUE..)/clFinish().
Further more, we tried:
clEnqueueNDRangeKernel(kernel1,event1);
clEnqueueNDRangeKernel(kernel2,event2);
clEnqueueNDRangeKernel(kernel3,event3);
clEnqueueReadBuffer(..CL_FALSE..,event4);
for(;;)
{
clGetEventinfo(event1);
clGetEventinfo(event2);
clGetEventinfo(event3);
clGetEventinfo(event4);
}
No matter how long the program run,the status won't change/reflesh and outputs of clGetEventinfo() are always CL_QUEUED .
another method we tried is Using clSetEventCallback and the result we got is same as above mentioned: program won't call unless we used the apis with block attribute. It means that event status never been set to CL_COMPELET.
We used clflush(clqueuecommand) API and it does work which means event status flushed correctly.
But unfortunately, resources of cl_mem are not able to be released unless GPU kernel function finish,and it will cause memory leak.
all events status of clEnqueueNDRangeKernel(events) were set to CL_SUBMITTED when our program blocked.
Upvotes: 1
Views: 47