[PATCH] D79855: [AMDGPU] Strengthen export cluster ordering
Carl Ritson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 13 05:54:35 PDT 2020
critson created this revision.
critson added a reviewer: foad.
Herald added subscribers: llvm-commits, kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, wdng, jvesely, kzhuravl, arsenm.
Herald added a project: LLVM.
When removing barrier edges on exports then dependencies need to
be propagated.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D79855
Files:
llvm/lib/Target/AMDGPU/AMDGPUExportClustering.cpp
Index: llvm/lib/Target/AMDGPU/AMDGPUExportClustering.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUExportClustering.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUExportClustering.cpp
@@ -81,6 +81,32 @@
}
}
+static void removeExportDependencies(ScheduleDAGInstrs *DAG, SUnit &SU) {
+ SmallVector<SDep, 2> ToAdd, ToRemove;
+
+ for (const SDep &Pred : SU.Preds) {
+ SUnit *PredSU = Pred.getSUnit();
+ if (Pred.isBarrier() && isExport(*PredSU)) {
+ ToRemove.push_back(Pred);
+ if (isExport(SU))
+ continue;
+
+ // If we remove a barrier we need to copy dependencies
+ // from the predecessor to maintain order.
+ for (const SDep &ExportPred : PredSU->Preds) {
+ SUnit *ExportPredSU = ExportPred.getSUnit();
+ if (ExportPred.isBarrier() && !isExport(*ExportPredSU))
+ ToAdd.push_back(SDep(ExportPredSU, SDep::Barrier));
+ }
+ }
+ }
+
+ for (SDep Pred : ToRemove)
+ SU.removePred(Pred);
+ for (SDep Pred : ToAdd)
+ DAG->addEdge(&SU, Pred);
+}
+
void ExportClustering::apply(ScheduleDAGInstrs *DAG) {
const SIInstrInfo *TII = static_cast<const SIInstrInfo *>(DAG->TII);
@@ -97,15 +123,7 @@
if (isPositionExport(TII, &SU))
PosCount++;
}
-
- SmallVector<SDep, 2> ToRemove;
- for (const SDep &Pred : SU.Preds) {
- SUnit *PredSU = Pred.getSUnit();
- if (Pred.isBarrier() && isExport(*PredSU))
- ToRemove.push_back(Pred);
- }
- for (SDep Pred : ToRemove)
- SU.removePred(Pred);
+ removeExportDependencies(DAG, SU);
}
// Apply clustering if there are multiple exports
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79855.263685.patch
Type: text/x-patch
Size: 1663 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200513/acb223ba/attachment.bin>
More information about the llvm-commits
mailing list