[all-commits] [llvm/llvm-project] 049035: [flang][hlfir] Add MLIR op for `do concurrent`

Kareem Ergawy via All-commits all-commits at lists.llvm.org
Tue Mar 11 21:54:22 PDT 2025


  Branch: refs/heads/users/ergawy/hlfir_do_concurrent_op_1_mlir_op
  Home:   https://github.com/llvm/llvm-project
  Commit: 04903579ace09ae7785576d6cad69c3b57125563
      https://github.com/llvm/llvm-project/commit/04903579ace09ae7785576d6cad69c3b57125563
  Author: ergawy <kareem.ergawy at amd.com>
  Date:   2025-03-11 (Tue, 11 Mar 2025)

  Changed paths:
    M flang/include/flang/Optimizer/HLFIR/HLFIROps.td
    M flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
    A flang/test/HLFIR/do_concurrent.fir
    M flang/test/HLFIR/invalid.fir

  Log Message:
  -----------
  [flang][hlfir] Add MLIR op for `do concurrent`

Adds new MLIR ops to model `do concurrent`. In order to make `do
concurrent` representation self-contained, a loop is modeled using 2
ops, one wrapper and one that contains the actual body of the loop. For
example, a 2D `do concurrent` loop is modeled as follows:

```mlir
  hlfir.do_concurrent {
    %i = fir.alloca i32
    %j = fir.alloca i32
    hlfir.do_concurrent.loop
      (%i_iv, %j_iv) = (%i_lb, %j_lb) to (%i_ub, %j_ub) step (%i_st, %j_st) {
      %0 = fir.convert %i_iv : (index) -> i32
      fir.store %0 to %i : !fir.ref<i32>

      %1 = fir.convert %j_iv : (index) -> i32
      fir.store %1 to %j : !fir.ref<i32>
    }
  }
```

The `hlfir.do_concurrent` wrapper op encapsulates both the actual loop
and the allocations required for the iteration variables. The
`hlfir.do_concurrent.loop` op is a multi-dimensional op that contains
the loop control and body. See the ops' docs for more info.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list