JOCLSample_1_1.java contains following code:
long bufferRowPitch = sizeX * Sizeof.cl_float;
long bufferSlicePitch = sizeX * sizeY;
long hostRowPitch = regionSizeX * Sizeof.cl_float;
long hostSlicePitch = regionSizeX * regionSizeY;
When I run it I get:
CL_DEVICE_NAME: Pitcairn
Enqueue buffer region read, waiting for user event
Exception in thread "main" org.jocl.CLException: CL_INVALID_VALUE
at org.jocl.CL.checkResult(CL.java:686)
at org.jocl.CL.clEnqueueReadBufferRect(CL.java:14304)
at org.jocl.samples.JOCLSample_1_1.main(JOCLSample_1_1.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
However, when I change the code to:
long bufferRowPitch = sizeX * Sizeof.cl_float;
long bufferSlicePitch = sizeX * sizeY * Sizeof.cl_float;
long hostRowPitch = regionSizeX * Sizeof.cl_float;
long hostSlicePitch = regionSizeX * regionSizeY * Sizeof.cl_float;
I get the following output:
CL_DEVICE_NAME: Pitcairn
Enqueue buffer region read, waiting for user event
Waiting before setting event status to CL_COMPLETE
Seconds left: 3
Seconds left: 2
Seconds left: 1
Setting event status to CL_COMPLETE
Event cl_event[0x7ff6409d00b0] reached status CL_COMPLETE, user data: Event callback user data
Buffer region was read:
10.0 12.0
18.0 20.0
Memory object cl_mem[0x7ff6403adce0] was destroyed, user data: Memory object destructor callback user data
PASSED
Seems that there’s a bug in the code.