Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Clang] Introduce scoped variants of GNU atomic functions #72280

Merged
merged 1 commit into from
Dec 7, 2023

Commits on Nov 30, 2023

  1. [Clang] Introduce scoped variants of GNU atomic functions

    Summary:
    The standard GNU atomic operations are a very common way to target
    hardware atomics on the device. With more hetergenous devices being
    introduced, the concept of memory scopes has been in the LLVM language
    for awhile via the `syncscope` modifier. For targets, such as the GPU,
    this can change code generation depending on whether or not we only need
    to be consistent with the memory ordering with the entire system, the
    single GPU device, or lower.
    
    Previously these scopes were only exported via the `opencl` and `hip`
    variants of these functions. However, this made it difficult to use
    outside of those languages and the semantics were different from the
    standard GNU versions. This patch introduces a `__scoped_atomic` variant
    for the common functions. There was some discussion over whether or not
    these should be overloads of the existing ones, or simply new variants.
    I leant towards new variants to be less disruptive.
    
    The scope here can be one of the following
    
    ```
    __MEMORY_SCOPE_SYSTEM // All devices and systems
    __MEMORY_SCOPE_DEVICE // Just this device
    __MEMORY_SCOPE_WRKGRP // A 'work-group' AKA CUDA block
    __MEMORY_SCOPE_WVFRNT // A 'wavefront' AKA CUDA warp
    __MEMORY_SCOPE_SINGLE // A single thread.
    ```
    Naming consistency was attempted, but it is difficult to cpature to full
    spectrum with no many names. Suggestions appreciated.
    jhuber6 committed Nov 30, 2023
    Configuration menu
    Copy the full SHA
    ce494cd View commit details
    Browse the repository at this point in the history