================
@@ -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
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to