cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

maxdz8
Elite

Please compile this

Hello,

I start suspecting something with my system could be very wrong. I have the following kernel:


void boom(global uint4 *X)


{


    {


      uint4 tmp;


    tmp = (uint4)(


          (*(X + 1)).x,


        (*(X + 2)).y,


        (*(X + 3)).z,


          (*(X + 0)).w


      );


      *X = tmp;


    }


}







__attribute__((reqd_work_group_size(256, 1, 1)))


kerne


void CompilerBLAST(global uint4 * restrict xeight) {


  boom(xeight);


}


If I compile it as is, everything is nice.

If I remove the global qualifier from LN1, the following happens:

11_52_00-clBoom - CodeXL _ Analyze Mode.png

This happens as well in my program if I try to build code like this.

My reading of the OpenCL specification is that unqualified pointers like this get interpreted as private by default and this is thus an invalid pointer cast.

Does this happen only to me?

As a side note: is my understanding of qualifiers correct?

0 Likes
2 Replies
gopal
Staff

Hi,

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.

Thanks,


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.

09_25_20-Greenshot.png

^ ^ ^ Results of hitting "Build and analyze" ^ ^ ^

0 Likes