-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[OpenMP] Taskgraph Clang 'record and replay' frontend support #159774
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
jtb20
wants to merge
4
commits into
llvm:users/jtb20/omp-taskgraph-runtime
Choose a base branch
from
jtb20:omp-taskgraph-frontend-3
base: users/jtb20/omp-taskgraph-runtime
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
Some comments aren't visible on the classic Files Changed page.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2760,6 +2760,55 @@ class OMPTaskwaitDirective : public OMPExecutableDirective { | |
| } | ||
| }; | ||
|
|
||
| /// This represents '#pragma omp taskgraph' directive. | ||
| /// Available with OpenMP 6.0. | ||
| /// | ||
| /// \code | ||
| /// #pragma omp taskgraph | ||
| /// \endcode | ||
| /// | ||
| class OMPTaskgraphDirective final : public OMPExecutableDirective { | ||
| friend class ASTStmtReader; | ||
| friend class OMPExecutableDirective; | ||
| /// Build directive with the given start and end location. | ||
| /// | ||
| /// \param StartLoc Starting location of the directive kind. | ||
| /// \param EndLoc Ending location of the directive. | ||
| /// | ||
| OMPTaskgraphDirective(SourceLocation StartLoc, SourceLocation EndLoc) | ||
| : OMPExecutableDirective(OMPTaskgraphDirectiveClass, | ||
| llvm::omp::OMPD_taskgraph, StartLoc, EndLoc) {} | ||
|
|
||
| /// Build an empty directive. | ||
| /// | ||
| explicit OMPTaskgraphDirective() | ||
| : OMPExecutableDirective(OMPTaskgraphDirectiveClass, | ||
| llvm::omp::OMPD_taskgraph, SourceLocation(), | ||
| SourceLocation()) {} | ||
|
|
||
| public: | ||
| /// Creates directive. | ||
| /// | ||
| /// \param C AST context. | ||
| /// \param StartLoc Starting location of the directive kind. | ||
| /// \param EndLoc Ending Location of the directive. | ||
| /// | ||
| static OMPTaskgraphDirective * | ||
| Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, | ||
| ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt); | ||
|
Member
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. Does it have clauses? |
||
|
|
||
| /// Creates an empty directive. | ||
| /// | ||
| /// \param C AST context. | ||
| /// | ||
| static OMPTaskgraphDirective *CreateEmpty(const ASTContext &C, | ||
| unsigned NumClauses, EmptyShell); | ||
|
|
||
| static bool classof(const Stmt *T) { | ||
| return T->getStmtClass() == OMPTaskgraphDirectiveClass; | ||
| } | ||
| }; | ||
|
|
||
| /// This represents '#pragma omp taskgroup' directive. | ||
| /// | ||
| /// \code | ||
|
|
||
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
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
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 |
|---|---|---|
|
|
@@ -58,6 +58,8 @@ class CGOpenMPRegionInfo : public CodeGenFunction::CGCapturedStmtInfo { | |
| ParallelOutlinedRegion, | ||
| /// Region with outlined function for standalone 'task' directive. | ||
| TaskOutlinedRegion, | ||
| /// Region with outlined function for standalone 'taskgraph' directive. | ||
| TaskgraphOutlinedRegion, | ||
| /// Region for constructs that do not require function outlining, | ||
| /// like 'for', 'sections', 'atomic' etc. directives. | ||
| InlinedRegion, | ||
|
|
@@ -232,6 +234,26 @@ class CGOpenMPTaskOutlinedRegionInfo final : public CGOpenMPRegionInfo { | |
| const UntiedTaskActionTy &Action; | ||
| }; | ||
|
|
||
| /// API for captured statement code generation in OpenMP taskgraphs. | ||
| class CGOpenMPTaskgraphRegionInfo final : public CGOpenMPRegionInfo { | ||
| public: | ||
| CGOpenMPTaskgraphRegionInfo(const CapturedStmt &CS, | ||
| const RegionCodeGenTy &CodeGen) | ||
| : CGOpenMPRegionInfo(CS, TaskgraphOutlinedRegion, CodeGen, | ||
| llvm::omp::OMPD_taskgraph, false) {} | ||
|
|
||
| const VarDecl *getThreadIDVariable() const override { return 0; } | ||
|
|
||
| /// Get the name of the capture helper. | ||
| StringRef getHelperName() const override { return "taskgraph.omp_outlined."; } | ||
|
|
||
| static bool classof(const CGCapturedStmtInfo *Info) { | ||
| return CGOpenMPRegionInfo::classof(Info) && | ||
| cast<CGOpenMPRegionInfo>(Info)->getRegionKind() == | ||
| TaskgraphOutlinedRegion; | ||
| } | ||
| }; | ||
|
|
||
| /// API for inlined captured statement code generation in OpenMP | ||
| /// constructs. | ||
| class CGOpenMPInlinedRegionInfo : public CGOpenMPRegionInfo { | ||
|
|
@@ -5958,6 +5980,48 @@ void CGOpenMPRuntime::emitTaskwaitCall(CodeGenFunction &CGF, SourceLocation Loc, | |
| Region->emitUntiedSwitch(CGF); | ||
| } | ||
|
|
||
| void CGOpenMPRuntime::emitTaskgraphCall(CodeGenFunction &CGF, | ||
| SourceLocation Loc, | ||
| const OMPExecutableDirective &D) { | ||
| if (!CGF.HaveInsertPoint()) | ||
| return; | ||
|
|
||
| // Building kmp_taskgraph_flags_t flags for kmpc_taskgraph. C.f., kmp.h | ||
| enum { | ||
| NowaitFlag = 0x1, // Not used yet. | ||
| ReRecordFlag = 0x2, | ||
| }; | ||
|
|
||
| unsigned Flags = 0; | ||
|
|
||
| CodeGenFunction OutlinedCGF(CGM, /*suppressNewContext=*/true); | ||
|
|
||
| const auto *CS = cast<CapturedStmt>(D.getAssociatedStmt()); | ||
|
|
||
| auto BodyGen = [CS](CodeGenFunction &CGF, PrePostActionTy &) { | ||
| CGF.EmitStmt(CS->getCapturedStmt()); | ||
| }; | ||
|
|
||
| LValue CapStruct = CGF.InitCapturedStruct(*CS); | ||
| CGOpenMPTaskgraphRegionInfo TaskgraphRegion(*CS, BodyGen); | ||
| CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(OutlinedCGF, | ||
| &TaskgraphRegion); | ||
| llvm::Function *FnT = OutlinedCGF.GenerateCapturedStmtFunction(*CS); | ||
|
|
||
| std::array<llvm::Value *, 6> Args{ | ||
| emitUpdateLocation(CGF, Loc), | ||
| getThreadID(CGF, Loc), | ||
| CGF.Builder.getInt32(Flags), | ||
| CGF.Builder.getInt32(D.getBeginLoc().getHashValue()), | ||
| CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(FnT, CGM.VoidPtrTy), | ||
| CGF.Builder.CreatePointerBitCastOrAddrSpaceCast( | ||
| CapStruct.getPointer(OutlinedCGF), CGM.VoidPtrTy)}; | ||
|
|
||
| CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction( | ||
| CGM.getModule(), OMPRTL___kmpc_taskgraph), | ||
| Args); | ||
| } | ||
|
|
||
| void CGOpenMPRuntime::emitInlinedDirective(CodeGenFunction &CGF, | ||
| OpenMPDirectiveKind InnerKind, | ||
| const RegionCodeGenTy &CodeGen, | ||
|
|
@@ -6393,6 +6457,7 @@ const Expr *CGOpenMPRuntime::getNumTeamsExprForTargetDirective( | |
| case OMPD_taskyield: | ||
| case OMPD_barrier: | ||
| case OMPD_taskwait: | ||
| case OMPD_taskgraph: | ||
| case OMPD_taskgroup: | ||
| case OMPD_atomic: | ||
| case OMPD_flush: | ||
|
|
@@ -9797,6 +9862,7 @@ getNestedDistributeDirective(ASTContext &Ctx, const OMPExecutableDirective &D) { | |
| case OMPD_taskyield: | ||
| case OMPD_barrier: | ||
| case OMPD_taskwait: | ||
| case OMPD_taskgraph: | ||
| case OMPD_taskgroup: | ||
| case OMPD_atomic: | ||
| case OMPD_flush: | ||
|
|
@@ -10443,6 +10509,7 @@ void CGOpenMPRuntime::scanForTargetRegionsFunctions(const Stmt *S, | |
| case OMPD_taskyield: | ||
| case OMPD_barrier: | ||
| case OMPD_taskwait: | ||
| case OMPD_taskgraph: | ||
| case OMPD_taskgroup: | ||
| case OMPD_atomic: | ||
| case OMPD_flush: | ||
|
|
@@ -11010,6 +11077,7 @@ void CGOpenMPRuntime::emitTargetDataStandAloneCall( | |
| case OMPD_taskyield: | ||
| case OMPD_barrier: | ||
| case OMPD_taskwait: | ||
| case OMPD_taskgraph: | ||
| case OMPD_taskgroup: | ||
| case OMPD_atomic: | ||
| case OMPD_flush: | ||
|
|
@@ -12751,6 +12819,12 @@ void CGOpenMPSIMDRuntime::emitTaskwaitCall(CodeGenFunction &CGF, | |
| llvm_unreachable("Not supported in SIMD-only mode"); | ||
| } | ||
|
|
||
| void CGOpenMPSIMDRuntime::emitTaskgraphCall(CodeGenFunction &CGF, | ||
| SourceLocation Loc, | ||
| const OMPExecutableDirective &D) { | ||
| llvm_unreachable("Not supported in SIMD-only mode"); | ||
|
Member
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. Shall we support it in simd mode at all? I assume, it must be just ignored in simd-only |
||
| } | ||
|
|
||
| void CGOpenMPSIMDRuntime::emitCancellationPointCall( | ||
| CodeGenFunction &CGF, SourceLocation Loc, | ||
| OpenMPDirectiveKind CancelRegion) { | ||
|
|
||
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
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
Oops, something went wrong.
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.
Also, update OpenMPSupport.rst