This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Extend omp teams to permit nested omp atomic
ClosedPublic

Authored by jdenny on May 24 2022, 1:35 PM.

Details

Summary

OpenMP 5.2, sec. 10.2 "teams Construct", p. 232, L9-12 restricts what
regions can be strictly nested within a teams construct. This patch
relaxes Clang's enforcement of this restriction in the case of nested
atomic constructs unless -fno-openmp-extensions is specified.
Cases like the following then seem to work fine with no additional
implementation changes:

#pragma omp target teams map(tofrom:x)
#pragma omp atomic update
x++;

Diff Detail

Event Timeline

jdenny created this revision.May 24 2022, 1:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2022, 1:35 PM
jdenny requested review of this revision.May 24 2022, 1:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2022, 1:35 PM
ABataev added inline comments.May 24 2022, 1:55 PM
clang/lib/Sema/SemaOpenMP.cpp
4983

Can you add a check for 5.2?

jdenny added inline comments.May 24 2022, 2:03 PM
clang/lib/Sema/SemaOpenMP.cpp
4983

This is an extension relative not only to 5.2 and but also to previous versions. I quoted 5.2 just because it's the most recent.

Given that, I'm not sure why this should check for 5.2. Am I misunderstanding your request?

ABataev added inline comments.May 24 2022, 2:14 PM
clang/lib/Sema/SemaOpenMP.cpp
4983

Just looks like it is allowed in 5.2. Am I missing something?

jdenny added inline comments.May 24 2022, 2:23 PM
clang/lib/Sema/SemaOpenMP.cpp
4983

I'm not aware of any change in the 5.2 spec that would permit this. The text I cited in the review summary does not include atomic in the list of regions "that may be strictly nested inside the teams region":

distribute regions, including any distribute regions arising from composite constructs,
parallel regions, including any parallel regions arising from combined constructs, loop
regions, omp_get_num_teams() regions, and omp_get_team_num() regions are the
only OpenMP regions that may be strictly nested inside the teams region.

ABataev accepted this revision.EditedMay 24 2022, 2:39 PM

LG

This revision is now accepted and ready to land.May 24 2022, 2:39 PM
jdenny updated this revision to Diff 431804.May 24 2022, 2:49 PM

Fixed a bug in the new tests.

jdenny marked 2 inline comments as done.May 24 2022, 2:50 PM

Thanks. Will try to push tomorrow.

This revision was landed with ongoing or failed builds.May 26 2022, 11:59 AM
This revision was automatically updated to reflect the committed changes.