[PATCH] D93091: [Flang] [OpenMP] Add semantic checks for OpenMP Workshare Construct
Kiran Chandramohan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 13 01:11:16 PST 2021
kiranchandramohan requested changes to this revision.
kiranchandramohan added a comment.
This revision now requires changes to proceed.
Add a few tests to show that most restrictions do not apply inside a parallel construct nested inside a workshare construct.
================
Comment at: flang/lib/Semantics/check-omp-structure.cpp:867
+ } else {
+
+ // Check if OpenMP constructs enclosed in the Workshare Construct are
----------------
Nit: Remove empty line.
================
Comment at: flang/lib/Semantics/check-omp-structure.cpp:912-914
+ "The structured block in a WORKSHARE construct may consist of only "
+ "scalar or array assignments, forall or where statements, "
+ "forall, where, atomic, critical or parallel constructs"_err_en_US);
----------------
Nit: Capitalize constructs like elsewhere.
================
Comment at: flang/lib/Semantics/check-omp-structure.cpp:766
+ context_.Say(expr.source,
+ "User defined non-ELEMENTAL function "
+ "'%s' is not allowed in a WORKSHARE construct"_err_en_US,
----------------
praveen wrote:
> praveen wrote:
> > kiranchandramohan wrote:
> > > I think use of non-elemental function can be outside an assignment statement like in the where statement below.
> > > ```
> > > program mn
> > > integer :: a(10) = (/1,2,3,4,5,6,7,8,9,10/)
> > > !$omp workshare
> > > where ( a .lt. f()) a = a + 5
> > > !$omp end workshare
> > > contains
> > > integer function f()
> > > f = 5
> > > end function
> > > end program
> > > ```
> > Thanks @kiranchandramohan Will handle the same.
> @kiranchandramohan Modified the code to handle the same . Thanks!
There are probably more places (see example below) where user-defined are not allowed. I wonder whether a parse-tree walk would have been better for catching issues like these.
```
program mn
integer, parameter ::N = 100
real :: A(N,N), B(N,N)
!$omp workshare
FORALL(I = f():N, J = f():N, A(I, J) .NE. f()) B(I, J) = 1.0 / A(I, J)
!$omp end workshare
contains
pure integer function f()
f = 5
end function
end program
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93091/new/
https://reviews.llvm.org/D93091
More information about the llvm-commits
mailing list