[cfe-dev] [OpenCL] RFC: let Clang generate llvm atomic instructions for OpenCL atomic builtin functions
Liu, Yaxun (Sam) via cfe-dev
cfe-dev at lists.llvm.org
Fri Mar 4 10:04:05 PST 2016
Hi Alexey,
To clarify, when I said OpenCL atomic builtin functions, the 'builtin' was in the sense of OpenCL spec. In Clang they are just treated as ordinary functions.
Let's take an example of OpenCL atomic builtin function:
uint y;
volatile __global atomic_uint *x;
atomic_store(x, y);
Currently we clang generates a function call
call spir_func void @_Z12atomic_storePVU3AS1U7_Atomicjj(i32 addrspace(1)* %x, i32 %y)
However, it can simply be represented as an LLVM instruction
store atomic volatile i32 %y, i32 addrspace(1)* %x seq_cst, align 4
So I am wondering why not let Clang just generating the instruction directly, since Clang already did the same thing for some libm functions.
Sam
From: Bader, Alexey [mailto:alexey.bader at intel.com]
Sent: Friday, March 4, 2016 11:22 AM
To: Liu, Yaxun (Sam) <Yaxun.Liu at amd.com>; 'anastasia.stulova at arm.com' <anastasia.stulova at arm.com>; Pan, Xiuli <xiuli.pan at intel.com>; cfe-dev at lists.llvm.org
Cc: Sumner, Brian <Brian.Sumner at amd.com>
Subject: RE: [OpenCL] RFC: let Clang generate llvm atomic instructions for OpenCL atomic builtin functions
Hi Sam,
Could you clarify your idea?
At the moment clang doesn't provide any OpenCL built-in functions - they are provided by OpenCL implementation.
Clang provides C11 atomic built-ins<http://clang.llvm.org/docs/LanguageExtensions.html#c11-atomic-builtins> which should produce desired llvm atomic instructions.
This should work for OpenCL v2.0 atomics since they are taken from C11.
Thanks,
Alexey
From: Liu, Yaxun (Sam) [mailto:Yaxun.Liu at amd.com]
Sent: Thursday, March 3, 2016 11:37 PM
To: Bader, Alexey; 'anastasia.stulova at arm.com'; Pan, Xiuli; cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
Cc: Sumner, Brian
Subject: RE: [OpenCL] RFC: let Clang generate llvm atomic instructions for OpenCL atomic builtin functions
Hi,
OpenCL atomic builtin functions are similar to llvm atomic instructions. It seems natural to represent OpenCL atomic builtin functions by LLVM atomic instructions.
Doing this can simplify implementation of OpenCL builtin library and have a unified representation for OpenCL atomic builtin functions.
Any feedback? 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160304/86550ede/attachment.html>
More information about the cfe-dev
mailing list