[cfe-dev] [OpenCL] Representing kernel attributes by LLVM target-dependent attribute-value pairs instead of metadata

Mekhanoshin, Stanislav via cfe-dev cfe-dev at lists.llvm.org
Wed May 11 11:39:21 PDT 2016


Sam,

I guess metadata attached right to the function should work as well. Nothing would hold us from forming the same list of strings in a single metadata entry. The only problem I see here if someone else would want to use function metadata attachment for some other reason, so we will need to search and/or merge it.
Given that consideration attributes looks better to me, they are already a top-level list.

Stas

From: Liu, Yaxun (Sam)
Sent: 11 мая 2016 г. 10:18
To: Anastasia Stulova <Anastasia.Stulova at arm.com>; Mekhanoshin, Stanislav <Stanislav.Mekhanoshin at amd.com>; cfe-dev (cfe-dev at lists.llvm.org) <cfe-dev at lists.llvm.org>; Pan, Xiuli <xiuli.pan at intel.com>; Bader, Alexey (alexey.bader at intel.com) <alexey.bader at intel.com>
Cc: Stellard, Thomas <Tom.Stellard at amd.com>; Sumner, Brian <Brian.Sumner at amd.com>; nd <nd at arm.com>
Subject: RE: [OpenCL] Representing kernel attributes by LLVM target-dependent attribute-value pairs instead of metadata

Hi Anastasia,

Target-dependent attribute-value pair is not limited to one target. It is just a pair of strings attached to a function. It can be used by different targets as far as they accept a commonly agreed attribute name.

The function metadata also requires a commonly agreed attribute name. In this aspect it is similar to target-dependent attribute-value pair. However it may be more difficult to manipulate.

Stas, any comments on this?

Thanks.

Sam

From: Anastasia Stulova [mailto:Anastasia.Stulova at arm.com]
Sent: Wednesday, May 11, 2016 12:32 PM
To: Mekhanoshin, Stanislav <Stanislav.Mekhanoshin at amd.com<mailto:Stanislav.Mekhanoshin at amd.com>>; Liu, Yaxun (Sam) <Yaxun.Liu at amd.com<mailto:Yaxun.Liu at amd.com>>; cfe-dev (cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>) <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>>; Pan, Xiuli <xiuli.pan at intel.com<mailto:xiuli.pan at intel.com>>; Bader, Alexey (alexey.bader at intel.com<mailto:alexey.bader at intel.com>) <alexey.bader at intel.com<mailto:alexey.bader at intel.com>>
Cc: Stellard, Thomas <Tom.Stellard at amd.com<mailto:Tom.Stellard at amd.com>>; Sumner, Brian <Brian.Sumner at amd.com<mailto:Brian.Sumner at amd.com>>; nd <nd at arm.com<mailto:nd at arm.com>>
Subject: RE: [OpenCL] Representing kernel attributes by LLVM target-dependent attribute-value pairs instead of metadata

Hi Sam,

Interesting idea, I am just concerned whether target-dependent attribute-value pairs are really correct for this use case. Because kernel attributes aren't really target dependent.

However, I agree that current approach is painful enough. Do you think switching to function metadata (see llvm at r235783) would help instead? This way we will also have the kernel attributes directly accessible from the function, simplifying querying them (as compared to what we have at the moment).

Thanks,
Anastasia

From: Mekhanoshin, Stanislav [mailto:Stanislav.Mekhanoshin at amd.com]
Sent: 09 May 2016 21:14
To: Liu, Yaxun (Sam); cfe-dev (cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>); Anastasia Stulova; Pan, Xiuli; Bader, Alexey (alexey.bader at intel.com<mailto:alexey.bader at intel.com>)
Cc: Stellard, Thomas; Sumner, Brian
Subject: RE: [OpenCL] Representing kernel attributes by LLVM target-dependent attribute-value pairs instead of metadata

It will make our life much easier I would say.

Stas

From: Liu, Yaxun (Sam)
Sent: Monday, May 09, 2016 1:05 PM
To: cfe-dev (cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>) <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>>; 'anastasia.stulova at arm.com' <anastasia.stulova at arm.com<mailto:anastasia.stulova at arm.com>>; Pan, Xiuli <xiuli.pan at intel.com<mailto:xiuli.pan at intel.com>>; Bader, Alexey (alexey.bader at intel.com<mailto:alexey.bader at intel.com>) <alexey.bader at intel.com<mailto:alexey.bader at intel.com>>
Cc: Stellard, Thomas <Tom.Stellard at amd.com<mailto:Tom.Stellard at amd.com>>; Sumner, Brian <Brian.Sumner at amd.com<mailto:Brian.Sumner at amd.com>>; Mekhanoshin, Stanislav <Stanislav.Mekhanoshin at amd.com<mailto:Stanislav.Mekhanoshin at amd.com>>
Subject: [OpenCL] Representing kernel attributes by LLVM target-dependent attribute-value pairs instead of metadata

Hi,

When SPIR 1.2/2.0 spec was developed, there was no target-dependent attribute-value pair in LLVM. As such, kernel attributes were represented as metadata.

This caused lots of inconvenience since these metadata are difficult to manipulate/change when kernel functions went through transformations in backends.

Now LLVM supports target-dependent attribute-value pair, I am wondering whether it is time to use that to represent kernel attributes.

e.g. something like (just to give an idea, not exact llvm IR)

kernel void foo(global int*a, sampler_t s); #1
#1 = {
reqd_work_group_size="1 1 1",
kernel_arg_type="int *, sampler_t",
...
}

basically we keep the info conveyed by the original metadata but attach them to the kernel function as attribute/value pair. This will make these attributes much easier to manipulate/change.

Any feedbacks? Thanks.

Sam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160511/6c1cc190/attachment.html>


More information about the cfe-dev mailing list