clEnqueueReadBuffer fails with BSOD

Hi, I have a problem that I can not explain.

On the second iteration clEnqueueReadBuffer hangs the system and it goes to BSOD saying that infinite loop at video adapter detected.

Any suggestions what am I doing wrong?

Here is the outline of the algorithm:

1. Init all variables, queues, kernels, writing data to buffers and so on
//here's the basic cycle goes:
2. do{
   2.1. Write buffer to "Nebalans" kernel
   2.2. clEnqueueNDRangeKernel Nebalans
   2.3. Read buffers from "Nebalans" kernel
   2.4. clFinish(queue)

   2.5. clEnqueueNDRangeKernel JacobiForm
   2.7. Read buffers from "JacobiForm" kernel
   2.8. clFinish(queue)
   2.9. for (i = 1..N)
       2.9.1. for (j = 0..i)
   clSetKernelArg (for kernel SAXPY_cond)
   clEnqueueNDRangeKernel SAXPY_cond
   Read data from kernel SAXPY_cond
   Release mem objects
}while (EndCondition())

code is here

damn…what the?..

I removed all clFinish() and everything works fine.
Why? :confused: