[PATCH] D92732: [Flang][OpenMP 4.5] Add semantic check for OpenMP Do Loop Constructs

Kiran Chandramohan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 2 14:37:41 PST 2021


kiranchandramohan added a comment.

I think you are doing three patches worth of work in a single one. Ideally, we could have had, One patch for the cycle restrictions, One patch for threadprivate, and One patch for the rest.



================
Comment at: flang/lib/Semantics/check-omp-structure.cpp:405
+      dir.source, llvm::omp::Directive::OMPD_threadprivate);
+  threadPrivateSymbols.clear();
+  const auto &list{std::get<parser::OmpObjectList>(x.t)};
----------------
yhegde wrote:
> kiranchandramohan wrote:
> > This clear will cause programs with multiple declarations to not work properly. See example below.
> > ```
> > program omp_do
> >   integer, save:: i, j, k
> >   !$omp threadprivate(i)
> >   !$omp threadprivate(j)
> >   !$omp do collapse(2)
> >   do k = 1, 10
> >     do i = 1, 10
> >       print *, "Hello"
> >     end do
> >   end do
> >   !$omp end do
> > end program omp_do
> > ```
> @kiranchandramohan . Thanks for pointing this out. Can I have the ThreadPrivate related check in resolve-directives.cpp or is it required to do in check-omp-structure.cpp as it is openmp specific. ? 
> 
> For the test case given (if implemented in resolve-directives.cpp)
> program omp_do
>   integer, save:: i, j, k
>   !$omp threadprivate(i)
>   !$omp threadprivate(j)
>   !$omp do collapse(2)
>   do k = 1, 10
>     do i = 1, 10
>       print *, "Hello"
>     end do
>   end do
>   !$omp end do
> end program omp_do
> 
> This is the error thrown 
> /tp.f90:10:8: error: Loop iteration variable i is not allowed in THREADPRIVATE.
>       do i = 1, 10
>          ^
> and for omp-do04.f90 
> 
> the errors are -
> ./omp-do04.f90:12:6: error: Loop iteration variable i is not allowed in THREADPRIVATE.
>     do i = 1, 10
>        ^
> ./omp-do04.f90:14:8: error: Loop iteration variable j is not allowed in THREADPRIVATE.
>       do j = 1, 10
>          ^
> ./omp-do04.f90:25:6: error: Loop iteration variable i is not allowed in THREADPRIVATE.
>     do i = 1, 10
>        ^
> ./omp-do04.f90:26:8: error: Loop iteration variable j is not allowed in THREADPRIVATE.
>       do j = 1, 10
>          ^
> 
> 
> 
Yes, you can add the check in resolve-directives.cpp. 

Why is there an error in line 26 of test omp-do04.f90? Since there is no collapse/ordered, should there be an error?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92732



More information about the llvm-commits mailing list