[cfe-dev] [RFC] Support synchronisation scope in Clang atomic builtin functions

John McCall via cfe-dev cfe-dev at lists.llvm.org
Tue Jan 17 11:45:01 PST 2017


> On Jan 17, 2017, at 1:54 PM, Anastasia Stulova via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> FYI, reference to the relevant part of the OpenCL spec: https://www.khronos.org/registry/OpenCL/specs/opencl-2.0-openclc.pdf#105 <https://www.khronos.org/registry/OpenCL/specs/opencl-2.0-openclc.pdf#105>
>  
> From the OpenCL side this proposal seems to make sense generally. I am not quite clear though what would happen with the scopes other than synch_scope_single_thread.
>  
> Do you need to extend the IR language to accommodate that too in addition to ‘singlethread’ flag you already use?

Thank you for linking the actual language specification.  It seems clear to me now that we just need to introduce new builtin functions specifically for OpenCL.  The OpenCL implementation in IRGen can then just handle different constants however it wishes.

John.

>  
> Cheers,
> Anastasia
>  
> From: Liu, Yaxun (Sam) [mailto:Yaxun.Liu at amd.com <mailto:Yaxun.Liu at amd.com>] 
> Sent: 17 January 2017 17:16
> To: cfe-dev (cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>)
> Cc: Sumner, Brian; Tye, Tony; Zhuravlyov, Konstantin; Anastasia Stulova; Bader, Alexey (alexey.bader at intel.com <mailto:alexey.bader at intel.com>)
> Subject: [RFC] Support synchronisation scope in Clang atomic builtin functions
>  
> OpenCL 2.0 atomic builtin functions have a scope argument which is ideally represented as synchronization scope argument in LLVM atomic instructions.
> 
> Clang supports translating Clang atomic builtin functions to LLVM atomic instructions. However it currently does not support synchronization scope of LLVM atomic instructions. Without this, users have to use LLVM assembly code to implement OpenCL atomic builtin functions.
> 
> I have a patch (https://reviews.llvm.org/D28691 <https://reviews.llvm.org/D28691> ) which allows Clang atomic builtin functions to accept an optional synchronization scope argument, so that they can be used to implement OpenCL atomic builtin functions.
> 
> This patch will not just benefits OpenCL. It will benefit any languages which need to generate atomic instructions with synchronization scopes. For languages not using synchronization scopes there is no functional change, since the synchronization scope argument is optional, and its default value generates the same LLVM instruction as before.
> 
> Your comments are welcome.
> 
> Thanks.
> 
> Sam
> 
>  
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170117/4a4543c5/attachment.html>


More information about the cfe-dev mailing list