[PATCH] D93091: [Flang] [OpenMP] Add semantic checks for OpenMP Workshare Construct

Praveen G via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 14 11:36:36 PST 2021


praveen marked an inline comment as done.
praveen added a comment.

@kiranchandramohan To make use of parse-tree walk to check all the assignments and expressions in OpenMP Workshare constructs ,  is it preferred to add a class in **check-omp-structure.cpp** specific for workshare or add a generic class in **Semantics/tools.cpp** to collect all the assignments and expressions and then iterate over all the assignments / expressions identified in the walk?



================
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,
----------------
kiranchandramohan wrote:
> 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
> ```
@kiranchandramohan Thanks for pointing this out . I had missed this check in forall statements and construct. 

I do feel parse-tree walk would be better to catch all the assignments and Expressions instead of multiple functions for each statement / construct.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93091/new/

https://reviews.llvm.org/D93091



More information about the llvm-commits mailing list