[llvm-branch-commits] [flang] [flang] Lower omp.workshare to other omp constructs (PR #101446)
Ivan R. Ivanov via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Aug 1 19:01:46 PDT 2024
================
@@ -792,7 +793,8 @@ struct ElementalOpConversion
// Generate a loop nest looping around the fir.elemental shape and clone
// fir.elemental region inside the inner loop.
hlfir::LoopNest loopNest =
- hlfir::genLoopNest(loc, builder, extents, !elemental.isOrdered());
+ hlfir::genLoopNest(loc, builder, extents, !elemental.isOrdered(),
+ flangomp::shouldUseWorkshareLowering(elemental));
----------------
ivanradanov wrote:
According to the standard:
> For array expressions within each statement, including transformational array intrinsic functions that compute scalar values from arrays:
> Evaluation of each element of the array expression, including any references to ELEMENTAL functions, is a unit of work.
> Evaluation of transformational array intrinsic functions may be freely subdivided into any number of units of work.
I was under the impression that ELEMENTAL functions must be PURE, however now I see that they can be marked IMPURE. The standard says to divide these into units of work, and
> It is unspecified how the units of work are assigned to the threads executing a workshare region.
So just from reading this it looks like we should lower those to wsloops and the user is responsible for any race conditions.
Or perhaps this part
> An implementation of the workshare construct must insert any synchronization that is required to maintain standard Fortran semantics.
Can be taken to mean that we need to schedule these properly.
Perhaps we can introduce a non-standard clause to the workdistribute to control this?
https://github.com/llvm/llvm-project/pull/101446
More information about the llvm-branch-commits
mailing list