The correct way to inform OpenCL kernels from many memory objects?

In my OpenCL program, I’m going to end up with more than 60 global global memory buffers that each core will need. What is the recommended way to let each core know the location of each of these buffers?

The buffers themselves are stable throughout the life of the application β€” that is, we will allocate buffers when the application starts, call several cores, and then free only the buffers at the end of the application. Their contents, however, may change as the kernels read / write from them.

In CUDA, I did this to create 60+ global program area variables in my CUDA code. Then on the host I will write the address of the device buffers that I allocated to these global variables. Then the kernels would simply use these global variables to find the buffer in which it should run.

What would be the best way to do this in OpenCL? It seems that the CL global variables are slightly different from CUDA, but I can’t find a clear answer if my CUDA method works, and if so, how do I go about passing buffer pointers to global variables. If that doesn't work, what's the best way?

+5
source share
2 answers

60 ! , ? , ​​ , - !

. , 60 , , . :

A is 100 elements
B is 200 elements
C is 100 elements

big_array = A[0:100] B[0:200] C[0:100]
offsets = [0, 100, 300]

big_array , . :

A[50] = big_array[offsets[0] + 50]
B[20] = big_array[offsets[1] + 20]
C[0] = big_array[offsets[2] + 0]

, , " ". . , , , .

, , clCreateSubBuffer: http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clCreateSubBuffer.html, .

, , 60 , clcletKernelArgs OpenCL . , , .

+1

. -, , , , :

kernel void awesome_parallel_stuff(global float* buf1, ..., global float* buf60)

. clSetKernelArg clEnqueueNDRangeKernel, .

, , . , , , clSetKernelArg , .

0

All Articles