1 of 1 people found this helpful
Your understanding of qualifiers is correct.
This happens to me once i was trying to do same, and i got following error message: "argument of type __global char * is incompatible with parameter if type char *".
As per the section 6.5.4 from OpenCL spec 1.2, "variables inside a kernel function not declared with an address space qualifier, all variables inside non-kernel functions, and all function arguments are in the __private or private address space. Variables declared as pointers are considered to point to the __private
address space if an address space qualifier is not specified".
And as per the section 6.5 from OpenCL 1.2, a pointer to address space A can only be assigned to a pointer to the same address space A. Casting a pointer to address space A to a pointer to address space B is illegal. In your case, you are trying to assign a pointer to global address space, to a pointer to private address space which is illegal and hence compiler generates error.
OpenCL 2.0 has introduced a new feature "Generic Address Space for arguments to function" which address the same problem. As per the section 3.3.1 from OpenCL 2.0, The generic address space supports conversion of pointers to and from private, local and global address spaces, and hence lets a programmer write a single function that at compile time can take arguments from any of the three named address spaces.This saves a programmer from the error-prone and wasteful practice of creating multiple copies of functions; one for each named address space.
Thank you Gopal for the confirmations. I have indeed read the CL2 spec and that's something definitely needed.
I need to stress that the compiler does not generate any error. It crashes!
In retrospect, I figure out cropping away the output has been a fairly dumb thing to do.
^ ^ ^ Results of hitting "Build and analyze" ^ ^ ^