using __local
Posted by gmseed on Nov 02, 2013; 10:53am
URL: https://forum.jogamp.org/using-local-tp4030471.html
Hi
I have a triangle-ray intersection kernel that was working fine using global memory but when I add a local kernel argument it's throwing an exception when trying to read the returned intersection point, which is returned in a buffer of 1 float.
Kernel:
__kernel void triangles_ray_intersection(__global float* vxs, __global float* vys, __global float* vzs,
__global float* ray_origin, __global float* ray_direction,
__global float* t_nearest_output,
__local float* t_loc)
buffers:
CLBuffer<FloatBuffer> clBuffer_xs = context.createFloatBuffer(bufferSize, CLMemory.Mem.READ_ONLY);
CLBuffer<FloatBuffer> clBuffer_ys = context.createFloatBuffer(bufferSize, CLMemory.Mem.READ_ONLY);
CLBuffer<FloatBuffer> clBuffer_zs = context.createFloatBuffer(bufferSize, CLMemory.Mem.READ_ONLY);
CLBuffer<FloatBuffer> clBuffer_rayOrigin = context.createFloatBuffer(3, CLMemory.Mem.READ_ONLY);
CLBuffer<FloatBuffer> clBuffer_rayDir = context.createFloatBuffer(3, CLMemory.Mem.READ_ONLY);
CLBuffer<FloatBuffer> clBuffer_t = context.createFloatBuffer(1, CLMemory.Mem.WRITE_ONLY);
arg assignment; noting that i use putNullArg() for the __local arg. Is that correct?:
kernel.putArgs(clBuffer_xs,clBuffer_ys,clBuffer_zs,clBuffer_rayOrigin,clBuffer_rayDir,clBuffer_t)
.putNullArg(localWorkSize);
and finally trying to read back the result:
queue.putWriteBuffer(clBuffer_xs, false)
.putWriteBuffer(clBuffer_ys, false)
.putWriteBuffer(clBuffer_zs, false)
.putWriteBuffer(clBuffer_rayOrigin, false)
.putWriteBuffer(clBuffer_rayDir, false)
.put1DRangeKernel(kernel, 0, globalWorkSize, localWorkSize)
.putReadBuffer(clBuffer_t, true);
It throws the exception at the last putReadBuffer() call:
Exception in thread "main" com.jogamp.opencl.CLException$CLOutOfResourcesException: can not enqueue read-buffer: CLBuffer [id: 422414000 buffer: java.nio.DirectFloatBufferU[pos=0 lim=1 cap=1]] with
cond.: null events: null [error: CL_OUT_OF_RESOURCES]
at com.jogamp.opencl.CLException.newException(CLException.java:79)
at com.jogamp.opencl.CLCommandQueue.putReadBuffer(CLCommandQueue.java:185)
at com.jogamp.opencl.CLCommandQueue.putReadBuffer(CLCommandQueue.java:155)
at com.isl.opencl.jogamp_jocl.geo.threed.intersection.SimpleTriangleMeshRayIntersection3D.nearestIntersection_OpenCL(SimpleTriangleMeshRayIntersection3D.java:149)
at com.isl.opencl.jogamp_jocl.geo.threed.intersection.SimpleTriangleMeshRayIntersection3D.nearestIntersection(SimpleTriangleMeshRayIntersection3D.java:51)
at com.isl.opencl.jogamp_jocl.geo.threed.intersection.SimpleTriangleMeshRayIntersection3D.main(SimpleTriangleMeshRayIntersection3D.java:253)
Thanks
Graham