[PATCH] D36410: [OpenCL] Handle taking address of block captures

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 30 08:19:27 PDT 2017


yaxunl added a comment.

In https://reviews.llvm.org/D36410#855358, @bader wrote:

> In https://reviews.llvm.org/D36410#855282, @Anastasia wrote:
>
> > Ok, I will update it to be implicitly generic then. Just to be sure, @bader do you agree on this too?
>
>
>
>
> > An alternative approached could be (in case we want to allow this code) to **assume captures are located in the generic AS implicitly**. However, in this case programmers should be advised that erroneous AS casts can occur further that can't be diagnosed by the frontend (i.e. if capture address is used further in the operations of a different address space to where the captures physical location is).
>
> I don't have a strong opinion on this topic, but I'm worried about relying on implicit assumptions, which might make code less portable.
>
> How the alternative approach is this suppose to work for enqueue_kernel? Do we assume that the captured variables passed by generic pointer and compiler will assign the correct address space based on the explicit casts in the block?
>  There are some restrictions on kernel parameters: 6.9.a. Arguments to kernel functions declared in a program that are pointers must be declared with the global, constant or local qualifier.


The captured variable is still passed by value. The address taking is on the duplicate of the captured variable, not on the original variable. My understanding is that OpenCL does not require the real address space of a generic pointer to be deducible at compile/link time, therefore a compliant implementation should be able to dereference a generic pointer at runtime.

>> I feel forbidding user taking address of captured variable is too restrictive and make blocks less useful.
> 
> I have no information how widely blocks are used by the OpenCL community and how important this feature is.

The OpenCL spec does not forbid taking address of captured variable. Forbidding taking address of captured variable would violate the spec.


https://reviews.llvm.org/D36410





More information about the cfe-commits mailing list