[llvm] [AMDGPU][Attributor] Rework update of `AAAMDWavesPerEU` (PR #123995)
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Fri May 16 15:43:27 PDT 2025
================
@@ -1323,6 +1298,60 @@ struct AAAMDGPUNoAGPR
const char AAAMDGPUNoAGPR::ID = 0;
+/// The final check and update of the attribute 'amdgpu-waves-per-eu' based on
+/// the determined 'amdgpu-flat-work-group-size' attribute. We can't do this
+/// during attributor run because the two attributes grow in opposite direction,
+/// we should not use any intermediate value to calculate waves per eu until we
+/// have a determined flat workgroup size.
+static void updateWavesPerEU(Module &M, TargetMachine &TM) {
+ for (Function &F : M) {
+ if (F.isDeclaration())
+ continue;
+
+ const GCNSubtarget &ST = TM.getSubtarget<GCNSubtarget>(F);
+
+ std::optional<std::pair<unsigned, std::optional<unsigned>>>
+ FlatWgrpSizeAttr =
+ AMDGPU::getIntegerPairAttribute(F, "amdgpu-flat-work-group-size");
+
+ unsigned MinWavesPerEU = ST.getMinWavesPerEU();
+ unsigned MaxWavesPerEU = ST.getMaxWavesPerEU();
+
+ unsigned MinFlatWgrpSize = ST.getMinFlatWorkGroupSize();
+ unsigned MaxFlatWgrpSize = ST.getMaxFlatWorkGroupSize();
+ if (FlatWgrpSizeAttr.has_value()) {
+ MinFlatWgrpSize = FlatWgrpSizeAttr->first;
+ MaxFlatWgrpSize = *(FlatWgrpSizeAttr->second);
+ }
+
+ // Start with the max range.
----------------
jdoerfert wrote:
"best range", not "max"
https://github.com/llvm/llvm-project/pull/123995
More information about the llvm-commits
mailing list