AMD's new release of ATI Stream SDK v2.0 w/ OpenCL(tm) 1.0 support is now available:
I just downloaded SDK 2.0 (64-bit Linux) and upgraded from "beta4", but it has a bug that breaks my program.
The bug is:
cl_mem invalid_memory_object = (cl_mem)(-1);
error = clSetKernelArg(kernel, argnum, sizeof(cl_mem), &invalid_memory_object);
The OpenCL standard specifies that an error of "CL_INVALID_MEM_OBJECT" must be returned, which is so in "beta4", but after the upgrade, no error is returned (CL_SUCCESS).
Sorry, but my program cannot work without this feature. Is there any chance of fixing it?
BTW, I encountered several other bugs (which are not as critical as this one): where is the best place to report them?
Mosix0,
We will report this to developers. I don't really understand how it blocks your code. Please post in this forum as a separate post if you encounter any problems/bugs.
Mosix0,
Could you please post testcase here to reproduce your problem?
Well, here is the most minimal program to test this issue:
#include <cl.h>
#include <stdlib.h>
#include <stdio.h>
char *src = "__kernel void add(__global int *A, __global int *B, __global int *C, int n){int i = get_global_id(0);C = A + B;}";
int
main(na, argv)
char *argv[];
{
cl_platform_id platform;
cl_context_properties cps[3];
static cl_context context;
cl_program program;
cl_kernel kernel;
cl_mem invalid_mem_object = (cl_mem)(-1);
cl_int result;
if(clGetPlatformIDs(1, &platform, NULL) != CL_SUCCESS)
{
fprintf(stderr, "Could not get a platform\n");
exit(1);
}
cps[0] = CL_CONTEXT_PLATFORM;
cps[1] = (cl_context_properties)platform;
cps[2] = 0;
if(!(context = clCreateContextFromType(cps, CL_DEVICE_TYPE_ALL,
NULL, NULL, NULL)))
{
fprintf(stderr, "No context\n");
exit(1);
}
if(!(program = clCreateProgramWithSource(context, 1,
(const char **)&src, NULL, NULL)))
{
fprintf(stderr, "No program\n");
exit(1);
}
if(clBuildProgram(program, 0, NULL, "", NULL, NULL) != CL_SUCCESS)
{
printf("Program not built\n");
exit(1);
}
if(!(kernel = clCreateKernel(program, "add", NULL)))
{
fprintf(stderr, "No kernel\n");
exit(1);
}
result = clSetKernelArg(kernel, 0, sizeof(cl_mem), &invalid_mem_object);
if(result == CL_INVALID_MEM_OBJECT)
printf("Correct!\n");
else
printf("Wrong - got error %d\n", result);
exit(0);
}
mosix0,
We will get you back once we get a reply from Khronos Group. Presently validation of runtime object missing after adding ICD model.
Workaround for your problem now is define invalid_mem_object as follows
cl_mem invalid_mem_object = (cl_mem)(NULL);
Thank you, this works and helps with my immediate problem, but it goes against the OpenCL specification:
Under the description of clSetKernelArg(), chapter 5.5.2, "Setting kernel arguments":
... A NULL value can also be specified if the argument is a buffer object in which case a NULL value will be used as the value for the argument declared as a pointer to __global or __constant memory in the kernel.
Mosix0,
I donot see any solution other than this.
" I donot see any solution other than this."
Well, it allows me to keep working past the date when the "beta4" release expires, so thank you for this. I did not consider using a NULL because it goes against the holy-specs. As for the future, the solution is simple - just follow the good book, meaning that a value of NULL should be a valid argument and any other value which is not a valid memory-object should produce an "CL_INVALID_MEM_OBJECT" error.
This problem was still not solved in SDK v2.01
The fact is that NULL is a valid kernel argument.
For a solution, the SDK must maintain a list of existing/valid memory-objects:
if the argument is not on the list, then it is not a valid argument.
(otherwise, a segmentation-fault is likely to occur once the kernel is activated)