File tree Expand file tree Collapse file tree 4 files changed +16
-7
lines changed Expand file tree Collapse file tree 4 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -94,8 +94,17 @@ void DataSharingProcessor::insertDeallocs() {
94
94
void DataSharingProcessor::cloneSymbol (const Fortran::semantics::Symbol *sym) {
95
95
// Privatization for symbols which are pre-determined (like loop index
96
96
// variables) happen separately, for everything else privatize here.
97
- if (sym->test (Fortran::semantics::Symbol::Flag::OmpPreDetermined))
97
+ auto isOMPParallelConstruct = [](Fortran::lower::pft::Evaluation &eval) {
98
+ if (const auto *ompConstruct = eval.getIf <parser::OpenMPConstruct>())
99
+ if (std::holds_alternative<parser::OpenMPBlockConstruct>(ompConstruct->u ))
100
+ return true ;
101
+ return false ;
102
+ };
103
+
104
+ if (sym->test (Fortran::semantics::Symbol::Flag::OmpPreDetermined) &&
105
+ !isOMPParallelConstruct (eval))
98
106
return ;
107
+
99
108
bool success = converter.createHostAssociateVarClone (*sym);
100
109
(void )success;
101
110
assert (success && " Privatization failed due to existing binding" );
@@ -344,7 +353,6 @@ void DataSharingProcessor::collectSymbols(
344
353
assert (curScope && " couldn't find current scope" );
345
354
if (isPrivatizable (*sym) && !symbolsInNestedRegions.contains (sym) &&
346
355
!privatizedSymbols.contains (sym) &&
347
- !sym->test (Fortran::semantics::Symbol::Flag::OmpPreDetermined) &&
348
356
(collectImplicit ||
349
357
!sym->test (Fortran::semantics::Symbol::Flag::OmpImplicit)) &&
350
358
clauseScopes.contains (&sym->owner ()))
Original file line number Diff line number Diff line change @@ -1674,6 +1674,7 @@ void OmpAttributeVisitor::ResolveSeqLoopIndexInParallelOrTaskConstruct(
1674
1674
// parallel or task
1675
1675
if (auto *symbol{ResolveOmp (iv, Symbol::Flag::OmpPrivate, targetIt->scope )}) {
1676
1676
targetIt++;
1677
+ symbol->set (Symbol::Flag::OmpPreDetermined);
1677
1678
iv.symbol = symbol; // adjust the symbol within region
1678
1679
for (auto it{dirContext_.rbegin ()}; it != targetIt; ++it) {
1679
1680
AddToContextObjectWithDSA (*symbol, Symbol::Flag::OmpPrivate, *it);
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ program omp_do
9
9
! DEF: /omp_do/n ObjectEntity INTEGER(4)
10
10
integer i,n
11
11
! $omp parallel
12
- ! DEF: /omp_do/OtherConstruct1/i (OmpPrivate) HostAssoc INTEGER(4)
12
+ ! DEF: /omp_do/OtherConstruct1/i (OmpPrivate, OmpPreDetermined ) HostAssoc INTEGER(4)
13
13
do i= 1 ,10
14
14
! $omp single
15
15
print * , " hello"
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ subroutine test_do
37
37
do j= 6 ,10
38
38
! REF: /test_do/a
39
39
a(1 ,1 ,1 ) = 0 .
40
- ! DEF: /test_do/OtherConstruct1/k (OmpPrivate) HostAssoc INTEGER(4)
40
+ ! DEF: /test_do/OtherConstruct1/k (OmpPrivate, OmpPreDetermined ) HostAssoc INTEGER(4)
41
41
do k= 11 ,15
42
42
! REF: /test_do/a
43
43
! REF: /test_do/OtherConstruct1/k
@@ -170,9 +170,9 @@ subroutine test_simd
170
170
! $omp parallel do simd
171
171
! DEF: /test_simd/OtherConstruct1/i (OmpLinear, OmpPreDetermined) HostAssoc INTEGER(4)
172
172
do i= 1 ,5
173
- ! DEF: /test_simd/OtherConstruct1/j (OmpPrivate) HostAssoc INTEGER(4)
173
+ ! DEF: /test_simd/OtherConstruct1/j (OmpPrivate, OmpPreDetermined ) HostAssoc INTEGER(4)
174
174
do j= 6 ,10
175
- ! DEF: /test_simd/OtherConstruct1/k (OmpPrivate) HostAssoc INTEGER(4)
175
+ ! DEF: /test_simd/OtherConstruct1/k (OmpPrivate, OmpPreDetermined ) HostAssoc INTEGER(4)
176
176
do k= 11 ,15
177
177
! REF: /test_simd/a
178
178
! REF: /test_simd/OtherConstruct1/k
@@ -228,7 +228,7 @@ subroutine test_seq_loop
228
228
print * , i, j
229
229
! $omp parallel
230
230
! REF: /test_seq_loop/i
231
- ! DEF: /test_seq_loop/OtherConstruct1/OtherConstruct1/j (OmpPrivate) HostAssoc INTEGER(4)
231
+ ! DEF: /test_seq_loop/OtherConstruct1/OtherConstruct1/j (OmpPrivate, OmpPreDetermined ) HostAssoc INTEGER(4)
232
232
print * , i, j
233
233
! $omp do
234
234
! DEF: /test_seq_loop/OtherConstruct1/OtherConstruct1/OtherConstruct1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
You can’t perform that action at this time.
0 commit comments