[cfe-dev] [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*
Liu, Yaxun (Sam) via cfe-dev
cfe-dev at lists.llvm.org
Thu Jul 28 12:11:52 PDT 2016
Just guessing. If they have code relying on the opencl type names.
I do not have strong opinion on this.
Sam
From: Anastasia Stulova [mailto:Anastasia.Stulova at arm.com]
Sent: Thursday, July 28, 2016 1:10 PM
To: Liu, Yaxun (Sam) <Yaxun.Liu at amd.com>; Bader, Alexey <alexey.bader at intel.com>; cfe-dev (cfe-dev at lists.llvm.org) <cfe-dev at lists.llvm.org>
Cc: Sumner, Brian <Brian.Sumner at amd.com>; Pan, Xiuli <xiuli.pan at intel.com>; nd <nd at arm.com>
Subject: RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*
How will it break the debugger?
I don't think having two different naming schemes for the same thing helps anyone.
Anastasia
From: Liu, Yaxun (Sam) [mailto:Yaxun.Liu at amd.com]
Sent: 28 July 2016 16:51
To: Anastasia Stulova; Bader, Alexey; cfe-dev (cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>)
Cc: Sumner, Brian; Pan, Xiuli; nd
Subject: RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*
The debug information is for user to view the type of a variable when executing the program, and the LLVM type name is only used during compilation. Do they really need to be the same? Also changing debug info may break debugger.
Sam
From: Anastasia Stulova [mailto:Anastasia.Stulova at arm.com]
Sent: Thursday, July 28, 2016 11:43 AM
To: Liu, Yaxun (Sam) <Yaxun.Liu at amd.com<mailto:Yaxun.Liu at amd.com>>; Bader, Alexey <alexey.bader at intel.com<mailto:alexey.bader at intel.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>>
Cc: Sumner, Brian <Brian.Sumner at amd.com<mailto:Brian.Sumner at amd.com>>; Pan, Xiuli <xiuli.pan at intel.com<mailto:xiuli.pan at intel.com>>; nd <nd at arm.com<mailto:nd at arm.com>>
Subject: RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*
Exactly, I think we should make it consistent.
From: Liu, Yaxun (Sam) [mailto:Yaxun.Liu at amd.com]
Sent: 28 July 2016 16:28
To: Anastasia Stulova; Bader, Alexey; cfe-dev (cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>)
Cc: Sumner, Brian; Pan, Xiuli; nd
Subject: RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*
You mean changing the name of OpenCL types in debug info from 'opencl_*' to 'opencl.*' to match the names used in LLVM IR?
Sam
From: Anastasia Stulova [mailto:Anastasia.Stulova at arm.com]
Sent: Thursday, July 28, 2016 11:21 AM
To: Liu, Yaxun (Sam) <Yaxun.Liu at amd.com<mailto:Yaxun.Liu at amd.com>>; Bader, Alexey <alexey.bader at intel.com<mailto:alexey.bader at intel.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>>
Cc: Sumner, Brian <Brian.Sumner at amd.com<mailto:Brian.Sumner at amd.com>>; Pan, Xiuli <xiuli.pan at intel.com<mailto:xiuli.pan at intel.com>>; nd <nd at arm.com<mailto:nd at arm.com>>
Subject: RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*
I noticed we use different naming scheme for OpenCL types while generating debug info in CGDebugInfo.cpp, which is "opencl_*". I think we should make this consistent across CodeGen components.
Cheers,
Anastasia
From: Liu, Yaxun (Sam) [mailto:Yaxun.Liu at amd.com]
Sent: 28 July 2016 14:57
To: Anastasia Stulova; Bader, Alexey; cfe-dev (cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>)
Cc: Sumner, Brian; Pan, Xiuli; nd
Subject: RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*
I did not realize that __builtin_astype can be used for this. Thanks Alexey.
For now I will drop this RFC unless I encounter further issues with this approach.
Thanks.
Sam
From: Anastasia Stulova [mailto:Anastasia.Stulova at arm.com]
Sent: Thursday, July 28, 2016 9:53 AM
To: Bader, Alexey <alexey.bader at intel.com<mailto:alexey.bader at intel.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>>
Cc: Sumner, Brian <Brian.Sumner at amd.com<mailto:Brian.Sumner at amd.com>>; Pan, Xiuli <xiuli.pan at intel.com<mailto:xiuli.pan at intel.com>>; nd <nd at arm.com<mailto:nd at arm.com>>
Subject: RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*
Yes, I think casting is the most reasonable solution. Sam could you explain what issue do you have with it? I am guessing bitcast shouldn't affect performance of the compiled code as it's mainly a semantic node which is optimised out.
Anastasia
From: Bader, Alexey [mailto:alexey.bader at intel.com]
Sent: 28 July 2016 12:15
To: Anastasia Stulova; Liu, Yaxun (Sam); cfe-dev (cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>)
Cc: Sumner, Brian; Pan, Xiuli; nd
Subject: RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*
Hi Sam,
You can cast OpenCL image types to pointer type using __builtin_astype function.
void f(read_only image2d_t s) {
void *q = __builtin_astype(s, void*);
void *p = __builtin_astype(s, char*);
}
I think this approach will work for sampler type too.
Thanks,
Alexey
From: Anastasia Stulova [mailto:Anastasia.Stulova at arm.com]
Sent: Thursday, July 28, 2016 12:59 PM
To: Liu, Yaxun (Sam) <Yaxun.Liu at amd.com<mailto:Yaxun.Liu at amd.com>>; Bader, Alexey <alexey.bader at intel.com<mailto:alexey.bader at intel.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>>
Cc: Sumner, Brian <Brian.Sumner at amd.com<mailto:Brian.Sumner at amd.com>>; Pan, Xiuli <xiuli.pan at intel.com<mailto:xiuli.pan at intel.com>>; nd <nd at arm.com<mailto:nd at arm.com>>
Subject: RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*
Hi Sam,
>From the practical perspective I don't disagree with your approach. Logically, however, OpenCL types aren't intended to be struct or any existing LLVM type. The implementation of backend doesn't work on OpenCL source level, and therefore can take different approach than the implementation that you are proposing here. One way is for example to transform those types to something that hardware architecture supports natively.
Cheers,
Anastasia
From: Liu, Yaxun (Sam) [mailto:Yaxun.Liu at amd.com]
Sent: 27 July 2016 20:46
To: Anastasia Stulova; Bader, Alexey; cfe-dev (cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>)
Cc: Sumner, Brian; Pan, Xiuli; nd
Subject: RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*
Clang does not allow casting OpenCL opaque types to any other types. For example,
$ cat test3.cl
void f(sampler_t s) {
void *q = (void*) s;
char *p = (char*) s;
}
$ bin/clang -cc1 test3.cl
test3.cl:2:21: error: operand of type 'sampler_t' where arithmetic or pointer type is required
void *q = (void*) s;
^
test3.cl:3:21: error: operand of type 'sampler_t' where arithmetic or pointer type is required
char *p = (char*) s;
^
2 errors generated.
That makes sense since allowing OpenCL opaque types to be casted to other types potentially can cause lots of issues and needs more checks.
Then I don't know how representing OpenCL opaque type as a non-struct type would work.
On the other hand, any type can be easily packaged in a struct type. What we need is a struct name that can be used by a common OpenCL source code.
Sam
From: Anastasia Stulova [mailto:Anastasia.Stulova at arm.com]
Sent: Wednesday, July 27, 2016 2:39 PM
To: Liu, Yaxun (Sam) <Yaxun.Liu at amd.com<mailto:Yaxun.Liu at amd.com>>; Bader, Alexey <alexey.bader at intel.com<mailto:alexey.bader at intel.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>>
Cc: Sumner, Brian <Brian.Sumner at amd.com<mailto:Brian.Sumner at amd.com>>; Pan, Xiuli <xiuli.pan at intel.com<mailto:xiuli.pan at intel.com>>; nd <nd at arm.com<mailto:nd at arm.com>>
Subject: RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*
Right, what I mean is that OpenCL types are now generated by Clang as unknown opaque types identified by their name in LLVM. Unfortunately LLVM is missing proper type support for OpenCL, therefore we have this issue. But adding "struct." prefix might imply that this has to be a struct. Clang uses "struct." prefix as a naming convention for generated C struct types in LLVM.
Implementation should however have freedom to use OpenCL opaque types differently to struct (we don't force it to be anything). I don't think adding a struct prefix to the OpenCL opaque type names in LLVM is a good idea as it adds some confusion about their representation.
Cheers,
Anastasia
From: Liu, Yaxun (Sam) [mailto:Yaxun.Liu at amd.com]
Sent: 27 July 2016 18:58
To: Anastasia Stulova; Bader, Alexey; cfe-dev (cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>)
Cc: Sumner, Brian; Pan, Xiuli; nd
Subject: RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*
In LLVM, the OpenCL opaque types are already represented as an opaque struct type since only struct types can have name. This proposal does not change that, it only changes the name of the struct type to be accessible in the OpenCL source code.
Besides, Clang does not allow OpenCL opaque types such as sampler and image types to be explicitly casted to other types.
Sam
From: Anastasia Stulova [mailto:Anastasia.Stulova at arm.com]
Sent: Wednesday, July 27, 2016 1:08 PM
To: Liu, Yaxun (Sam) <Yaxun.Liu at amd.com<mailto:Yaxun.Liu at amd.com>>; Bader, Alexey <alexey.bader at intel.com<mailto:alexey.bader at intel.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>>
Cc: Sumner, Brian <Brian.Sumner at amd.com<mailto:Brian.Sumner at amd.com>>; Pan, Xiuli <xiuli.pan at intel.com<mailto:xiuli.pan at intel.com>>; nd <nd at arm.com<mailto:nd at arm.com>>
Subject: RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*
In this case I am not sure it's generic enough to assume that those types are always mapped to some struct.
Perhaps, we should stay with the conversion?
Anastasia
From: Liu, Yaxun (Sam) [mailto:Yaxun.Liu at amd.com]
Sent: 27 July 2016 16:29
To: Bader, Alexey; Anastasia Stulova; cfe-dev (cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>)
Cc: Sumner, Brian; Pan, Xiuli; nd
Subject: RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*
You are right. It should be struct.__opencl_ prefix.
Sam
From: Bader, Alexey [mailto:alexey.bader at intel.com]
Sent: Wednesday, July 27, 2016 10:56 AM
To: Anastasia Stulova <Anastasia.Stulova at arm.com<mailto:Anastasia.Stulova at arm.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>>
Cc: Sumner, Brian <Brian.Sumner at amd.com<mailto:Brian.Sumner at amd.com>>; Pan, Xiuli <xiuli.pan at intel.com<mailto:xiuli.pan at intel.com>>; nd <nd at arm.com<mailto:nd at arm.com>>
Subject: RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*
Hi Sam,
I want to clarify the use case.
The intension is to allow library developer redefining OpenCL images types in a library written in OpenCL C and prefix starting with double underscore is supposed to protect the library image types definitions from redefinition by user.
The change you are proposing is to rename image opaque types in LLVM IR, without making them concrete.
Am I getting it right?
Wouldn't types defined by library developer prefixed with 'struct.'? Shouldn't clang create opaque types with 'struct.__opencl_' prefix instead to match the type names defined by library developer?
Thanks,
Alexey
From: Anastasia Stulova [mailto:Anastasia.Stulova at arm.com]
Sent: Monday, July 25, 2016 6:41 PM
To: 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>>
Cc: Sumner, Brian <Brian.Sumner at amd.com<mailto:Brian.Sumner at amd.com>>; Bader, Alexey <alexey.bader at intel.com<mailto:alexey.bader at intel.com>>; Pan, Xiuli <xiuli.pan at intel.com<mailto:xiuli.pan at intel.com>>; nd <nd at arm.com<mailto:nd at arm.com>>
Subject: RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*
Sounds good to me!
Thanks,
Anastasia
From: Liu, Yaxun (Sam) [mailto:Yaxun.Liu at amd.com]
Sent: 20 July 2016 18:49
To: cfe-dev (cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>)
Cc: Anastasia Stulova; Sumner, Brian; Bader, Alexey (alexey.bader at intel.com<mailto:alexey.bader at intel.com>); Pan, Xiuli
Subject: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*
Currently OpenCL opaque types have name opencl.* in LLVM IR, which causes difficulty for library developers who need to implement the concrete types corresponding to the opaque types.
For example, read_only image2d_t type is translated to opencl.image2d_ro_t addrspace(1)* in LLVM IR. Ideally, a library developer would implement a concreate struct type with name opencl.image2d_ro_t and access its members. However, due to the '.', 'opencl.image2d_ro_t' is not a valid identifier in OpenCL C language, library developers cannot use it as the name of the concrete struct type for image2d_t. Bitcasts have to be introduced, which causes extra efforts in backends.
Due to this reason, we would like to propose renaming OpenCL opaque types in LLVM IR from opencl.* to __opencl_*.
This change will make the IR deviate from SPIR spec. However, considering there is simple rule to map this new name to SPIR defined name, and LLVM IR currently generated by Clang has already been deviated from SPIR spec, a SPIR consumer should be able to accommodate this change if it is able to accommodate existing deviations.
Your feedbacks are welcome. Thanks.
Sam
--------------------------------------------------------------------
Joint Stock Company Intel A/O
Registered legal address: Krylatsky Hills Business Park,
17 Krylatskaya Str., Bldg 4, Moscow 121614,
Russian Federation
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
--------------------------------------------------------------------
Joint Stock Company Intel A/O
Registered legal address: Krylatsky Hills Business Park,
17 Krylatskaya Str., Bldg 4, Moscow 121614,
Russian Federation
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160728/611ec27a/attachment.html>
More information about the cfe-dev
mailing list