1 Reply Latest reply on Jul 23, 2010 10:39 AM by nou

    OpenCL memory management questions ?




      I have a few questions about the way we must handle the 'CL buffer'.

      Case 1

      I create a buffer with 'clCreateBuffer' the use it. Then I use it several times in a loop, something like this

      cl_mem buffer = clCreateBuffer(...)
      kernel->setArg(4, buffer);

      for(int i=0; i < 1000; i++)

      Question 1 : Does my buffer is sent each time from CPU memory to GPU memory, or only once ?

      Case 2

      After I need to changes some informations in the buffer, then I do the following :

      queue->Finish(); // Insure that the CL commands are completed !
      delete buffer; // Release the buffer

      Questions :

      1) Does 'queue->Finish()' is enough to complete the OpenCL command ?

      2) Should I use 'delete' or clReleaseMemObject ?

      3) Then I must call 'buffer = clCreateBuffer(...)' and also 'kernel->setArg(4, buffer);' to set up the new buffer ?