[Mlir-commits] [mlir] [mlir][scf] Implement conversion from scf.forall to scf.parallel (PR #94109)

Spenser Bauman llvmlistbot at llvm.org
Mon Jun 3 09:06:51 PDT 2024


sabauma wrote:

> LGTM. By the way, I am curious what will nested `scf.parallel` be lowered to, in OpenMP target? Will it be nested parallelism in OMP?

@Menooker The SCF->OpenMP lowering does not try to do anything clever with nested `scf.parallel`. The lowering produces nested `omp.parallel`/`omp.wsloop` sequences.

```mlir
  scf.parallel (%i) = (%arg0) to (%arg2) step (%arg4) {
    scf.parallel (%j) = (%arg1) to (%arg3) step (%arg5) {
      "test.payload"(%i, %j) : (index, index) -> ()
    }
  }

  omp.parallel {
      omp.wsloop {
        omp.loop_nest (%arg6) : index = (%arg0) to (%arg2) step (%arg4) {
          memref.alloca_scope  {
            %1 = llvm.mlir.constant(1 : i64) : i64
            omp.parallel {
              omp.wsloop {
                omp.loop_nest (%arg7) : index = (%arg1) to (%arg3) step (%arg5) {
                  memref.alloca_scope  {
                    "test.payload"(%arg6, %arg7) : (index, index) -> ()
                  }
                  omp.yield
                }
                omp.terminator
              }
              omp.terminator
            }
          }
          omp.yield
        }
        omp.terminator
      }
      omp.terminator
   }
```

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


More information about the Mlir-commits mailing list