Skip to content

Conversation

@kerbowa
Copy link
Member

@kerbowa kerbowa commented Nov 26, 2025

This patch introduces scaffolding for a new machine instruction
scheduling strategy optimized for machine learning workloads.

Enable the ML scheduler automatically when functions have the
"amdgpu-workload-type"="ml" attribute.

This patch introduces scaffolding for a new machine instruction scheduling strategy optimized for machine learning workloads. Enable the ML scheduler automatically when functions have the "amdgpu-workload-type"="ml" attribute.
@github-actions
Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff origin/main HEAD --extensions cpp,h -- llvm/lib/Target/AMDGPU/AMDGPUMLSchedStrategy.cpp llvm/lib/Target/AMDGPU/AMDGPUMLSchedStrategy.h llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp llvm/lib/Target/AMDGPU/GCNSchedStrategy.h llvm/lib/Target/AMDGPU/GCNSubtarget.cpp --diff_from_common_commit

⚠️
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing origin/main to the base branch/commit you want to compare against.
⚠️

View the diff from clang-format here.
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp index b8962d286..f2fd137e4 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -24,6 +24,7 @@ #include "AMDGPUIGroupLP.h" #include "AMDGPUISelDAGToDAG.h" #include "AMDGPULowerVGPREncoding.h" +#include "AMDGPUMLSchedStrategy.h" #include "AMDGPUMacroFusion.h" #include "AMDGPUPerfHintAnalysis.h" #include "AMDGPUPreloadKernArgProlog.h" @@ -43,7 +44,6 @@ #include "GCNPreRAOptimizations.h" #include "GCNRewritePartialRegUses.h" #include "GCNSchedStrategy.h" -#include "AMDGPUMLSchedStrategy.h" #include "GCNVOPDUtils.h" #include "R600.h" #include "R600TargetMachine.h" @@ -1218,9 +1218,9 @@ GCNTargetMachine::createPostMachineScheduler(MachineSchedContext *C) const { C, std::make_unique<AMDGPUMLPostSchedStrategy>(C), /*RemoveKillFlags=*/true); - ScheduleDAGMI *DAG = new GCNPostScheduleDAGMILive( - C, std::make_unique<PostGenericScheduler>(C), - /*RemoveKillFlags=*/true); + ScheduleDAGMI *DAG = + new GCNPostScheduleDAGMILive(C, std::make_unique<PostGenericScheduler>(C), + /*RemoveKillFlags=*/true); const GCNSubtarget &ST = C->MF->getSubtarget<GCNSubtarget>(); DAG->addMutation(createLoadClusterDAGMutation(DAG->TII, DAG->TRI)); if (ST.shouldClusterStores()) diff --git a/llvm/lib/Target/AMDGPU/GCNSubtarget.cpp b/llvm/lib/Target/AMDGPU/GCNSubtarget.cpp index f21dffd61..13a20bdee 100644 --- a/llvm/lib/Target/AMDGPU/GCNSubtarget.cpp +++ b/llvm/lib/Target/AMDGPU/GCNSubtarget.cpp @@ -333,7 +333,8 @@ void GCNSubtarget::overrideSchedPolicy(MachineSchedPolicy &Policy, const Function &F = Region.RegionBegin->getMF()->getFunction(); Attribute WorkloadAttr = F.getFnAttribute("amdgpu-workload-type"); - bool IsMLWorkload = WorkloadAttr.isValid() && WorkloadAttr.getValueAsString() == "ml"; + bool IsMLWorkload = + WorkloadAttr.isValid() && WorkloadAttr.getValueAsString() == "ml"; // Always schedule top-down for better blancing of HW resource usage. if (IsMLWorkload) Policy.OnlyTopDown = true; 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants