Skip to content

Flang: Add support for Cray pointers in OpenMP constructs #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2242,16 +2242,22 @@ void OmpAttributeVisitor::Post(const parser::Name &name) {
if (Symbol * found{currScope().FindSymbol(name.source)}) {
if (symbol != found) {
name.symbol = found; // adjust the symbol within region
} else if (GetContext().defaultDSA == Symbol::Flag::OmpNone &&
!symbol->test(Symbol::Flag::OmpThreadprivate) &&
// Exclude indices of sequential loops that are privatised in
// the scope of the parallel region, and not in this scope.
// TODO: check whether this should be caught in IsObjectWithDSA
!symbol->test(Symbol::Flag::OmpPrivate)) {
context_.Say(name.source,
"The DEFAULT(NONE) clause requires that '%s' must be listed in "
"a data-sharing attribute clause"_err_en_US,
symbol->name());
} else {
// If the symbol is a CrayPointee, no need to updates the symbol
// flags.
if (symbol->test(Symbol::Flag::CrayPointee)) {
return;
} else if (GetContext().defaultDSA == Symbol::Flag::OmpNone &&
!symbol->test(Symbol::Flag::OmpThreadprivate) &&
// Exclude indices of sequential loops that are privatised in
// the scope of the parallel region, and not in this scope.
// TODO: check whether this should be caught in IsObjectWithDSA
!symbol->test(Symbol::Flag::OmpPrivate)) {
context_.Say(name.source,
"The DEFAULT(NONE) clause requires that '%s' must be listed in "
"a data-sharing attribute clause"_err_en_US,
symbol->name());
}
}
}
}
Expand Down
29 changes: 29 additions & 0 deletions flang/test/Semantics/OpenMP/cray-pointer-usage.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
!RUN: %python %S/../test_errors.py %s %flang -fopenmp
subroutine test_crayptr
implicit none
integer :: I
real*8 var(*)
pointer(ivar,var)
real*8 pointee(8)

pointee(1) = 42.0
ivar = loc(pointee)

!$omp parallel num_threads(2) default(none) shared(ivar)
print *, var(1)
!$omp end parallel

!$omp parallel num_threads(2) default(none) private(ivar)
print *, var(1)
!$omp end parallel

!$omp parallel num_threads(2) default(private) shared(ivar)
print *, var(1)
!$omp end parallel

!$omp parallel num_threads(2) default(firstprivate) shared(ivar)
print *, var(1)
!$omp end parallel

end subroutine test_crayptr