我想将一个cl_mem缓冲区数组传递给一个内核,但这似乎不可行。谁知道这里有什么意义?如果它实际上不可行,那么当我想将许多缓冲区对象传递到内核时,我怎样才能实现这个目标?非常感谢。
答案 0 :(得分:0)
对于
等内核 kernelString = "__kernel void advect(" +
" __global float *x,"+
" __global float *y,"+
" __global float *z,"+
" __global float *vx,"+
" __global float *vy,"+
" __global float *vz,"+
" ... many arguments,"+
" __global float *x2,"+
" __global float *y2,"+
" __global float *z2,"+
" __global float *vx2,"+
" __global float *vy2,"+
" __global float *vz2)"+
"{"+
"..."+
"}"+
而不是
CL.clSetKernelArg(kernel0, 0, Sizeof.cl_mem, Pointer.to(girisDizisi0Buf));
CL.clSetKernelArg(kernel0, 1, Sizeof.cl_mem, Pointer.to(girisDizisi1Buf));
CL.clSetKernelArg(kernel0, 2, Sizeof.cl_mem, Pointer.to(girisDizisi2Buf));
CL.clSetKernelArg(kernel0, 3, Sizeof.cl_mem, Pointer.to(girisDizisi3Buf));
CL.clSetKernelArg(kernel0, 4, Sizeof.cl_mem, Pointer.to(girisDizisi4Buf));
CL.clSetKernelArg(kernel0, 5, Sizeof.cl_mem, Pointer.to(girisDizisi5Buf));
您可以在循环中对数组执行相同的操作
for(int i=0;i<max;i++)
{
CL.clSetKernelArg(kernel0, i, Sizeof.cl_mem, Pointer.to(BufferYourArray[i]));
}
如果你在java的包装器中这样做,你可能需要一个String连接器方法将实际的参数放在内核字符串中。您也可以使用二维参数。它不应该是C / C ++包装器中的字符串问题。