-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[OpenMP] Patch for Support to loop bind clause : Checking Parent Region #76938
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1dcd470
Changes uploaded to the phabricator on Dec 16th are lost because the
1881663
Removing extra paranthesis.
9e43e28
Merge branch 'main' into parent_loop_bind
835bca8
In case of unspecified bind in "#pragma omp loop" and parent being "t…
43d846a
Merge branch 'main' into parent_loop_bind
04d1f35
Merge branch 'main' into parent_loop_bind
8f9c1e3
Correcting the brackets related to teams in SemaOpenMP.
c620420
Merge branch 'main' into parent_loop_bind
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5072,6 +5072,18 @@ static bool checkNestingOfRegions(Sema &SemaRef, const DSAStackTy *Stack, | |
CurrentRegion != OMPD_cancellation_point && | ||
CurrentRegion != OMPD_cancel && CurrentRegion != OMPD_scan) | ||
return false; | ||
// Checks needed for mapping "loop" construct. Please check mapLoopConstruct | ||
// for a detailed explanation | ||
if (SemaRef.LangOpts.OpenMP >= 50 && CurrentRegion == OMPD_loop && | ||
(BindKind == OMPC_BIND_parallel || BindKind == OMPC_BIND_teams) && | ||
(isOpenMPWorksharingDirective(ParentRegion) || | ||
ParentRegion == OMPD_loop)) { | ||
int ErrorMsgNumber = (BindKind == OMPC_BIND_parallel) ? 1 : 4; | ||
SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region) | ||
<< true << getOpenMPDirectiveName(ParentRegion) << ErrorMsgNumber | ||
<< getOpenMPDirectiveName(CurrentRegion); | ||
return true; | ||
} | ||
if (CurrentRegion == OMPD_cancellation_point || | ||
CurrentRegion == OMPD_cancel) { | ||
// OpenMP [2.16, Nesting of Regions] | ||
|
@@ -6124,35 +6136,39 @@ processImplicitMapsWithDefaultMappers(Sema &S, DSAStackTy *Stack, | |
|
||
bool Sema::mapLoopConstruct(llvm::SmallVector<OMPClause *> &ClausesWithoutBind, | ||
ArrayRef<OMPClause *> Clauses, | ||
OpenMPBindClauseKind BindKind, | ||
OpenMPBindClauseKind &BindKind, | ||
OpenMPDirectiveKind &Kind, | ||
OpenMPDirectiveKind &PrevMappedDirective) { | ||
OpenMPDirectiveKind &PrevMappedDirective, | ||
SourceLocation StartLoc, SourceLocation EndLoc, | ||
const DeclarationNameInfo &DirName, | ||
OpenMPDirectiveKind CancelRegion) { | ||
|
||
bool UseClausesWithoutBind = false; | ||
|
||
// Restricting to "#pragma omp loop bind" | ||
if (getLangOpts().OpenMP >= 50 && Kind == OMPD_loop) { | ||
|
||
const OpenMPDirectiveKind ParentDirective = DSAStack->getParentDirective(); | ||
|
||
if (BindKind == OMPC_BIND_unknown) { | ||
// Setting the enclosing teams or parallel construct for the loop | ||
// directive without bind clause. | ||
BindKind = OMPC_BIND_thread; // Default bind(thread) if binding is unknown | ||
|
||
const OpenMPDirectiveKind ParentDirective = | ||
DSAStack->getParentDirective(); | ||
if (ParentDirective == OMPD_unknown) { | ||
Diag(DSAStack->getDefaultDSALocation(), | ||
diag::err_omp_bind_required_on_loop); | ||
} else if (ParentDirective == OMPD_parallel || | ||
ParentDirective == OMPD_target_parallel) { | ||
ParentDirective == OMPD_target_parallel) | ||
BindKind = OMPC_BIND_parallel; | ||
} else if (ParentDirective == OMPD_teams || | ||
ParentDirective == OMPD_target_teams) { | ||
BindKind = OMPC_BIND_teams; | ||
} | ||
} else if (ParentDirective == OMPD_teams || | ||
ParentDirective == OMPD_target_teams) { | ||
BindKind = OMPC_BIND_teams; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please restore original code here |
||
} else { | ||
// bind clause is present, so we should set flag indicating to only | ||
// use the clauses that aren't the bind clause for the new directive that | ||
// loop is lowered to. | ||
// bind clause is present in loop directive. When the loop directive is | ||
// changed to a new directive the bind clause is not used. So, we should | ||
// set flag indicating to only use the clauses that aren't the | ||
// bind clause. | ||
UseClausesWithoutBind = true; | ||
} | ||
|
||
|
@@ -6213,26 +6229,35 @@ StmtResult Sema::ActOnOpenMPExecutableDirective( | |
OpenMPDirectiveKind PrevMappedDirective) { | ||
StmtResult Res = StmtError(); | ||
OpenMPBindClauseKind BindKind = OMPC_BIND_unknown; | ||
llvm::SmallVector<OMPClause *> ClausesWithoutBind; | ||
bool UseClausesWithoutBind = false; | ||
|
||
if (const OMPBindClause *BC = | ||
OMPExecutableDirective::getSingleClause<OMPBindClause>(Clauses)) | ||
BindKind = BC->getBindKind(); | ||
|
||
// Variable used to note down the DirectiveKind because mapLoopConstruct may | ||
// change "Kind" variable, due to mapping of "omp loop" to other directives. | ||
OpenMPDirectiveKind DK = Kind; | ||
if (Kind == OMPD_loop || PrevMappedDirective == OMPD_loop) { | ||
UseClausesWithoutBind = mapLoopConstruct( | ||
ClausesWithoutBind, Clauses, BindKind, Kind, PrevMappedDirective, | ||
StartLoc, EndLoc, DirName, CancelRegion); | ||
DK = OMPD_loop; | ||
} | ||
|
||
// First check CancelRegion which is then used in checkNestingOfRegions. | ||
if (checkCancelRegion(*this, Kind, CancelRegion, StartLoc) || | ||
checkNestingOfRegions(*this, DSAStack, Kind, DirName, CancelRegion, | ||
BindKind, StartLoc)) | ||
checkNestingOfRegions(*this, DSAStack, DK, DirName, CancelRegion, | ||
BindKind, StartLoc)) { | ||
return StmtError(); | ||
} | ||
|
||
// Report affected OpenMP target offloading behavior when in HIP lang-mode. | ||
if (getLangOpts().HIP && (isOpenMPTargetExecutionDirective(Kind) || | ||
isOpenMPTargetDataManagementDirective(Kind))) | ||
Diag(StartLoc, diag::warn_hip_omp_target_directives); | ||
|
||
llvm::SmallVector<OMPClause *> ClausesWithoutBind; | ||
bool UseClausesWithoutBind = false; | ||
|
||
UseClausesWithoutBind = mapLoopConstruct(ClausesWithoutBind, Clauses, | ||
BindKind, Kind, PrevMappedDirective); | ||
|
||
llvm::SmallVector<OMPClause *, 8> ClausesWithImplicit; | ||
VarsWithInheritedDSAType VarsWithInheritedDSA; | ||
bool ErrorFound = false; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you removed this? Remind me if we discussed it before.