Reputation: 1087
I was going through this article http://www.dyn-lab.com/articles/cl-gl.html
Now , if OpenCl kernel objects have whole memory R/W access & OpenGL can access data in memory witout CPU-GPU interaction to transfer data, how does it reduce CPU/GPU idle time since if GPU access data from main memory itself then memory bus access would cause CPU to stay idle(say cache does not hit) if some CPU instruction want memory access.
May be i have misunderstood the concept! Help me understand the conflict.
Upvotes: 1
Views: 1370
Reputation: 391
The article talks about using the GPU memory for both OpenGL and OpenCL:
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, 400, NULL, GL_STATIC_DRAW);
vbo_buff = clCreateFromGLBuffer(ctx, CL_MEM_WRITE_ONLY, 2, &err);
It's important to see why the third argument of glBufferData is set to NULL. This states that the host won't transfer data to the VBO. That is, the VBO is configured to hold 400 bytes, but this memory won't be allocated on the host. Instead, the 400 bytes will be allocated on the GPU and the kernel will initialize the VBO data by accessing the write-only buffer object, vbo_buff.
The application will create and fill the buffer once, at which point data transfer between the CPU/main memory and the GPU/GPU memory takes place. After that, OpenGL and OpenCL work in tandem on their local memory, in which they share their data. You eliminate further data transfers, and you gain using faster GPU memory and the GPU's (parallel) processing power.
Upvotes: 1