OpenCL.net

I am using the OpenCL.net library under C#. (http://sourceforge.net/projects/openclnet/)
Just have a look at the code and see my problem! it’s commented!

Any Ideas?

Thanks!!



...
//allocate Buffer for last KernelArg fieldLog
            IntPtr ct = (IntPtr)context;
            //constantInts = int value
            int buffSize = width * height * constantInts[3] * sizeof(float);
            IntPtr intPtrBufferSize = (IntPtr)buffSize;
            int offset = 0;
            IntPtr Offset = new IntPtr();
            Offset = (IntPtr)offset;
            

            ErrorCode err = new ErrorCode();

            IntPtr buffer;
            buffer = OpenCL.CreateBuffer(ct, (ulong)MemFlags.READ_WRITE, intPtrBufferSize, null, out err);

            IntPtr cq = (IntPtr)commandQueue;
            fixed (float* pInput = fieldLog)
            {
                //fieldLog (pInput) contains 0.0
                //init buffer (err = SUCCESS, but doesn't initializes buffer) ????? why?
                err = OpenCL.EnqueueWriteBuffer(cq, buffer, 1, Offset, intPtrBufferSize, pInput, 0, null, null);
            }
            float* p = (float*)buffer.ToPointer();
            //Argument to buffer
            CLKernel.SetIntPtrArg(7, buffer);


                //execute Kernel (works fine)
                commandQueue.EnqueueNDRangeKernel(CLKernel, 2, null, globalWorkSize, null);

            fixed (float* presult = fieldLog)
            {
                presult[0] = 1;
                //hangs when blocking_read = true, SUCCESS when blocking read = false (0)
                //returns err = SUCCESS but doesn't read buffer into presult ?? why??
                err = OpenCL.EnqueueReadBuffer(cq, buffer, 0, Offset, intPtrBufferSize, presult, 0, null, null);

                return new IntPtr((void*)presult);
            }
...