Re: problems with arg size
Posted by Michael Bien on Jul 06, 2011; 9:55pm
URL: https://forum.jogamp.org/problems-with-arg-size-tp3099042p3146370.html
works. constant memory is apparently just size-restricted global
read-only memory, you use it by allocating plain old CLBuffers and
passing the pointer to the kernel. Thats why you got the kernel size arg
error since the driver expected a pointer.
quick test:
public static void main(String[] args) throws IOException {
CLContext context =
CLContext.create(CLPlatform.getDefault(CLPlatformFilters.type(Type.CPU)));
System.out.println(context);
CLProgram program =
context.createProgram(KernelArrayTest.class.getResourceAsStream("test.cl")).build();
CLKernel kernel = program.createCLKernel("foo");
CLBuffer<IntBuffer> buffer = context.createBuffer(
Buffers.newDirectIntBuffer(new int[]{1,2,3,4}),
CLBuffer.Mem.COPY_BUFFER);
kernel.setArg(0, buffer);
CLCommandQueue queue =
context.getMaxFlopsDevice().createCommandQueue();
queue.putTask(kernel).finish();
context.release();
}
kernel...
#pragma OPENCL EXTENSION cl_amd_printf : enable
kernel void foo(constant int array[4]) {
printf("%d\n", array[0]);
printf("%d\n", array[1]);
printf("%d\n", array[2]);
printf("%d\n", array[3]);
}
output...
run-single:
CLContext [id: 140558620923808, platform: ATI Stream, profile:
FULL_PROFILE, devices: 1]
1
2
3
4
BUILD SUCCESSFUL (total time: 1 second)