[PATCH] [OpenCL] Promoting OpenCL image types

Tanya Lattner lattner at apple.com
Thu Feb 21 15:51:58 PST 2013


On Feb 20, 2013, at 3:23 AM, Joey Gouly <joey.gouly at arm.com> wrote:

>>> functions, such as: ASTContext::getCanonicalParamType,
>>> and ASTContext::getAdjustedParameterType, had to be changed to keep the
>>> qualifiers for OpenCL image types.
> 
>> I do not understand. Those functions are designed to strip off qualifiers,
> so that makes sense. Can you give an example of why using Qualifiers does
> not work?
> Then we lose the access info. The main problem I found was (we had a  few
> other problems, but I can't remember off hand):
> 
> void img_ro(read_only image2d_t src);
> 
> kernel void test(write_only image2d_t dst) {
>  img_ro(dst);
> }
> 
> We didn't error on this, because
>  a) img_ro was built with a ASTContext::getFunctionType(), which calls
> getCanonicalParamType, which loses the qualifiers
>  b) in Sema::CheckAssignmentConstraints (to check if we can call img_ro
> with dst), the types are compared using the unqualified types
> 
> Another issue: We'd like to be able to have the access qualifiers around at
> CodeGen stage.
> 

Ok, so take AddressSpaces for example. These are implemented as qualifiers and if you changed the read_only/write_only to an address space (and make them different) you would get an error about changing address space pointers when passing dst to that function. Address spaces are also available at codgen too.

Using AddressSpaces as my example, to me it seems like its doable with qualifiers. Maybe take a look at how that works and see if maybe you are just missing something? I think its cleaner to use qualifiers.

-Tanya

> I've attached a *rough* patch that shows how we did this with Qualifiers.
> Please note, I do not expect this to apply, or work cleanly,
> this is just to give you a basic idea of our current solution, against my
> proposed solution.
> 
> -Tanya
> 
>> 
>> Therefore, my proposal is to promote the OpenCL image types from builtin
>> types, to their own type. This will allow us
>> to store the modifiers in the type directly.
>> 
>> The first patch implements this, and the second patch implements basic
>> support for the qualifiers.
>> 
>> Please review and comment!
>> 
>> Thanks,
>> Joey
>> 
> <image_types_p2.diff><image_types_p1.diff>__________________________________
> _____________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 
> 
> <tmp.patch>




More information about the cfe-commits mailing list