I have 2 OpenCL kernels, run_kernel and apply_kernel that I want completed sequentially one after the other, a few times. The output of run_kernel contains some of the input for apply_kernel, but I'm not sure how to implement this.
Currently, I have a single cl_mem buffer named d_vertexBuffer that I filled with the data I want to give run_kernel, and it does its thing correctly. I set the kernel arg like this:
error = clSetKernelArg(run_kernel, 0, sizeof(cl_mem), (void*) &d_vertexBuffer);
I tried setting apply_kernel to use the same d_vertexBuffer, but I'm guessing this messes up run_kernel accessing to it, since the OpenCL code is getting NaN whenever it tries to access the buffer. I set the apply_kernel like this:
error = clSetKernelArg(apply_kernel, 0, sizeof(cl_mem), (void*) &d_vertexBuffer);
I create the d_vertexBuffer like this:
d_vertexBuffer = clCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, vertexBufferSize, h_vertexBuffer, &error);
In order to run these kernels multiple times, I have a for loop that enqueues the kernel in my command queue. Obviously this must not be the correct way to do it. How would I make it so that the two kernels are able share data?
By the sounds of it, you want the ability to append the important output from run_kernel onto the end of d_vertexBuffer. You could make d_vertexBuffer large enough to store the normal input values (vertexBufferSize) plus the extra vertices from the output of run_kernel. run_kernel copies the part of its output that matters for apply_kernel into the section of d_vertexBuffer above vertexBufferSize
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With