[LLVMdev] Function-level metadata for OpenCL (was Re: OpenCL support)

David Neto dneto.llvm at gmail.com
Fri Dec 17 13:21:18 PST 2010


However we record the fact that a function is a kernel, the mechanism
should handle the case of a kernel calling another kernel.
Recall that a kernel called by another kernel behaves more like a
regular function.  For example it doesn't have workspace iteration
automatically applied to it; rather it just adopts the work item of
the caller.

About using a calling convention to mark a function as a kernel.  It
seems a handy place to hang it, but is it really exclusive of the
other calling conventions?
In particular, does that approach nicely in the case where a CPU is
running the kernels?  Does that lead to special casing or duplication
in the code generator?  For example, you still have to know what
"real" calling convention to use when a kernel is running on a CPU.
(Forgive my ignorance.)


thanks,
david


On Thu, Dec 16, 2010 at 5:33 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:
> On Thu, Dec 16, 2010 at 06:16:25PM -0000, Anton Lokhmotov wrote:
>> Mike Gist wrote:
>> > You could also consider placing all kernel functions in a 'kernel'
>> > section, or adding a function attribute for kernels.
>> Unlike in Clang, function attribute bit-fields in LLVM are pretty crowded
>> (only couple of bits are unused?).  Besides, we do not want to represent
>> differently the kernel qualifier and optional kernel qualifiers, which
>> require storing <typen> and X, Y, Z values. (I don't even want to think how
>> one would mangle the optional qualifiers into a kernel name and then
>> demangle.)
>>
>> That's why we propose to use metadata for this purpose.  Does anyone have a
>> better idea?
>
> I agree that metadata should be used for function qualifiers;
> a prerequisite being support for non-discardable function-level
> metadata, which would need to be added to LLVM.  I'm undecided on
> whether __kernel should also be represented by metadata; there is
> precedent (PTX backend) for using the calling convention.
>
> I do have a concern though with the semantics of the inliner when it
> needs to inline a function with metadata.  One possibility would be to
> discard the callee's metadata, or somehow merge it with the caller's.
> Discarding seems like the right solution for OpenCL and a good starting
> point (in future we may wish to add attributes to metadata nodes like
> the 'appending' linkage for globals) but sounds like something that
> should be discussed first.
>
> Thanks,
> --
> Peter
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>




More information about the llvm-dev mailing list