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

Yashaswini Hegde via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 3 10:46:45 PST 2021


yhegde added inline comments.


================
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)};
----------------
kiranchandramohan wrote:
> 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?
Thank you @kiranchandramohan .  I have updated the code and the test cases with  ordered and collapsed clauses together. And the error for omp-do04.f90 is -

./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:27:6: error: Loop iteration variable i is not allowed in THREADPRIVATE.
    do i = 1, 10
       ^
Now the thread private related code is moved to resolve-directives.cpp 


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