Skip to content

Commit 0389aac

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 373e77b commit 0389aac

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
@@ -1999,16 +1999,22 @@ void OmpAttributeVisitor::Post(const parser::Name &name) {
19991999
if (Symbol * found{currScope().FindSymbol(name.source)}) {
20002000
if (symbol != found) {
20012001
name.symbol = found; // adjust the symbol within region
2002-
} else if (GetContext().defaultDSA == Symbol::Flag::OmpNone &&
2003-
!symbol->test(Symbol::Flag::OmpThreadprivate) &&
2004-
// Exclude indices of sequential loops that are privatised in
2005-
// the scope of the parallel region, and not in this scope.
2006-
// TODO: check whether this should be caught in IsObjectWithDSA
2007-
!symbol->test(Symbol::Flag::OmpPrivate)) {
2008-
context_.Say(name.source,
2009-
"The DEFAULT(NONE) clause requires that '%s' must be listed in "
2010-
"a data-sharing attribute clause"_err_en_US,
2011-
symbol->name());
2002+
} else {
2003+
// If the symbol is a CrayPointee, no need to updates the symbol
2004+
// flags.
2005+
if (symbol->test(Symbol::Flag::CrayPointee)) {
2006+
return;
2007+
} else if (GetContext().defaultDSA == Symbol::Flag::OmpNone &&
2008+
!symbol->test(Symbol::Flag::OmpThreadprivate) &&
2009+
// Exclude indices of sequential loops that are privatised in
2010+
// the scope of the parallel region, and not in this scope.
2011+
// TODO: check whether this should be caught in IsObjectWithDSA
2012+
!symbol->test(Symbol::Flag::OmpPrivate)) {
2013+
context_.Say(name.source,
2014+
"The DEFAULT(NONE) clause requires that '%s' must be listed in "
2015+
"a data-sharing attribute clause"_err_en_US,
2016+
symbol->name());
2017+
}
20122018
}
20132019
}
20142020
}
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)