[all-commits] [llvm/llvm-project] 621fcf: [mlir][OpenMP] rewrite conversion of privatisation...

Tom Eccles via All-commits all-commits at lists.llvm.org
Wed Oct 16 06:44:20 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 621fcf892bcd3c2d81e25c6ee39ca32db3c6b05a
      https://github.com/llvm/llvm-project/commit/621fcf892bcd3c2d81e25c6ee39ca32db3c6b05a
  Author: Tom Eccles <tom.eccles at arm.com>
  Date:   2024-10-16 (Wed, 16 Oct 2024)

  Changed paths:
    A flang/test/Integration/OpenMP/parallel-private-reduction-worstcase.f90
    A flang/test/Integration/OpenMP/private-global.f90
    M mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
    M mlir/test/Target/LLVMIR/openmp-firstprivate.mlir
    M mlir/test/Target/LLVMIR/openmp-private.mlir

  Log Message:
  -----------
  [mlir][OpenMP] rewrite conversion of privatisation for omp.parallel (#111844)

The existing conversion inlined private alloc regions and firstprivate
copy regions in mlir, then undoing the modification of the mlir module
before completing the conversion. To make this work, LLVM IR had to be
generated using the wrong mapping for privatised values and then later
fixed inside of OpenMPIRBuilder.

This approach violated an assumption in OpenMPIRBuilder that private
variables would be values not constants. Flang sometimes generates code
where private variables are promoted to globals, the address of which is
treated as a constant in LLVM IR. This caused the incorrect values for
the private variable from being replaced by OpenMPIRBuilder: ultimately
resulting in programs producing incorrect results.

This patch rewrites delayed privatisation for omp.parallel to work more
similarly to reductions: translating directly into LLVMIR with correct
mappings for private variables.

RFC:
https://discourse.llvm.org/t/rfc-openmp-fix-issue-in-mlir-to-llvmir-translation-for-delayed-privatisation/81225

Tested against the gfortran testsuite and our internal test suite.
Linaro's post-commit bots will check against the fujitsu test suite.

I decided to add the new tests as flang integration tests rather than in
mlir/test/Target/LLVMIR:
- The regression test is for an issue filed against flang. i wanted to
keep the reproducer similar to the code in the ticket.
- I found the "worst case" CFG test difficult to reason about in
abstract it helped me to think about what was going on in terms of a
Fortran program.

Fixes #106297



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