Skip to content

Commit 127024c

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 a7b249e commit 127024c

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
@@ -2242,16 +2242,22 @@ void OmpAttributeVisitor::Post(const parser::Name &name) {
22422242
if (Symbol * found{currScope().FindSymbol(name.source)}) {
22432243
if (symbol != found) {
22442244
name.symbol = found; // adjust the symbol within region
2245-
} else if (GetContext().defaultDSA == Symbol::Flag::OmpNone &&
2246-
!symbol->test(Symbol::Flag::OmpThreadprivate) &&
2247-
// Exclude indices of sequential loops that are privatised in
2248-
// the scope of the parallel region, and not in this scope.
2249-
// TODO: check whether this should be caught in IsObjectWithDSA
2250-
!symbol->test(Symbol::Flag::OmpPrivate)) {
2251-
context_.Say(name.source,
2252-
"The DEFAULT(NONE) clause requires that '%s' must be listed in "
2253-
"a data-sharing attribute clause"_err_en_US,
2254-
symbol->name());
2245+
} else {
2246+
// If the symbol is a CrayPointee, no need to updates the symbol
2247+
// flags.
2248+
if (symbol->test(Symbol::Flag::CrayPointee)) {
2249+
return;
2250+
} else if (GetContext().defaultDSA == Symbol::Flag::OmpNone &&
2251+
!symbol->test(Symbol::Flag::OmpThreadprivate) &&
2252+
// Exclude indices of sequential loops that are privatised in
2253+
// the scope of the parallel region, and not in this scope.
2254+
// TODO: check whether this should be caught in IsObjectWithDSA
2255+
!symbol->test(Symbol::Flag::OmpPrivate)) {
2256+
context_.Say(name.source,
2257+
"The DEFAULT(NONE) clause requires that '%s' must be listed in "
2258+
"a data-sharing attribute clause"_err_en_US,
2259+
symbol->name());
2260+
}
22552261
}
22562262
}
22572263
}
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)