-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[AMDGPU] Add iglp_opt(3) for simple mfma / exp interleaving #117269
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -832,7 +832,8 @@ void PipelineSolver::solve() { | |
| enum IGLPStrategyID : int { | ||
| MFMASmallGemmOptID = 0, | ||
| MFMASmallGemmSingleWaveOptID = 1, | ||
| MFMAExpInterleave = 2 | ||
| MFMAExpInterleave = 2, | ||
| MFMAExpSimpleInterleaveID = 3 | ||
| }; | ||
|
|
||
| // Implement a IGLP scheduling strategy. | ||
|
|
@@ -1845,6 +1846,50 @@ bool MFMAExpInterleaveOpt::applyIGLPStrategy( | |
| return true; | ||
| } | ||
|
|
||
| class MFMAExpSimpleInterleaveOpt final : public IGLPStrategy { | ||
| private: | ||
jrbyrnes marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| public: | ||
| bool applyIGLPStrategy( | ||
| DenseMap<int, SUnitsToCandidateSGsMap> &SyncedInstrs, | ||
| DenseMap<int, SmallVector<SchedGroup, 4>> &SyncedSchedGroups, | ||
|
Comment on lines
+1852
to
+1853
Contributor
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. What are these map keys? This could just be an array?
Contributor
Author
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. The map keys are the SyncIDs for the SchedGroups. We try to enforce ordering of SchedGroups that have the same SyncIDs. If a user specifies SchedGroups with multiple SyncIDs, then we would construct multiple SchedGroup based pipelines that are overlayed on one another. A multi-level structure works best with the Solver, but I suppose we could convert to a container for a vector of vectors with some SyncID -> index mapping. I think that should be done separately though. |
||
| AMDGPU::SchedulingPhase Phase) override; | ||
|
|
||
| bool shouldApplyStrategy(ScheduleDAGInstrs *DAG, | ||
| AMDGPU::SchedulingPhase Phase) override { | ||
| return true; | ||
| } | ||
|
|
||
| MFMAExpSimpleInterleaveOpt(ScheduleDAGInstrs *DAG, const SIInstrInfo *TII) | ||
| : IGLPStrategy(DAG, TII) { | ||
| IsBottomUp = true; | ||
| } | ||
| }; | ||
|
|
||
| bool MFMAExpSimpleInterleaveOpt::applyIGLPStrategy( | ||
| DenseMap<int, SUnitsToCandidateSGsMap> &SyncedInstrs, | ||
| DenseMap<int, SmallVector<SchedGroup, 4>> &SyncedSchedGroups, | ||
| AMDGPU::SchedulingPhase Phase) { | ||
| // Count the number of MFMA instructions. | ||
| unsigned MFMACount = 0; | ||
| for (const MachineInstr &I : *DAG) | ||
| if (TII->isMFMAorWMMA(I)) | ||
| ++MFMACount; | ||
|
|
||
| const unsigned PipelineSyncID = 0; | ||
| SchedGroup *SG = nullptr; | ||
jrbyrnes marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| for (unsigned I = 0; I < MFMACount * 3; ++I) { | ||
| SG = &SyncedSchedGroups[PipelineSyncID].emplace_back( | ||
| SchedGroupMask::TRANS, 1, PipelineSyncID, DAG, TII); | ||
| SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]); | ||
|
|
||
| SG = &SyncedSchedGroups[PipelineSyncID].emplace_back( | ||
| SchedGroupMask::MFMA, 1, PipelineSyncID, DAG, TII); | ||
| SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]); | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| class MFMASmallGemmSingleWaveOpt final : public IGLPStrategy { | ||
| private: | ||
| // Whether the DS_READ is a predecessor of first four MFMA in region | ||
|
|
@@ -2310,6 +2355,8 @@ createIGLPStrategy(IGLPStrategyID ID, ScheduleDAGInstrs *DAG, | |
| return std::make_unique<MFMASmallGemmSingleWaveOpt>(DAG, TII); | ||
| case MFMAExpInterleave: | ||
| return std::make_unique<MFMAExpInterleaveOpt>(DAG, TII); | ||
| case MFMAExpSimpleInterleaveID: | ||
| return std::make_unique<MFMAExpSimpleInterleaveOpt>(DAG, TII); | ||
| } | ||
|
|
||
| llvm_unreachable("Unknown IGLPStrategyID"); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.