[PATCH] D120396: [flang] Support export/import OpenMP Threadprivate Flag

Peixin Qiao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 24 03:30:14 PST 2022


peixin added inline comments.


================
Comment at: flang/lib/Semantics/mod-file.cpp:328
+                   if (symbol.test(Symbol::Flag::OmpThreadprivate) &&
+                       !FindCommonBlockContaining(symbol)) {
+                     decls_ << "!$omp threadprivate(" << symbol.name() << ")\n";
----------------
kiranchandramohan wrote:
> peixin wrote:
> > schweitz wrote:
> > > What are the expectations of having a variable that is both in a COMMON block and flagged as OMP thread private? (This suggests COMMON will have priority over thread private.)
> > > 
> > > I think you should have a test case below to check that combination of conditions and ensure against regressions, etc.
> > An element of common block cannot be in Threadprivate directive. The semantic check is in https://github.com/llvm/llvm-project/blob/3e3e79a9e4c378b59f5f393f556e6a84edcd8898/flang/lib/Semantics/check-omp-structure.cpp#L879-L883. The Threadprivate flag is resolved as every element has the flag (https://github.com/llvm/llvm-project/blob/3e3e79a9e4c378b59f5f393f556e6a84edcd8898/flang/lib/Semantics/resolve-directives.cpp#L1640-L1652). No addition information needs to be exported for common block in Threadprivate directive.
> > 
> > Added the test case for common block.
> Would it be better to always generate the declarative directives, irrespective of conditions and then use it conditionally?
Thanks for the notice. I was wrong before. Although an element of common block cannot be in Threadprivate directive, the usage of the element of a Threadprivate common block is as if it is allowed according to the OpenMP Spec 5.0 Section 2.19.4 [Data-sharing attribute clauses]. For example, a list item that appears in a copyin clause must be threadprivate. Named variables that appear in a threadprivate common block may be specified: it is not necessary to specify the whole common block. The specific case is like the following:
```
$ cat file2.f90
module private_data
	real :: x
	common /blk/ x
    !$OMP THREADPRIVATE(/blk/)
end module private_data
$ cat file1.f90
subroutine a
  use private_data
  !$omp parallel copyin(x)
  !$omp end parallel
end
$ flang-new -fc1 -fopenmp file2.f90 
$ flang-new -fc1 -fopenmp file1.f90
```


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

https://reviews.llvm.org/D120396



More information about the llvm-commits mailing list