Skip to content

Commit e28529e

Browse files
committed
[Flang][OpenMP] : Compilation error involving Cray pointers and data-sharing attributes
Issue description: When DEFAULT DSA is NONE, all data refs must be listed in one of the data sharing clause. When a Cray pointer is listed in one of the data sharing clause, Cray pointee can be used in parallel region. This is valid as per standard. "Cray pointees have the same data-sharing attribute as the storage with which their Cray pointers are associated." Currently compiler crashes for default(none). Also current semantic checks incorrectly updates the symbol flags related to Craypointee symbols. due to this incorrect updation, compiler crashes when default(private) and default(firstprivate) is specified. Solution: Added an additional check to skip updation of symbol flags related to Craypointee symbols. This also prevents from checking cray pointee when DEFAULT DSA is NONE. This patch has code changes and a test case.
1 parent f672cc1 commit e28529e

File tree

2 files changed

+45
-10
lines changed

2 files changed

+45
-10
lines changed

flang/lib/Semantics/resolve-directives.cpp

+16-10
Original file line numberDiff line numberDiff line change
@@ -2220,16 +2220,22 @@ void OmpAttributeVisitor::Post(const parser::Name &name) {
22202220
if (Symbol * found{currScope().FindSymbol(name.source)}) {
22212221
if (symbol != found) {
22222222
name.symbol = found; // adjust the symbol within region
2223-
} else if (GetContext().defaultDSA == Symbol::Flag::OmpNone &&
2224-
!symbol->test(Symbol::Flag::OmpThreadprivate) &&
2225-
// Exclude indices of sequential loops that are privatised in
2226-
// the scope of the parallel region, and not in this scope.
2227-
// TODO: check whether this should be caught in IsObjectWithDSA
2228-
!symbol->test(Symbol::Flag::OmpPrivate)) {
2229-
context_.Say(name.source,
2230-
"The DEFAULT(NONE) clause requires that '%s' must be listed in "
2231-
"a data-sharing attribute clause"_err_en_US,
2232-
symbol->name());
2223+
} else {
2224+
// If the symbol is a CrayPointee, no need to updates the symbol
2225+
// flags.
2226+
if (symbol->test(Symbol::Flag::CrayPointee)) {
2227+
return;
2228+
} else if (GetContext().defaultDSA == Symbol::Flag::OmpNone &&
2229+
!symbol->test(Symbol::Flag::OmpThreadprivate) &&
2230+
// Exclude indices of sequential loops that are privatised in
2231+
// the scope of the parallel region, and not in this scope.
2232+
// TODO: check whether this should be caught in IsObjectWithDSA
2233+
!symbol->test(Symbol::Flag::OmpPrivate)) {
2234+
context_.Say(name.source,
2235+
"The DEFAULT(NONE) clause requires that '%s' must be listed in "
2236+
"a data-sharing attribute clause"_err_en_US,
2237+
symbol->name());
2238+
}
22332239
}
22342240
}
22352241
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
!RUN: %python %S/../test_errors.py %s %flang -fopenmp
2+
subroutine test_crayptr
3+
implicit none
4+
integer :: I
5+
real*8 var(*)
6+
pointer(ivar,var)
7+
real*8 pointee(8)
8+
9+
pointee(1) = 42.0
10+
ivar = loc(pointee)
11+
12+
!$omp parallel num_threads(2) default(none) shared(ivar)
13+
print *, var(1)
14+
!$omp end parallel
15+
16+
!$omp parallel num_threads(2) default(none) private(ivar)
17+
print *, var(1)
18+
!$omp end parallel
19+
20+
!$omp parallel num_threads(2) default(private) shared(ivar)
21+
print *, var(1)
22+
!$omp end parallel
23+
24+
!$omp parallel num_threads(2) default(firstprivate) shared(ivar)
25+
print *, var(1)
26+
!$omp end parallel
27+
28+
end subroutine test_crayptr
29+

0 commit comments

Comments
 (0)