1. Mar 19, 2024
  2. Mar 18, 2024
  3. Mar 13, 2024
    • Tom Eccles's avatar
      [flang][OpenMP] lower simple array reductions · bd668cd9
      Tom Eccles authored
      This has been tested with arrays with compile-time constant bounds.
      Allocatable arrays and arrays with non-constant bounds are not yet
      supported. User-defined reduction functions are also not yet supported.
      
      The design is intended to work for arrays with non-constant bounds too
      without a lot of extra work (mostly there are bugs in OpenMPIRBuilder I
      haven't fixed yet).
      
      We need some way to get these runtime bounds into the reduction init and
      combiner regions. To keep things simple for now I opted to always box the
      array arguments so the box can be passed as one argument and the lower
      bounds and extents read from the box. This has the disadvantage of
      resulting in fir.box_dim operations inside of the critical section. If
      these prove to be a performance issue, we could follow OpenACC reading
      box lower bounds and extents before the reduction and passing them as
      block arguments to the reduction init and combiner regions. I would
      prefer to keep things simple for now.
      
      Note: this implementation only works when the HLFIR lowering is used. I
      don't think it is worth supporting FIR-only lowering because the plan is
      for that to be removed soon.
      bd668cd9
    • Tom Eccles's avatar
      [flang][NFC] move extractSequenceType helper out of OpenACC to share code · 2ff12fa0
      Tom Eccles authored
      Moving extractSequenceType to FIRType.h so that this can also be used
      from OpenMP.
      2ff12fa0
    • Tom Eccles's avatar
      [mlir][LLVM] erase call mappings in forgetMapping() · c62b3126
      Tom Eccles authored
      It looks like the mappings for call instructions were forgotten here.
      This fixes a bug in OpenMP when inlining a region containing call
      operations multiple times.
      c62b3126
    • Tom Eccles's avatar
      [flang][CodeGen] Run PreCGRewrite on omp reduction declare ops · f951d16c
      Tom Eccles authored
      OpenMP reduction declare operations can contain FIR code which needs to
      be lowered to LLVM. With array reductions, these regions can contain
      more complicated operations which need PreCGRewriting. A similar extra
      case was already needed for fir::GlobalOp.
      f951d16c
    • Tom Eccles's avatar
      [flang] run CFG conversion on omp reduction declare ops · 192da3c0
      Tom Eccles authored
      
      
      Most FIR passes only look for FIR operations inside of functions (either
      because they run only on func.func or they run on the module but iterate
      over functions internally). But there can also be FIR operations inside
      of fir.global, some OpenMP and OpenACC container operations.
      
      This has worked so far for fir.global and OpenMP reductions because they
      only contained very simple FIR code which doesn't need most passes to be
      lowered into LLVM IR. I am not sure how OpenACC works.
      
      In the long run, I hope to see a more systematic approach to making sure
      that every pass runs on all of these container operations. I will write
      an RFC for this soon.
      
      In the meantime, this pass duplicates the CFG conversion pass to also
      run on omp reduction operations. This is similar to how the
      AbstractResult pass is already duplicated for fir.global operations.
      
      Co-authored-by: default avatarMats Petersson <mats.petersson@arm.com>
      192da3c0
    • Tom Eccles's avatar
      [flang] support fir.alloca operations inside of omp reduction ops · 63c7fe3c
      Tom Eccles authored
      Advise to place the alloca at the start of the first block of whichever
      region (init or combiner) we are currently inside.
      
      It probably isn't safe to put an alloca inside of a combiner region
      because this will be executed multiple times. But that would be a bug to
      fix in Lower/OpenMP.cpp, not here.
      63c7fe3c
    • Tom Eccles's avatar
      Add TODO message · 85df0051
      Tom Eccles authored
      85df0051
    • Tom Eccles's avatar
      Fix regression on min reduction · 3114a123
      Tom Eccles authored
      This makes sure that the generated IR doesn't change as a result of this
      PR. The generated IR looks wrong to me (no reduction is generated at
      all), but that is a matter for another patch.
      3114a123
  4. Mar 07, 2024