[all-commits] [llvm/llvm-project] debdfc: [Flang][OpenMP][MLIR] Filter emitted code dependin...

Sergio Afonso via All-commits all-commits at lists.llvm.org
Mon Jul 17 01:08:27 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: debdfc0ae21befa4124c227a916fc69913a4f146
      https://github.com/llvm/llvm-project/commit/debdfc0ae21befa4124c227a916fc69913a4f146
  Author: Sergio Afonso <safonsof at amd.com>
  Date:   2023-07-17 (Mon, 17 Jul 2023)

  Changed paths:
    M flang/include/flang/Optimizer/Transforms/Passes.h
    M flang/include/flang/Optimizer/Transforms/Passes.td
    M flang/lib/Frontend/FrontendActions.cpp
    M flang/lib/Optimizer/Transforms/CMakeLists.txt
    A flang/lib/Optimizer/Transforms/OMPFunctionFiltering.cpp
    A flang/test/Lower/OpenMP/function-filtering.f90
    M flang/test/Lower/OpenMP/omp-declare-target-func-and-subr.f90
    M flang/test/Lower/OpenMP/omp-declare-target-program-var.f90
    A flang/test/Transforms/omp-function-filtering.mlir
    M mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
    M mlir/test/Target/LLVMIR/omptarget-region-llvm-target-device.mlir
    M mlir/test/Target/LLVMIR/openmp-llvm.mlir

  Log Message:
  -----------
  [Flang][OpenMP][MLIR] Filter emitted code depending on declare target and device

This patch adds support for selecting which functions are lowered to LLVM IR
from MLIR depending on declare target information and whether host or device
code is being generated.

The approach proposed by this patch is to perform the filtering in two stages:
  - An MLIR transformation pass, which is added to the Flang translation flow
    after the `OMPEarlyOutliningPass`. The functions that are kept are those
    that match the OpenMP processor (host or device) the compiler invocation
    is targeting, according to the presence of the `-fopenmp-is-target-device`
    compiler option and declare target information. All functions contaning an
    `omp.target` are also kept, regardless of the declare target information of
    the function, due to the need for keeping target regions visible for both
    host and device compilation.
  - A filtering step during translation to LLVM IR, which is peformed for those
    functions that were kept because of the presence of a target region inside.
    If the targeted OpenMP processor does not match the declare target
    information of the function, then it is removed from the LLVM IR after its
    contents have been processed and translated. Since they should only contain
    an omp.target operation which, in turn, should have been outlined into
    another LLVM IR function, the wrapper can be deleted at that point.

Depends on D150328 and D150329.

Differential Revision: https://reviews.llvm.org/D147641




More information about the All-commits mailing list