I'm using OpenCL on an nvidia GPU and I keep getting CL_INVALID_KERNEL_ARGS when I try to execute a kernel. I've stepped it down to a very simple program:
__kernel void foo(int a, __write_only image2d_t bar) { int 2 coords = {0, get_global_id(0)}; write_imagef(bar, coords, (float4)a); }
With the following C program (skipped initialization and error checking bits for brevity)
cl_kernel foo = clCreateKernel(program, "foo", &err); int a = 42; clSetKernelArg(foo, 0, sizeof(int), &a); cl_image_format fmt = {CL_INTENSITY, CL_FLOAT}; cl_mem bar = clCreateImage2D(ctx, CL_MEM_WRITE_ONLY|CL_MEM_ALLOC_HOST_PTR, &fmt, 100, 1, 0, NULL, &err)); clSetKernelArg(foo, 1, sizeof(cl_mem), &bar); size_t gws[] = {100}; size_t lws[] = {100}; cl_event evt; clEnqueueNDRangeKernel(queue, foo, 1, NULL, gws, lws, 0, NULL, &evt); clFinish(queue);
The clEnqueueNDRangeKernel keeps returning CL_INVALID_KERNEL_ARGS. Any ideas?
See https://stackoverflow.com/a/20566270/431528.
How large are the buffer objects you are passing? __constant arguments are allocated from separate memory space and not from global memory so therefore you have probably ran out of constant memory
Check CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE
using clGetDeviceInfo
to ensure you are not exceeding that size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With