[Mlir-commits] [flang] [llvm] [mlir] [OpenMPIRBuilder] Emit __atomic_load and __atomic_compare_exchange libcalls for complex types in atomic update (PR #92364)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu May 16 01:40:42 PDT 2024


NimishMishra wrote:

Hello all,

   For this particular patch, my main approach was to leverage AtomicExpandPass in order to automatically expand atomic load and atomic compare exchange into relevant libcalls (and as a result, refactor such code from Clang too). However, I was not able to get the pass run on desired function housing these instructions. Hence, I extracted out the necessary functionality and created this PR. Please do suggest if there is a way to improve upon this.

For now, this patch fixes the issue of complex types in atomic. For instance, given the following source:

```
program main
      complex*8 ia, ib
      ia = (2, 2)
      
      !$omp parallel num_threads(50)
      !$omp atomic update
        ia = ia + (1, 1)
      !$omp end atomic  
     !$omp end parallel
      print *, ia
end program main
```

The final value printed with `flang-new -fopenmp <test>.f90 -latomic` is `(52., 52.)`. 

https://github.com/llvm/llvm-project/pull/92364


More information about the Mlir-commits mailing list