From 6f956e3117589e6a4c71ed7f27095aa232778304 Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Mon, 30 Sep 2024 10:29:31 +0100 Subject: [PATCH] [AMDGPU] Rename LocalMemorySize features to AddressableLocalMemorySize (#110242) Change the names of the TableGen features to match the names used by AMDGPUSubtarget. "Addressable" refers to the amount that can be accessed by a single workgroup. Add some explanatory comments. NFC. --- llvm/lib/Target/AMDGPU/AMDGPU.td | 14 +++++++------- llvm/lib/Target/AMDGPU/AMDGPUFeatures.td | 12 +++++++----- llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h | 8 ++++++++ llvm/lib/Target/AMDGPU/GCNSubtarget.cpp | 7 +++---- llvm/lib/Target/AMDGPU/R600Processors.td | 4 ++-- llvm/lib/Target/AMDGPU/R600Subtarget.cpp | 2 +- llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp | 4 ++-- 7 files changed, 30 insertions(+), 21 deletions(-) diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.td b/llvm/lib/Target/AMDGPU/AMDGPU.td index 3626fd8bc78c15..dc94edf85586f5 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPU.td +++ b/llvm/lib/Target/AMDGPU/AMDGPU.td @@ -1118,7 +1118,7 @@ class GCNSubtargetFeatureGeneration ; -class SubtargetFeatureLocalMemorySize : SubtargetFeature< - "localmemorysize"#Value, - "LocalMemorySize", +// Addressable local memory size is the maximum number of bytes of LDS that can +// be allocated to a single workgroup. +class SubtargetFeatureAddressableLocalMemorySize : SubtargetFeature< + "addressablelocalmemorysize"#Value, + "AddressableLocalMemorySize", !cast(Value), "The size of local memory in bytes" >; -def FeatureLocalMemorySize32768 : SubtargetFeatureLocalMemorySize<32768>; -def FeatureLocalMemorySize65536 : SubtargetFeatureLocalMemorySize<65536>; +def FeatureAddressableLocalMemorySize32768 : SubtargetFeatureAddressableLocalMemorySize<32768>; +def FeatureAddressableLocalMemorySize65536 : SubtargetFeatureAddressableLocalMemorySize<65536>; class SubtargetFeatureWavefrontSize : SubtargetFeature< "wavefrontsize"#!shl(1, ValueLog2), diff --git a/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h b/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h index 49ccd2c9ae5112..334322f533e54a 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h +++ b/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h @@ -226,10 +226,18 @@ class AMDGPUSubtarget { return WavefrontSizeLog2; } + /// Return the maximum number of bytes of LDS available for all workgroups + /// running on the same WGP or CU. + /// For GFX10-GFX12 in WGP mode this is 128k even though each workgroup is + /// limited to 64k. unsigned getLocalMemorySize() const { return LocalMemorySize; } + /// Return the maximum number of bytes of LDS that can be allocated to a + /// single workgroup. + /// For GFX10-GFX12 in WGP mode this is limited to 64k even though the WGP has + /// 128k in total. unsigned getAddressableLocalMemorySize() const { return AddressableLocalMemorySize; } diff --git a/llvm/lib/Target/AMDGPU/GCNSubtarget.cpp b/llvm/lib/Target/AMDGPU/GCNSubtarget.cpp index 52c24a5c25ec24..187d337a98a0bc 100644 --- a/llvm/lib/Target/AMDGPU/GCNSubtarget.cpp +++ b/llvm/lib/Target/AMDGPU/GCNSubtarget.cpp @@ -143,11 +143,10 @@ GCNSubtarget &GCNSubtarget::initializeSubtargetDependencies(const Triple &TT, if (LDSBankCount == 0) LDSBankCount = 32; - if (TT.getArch() == Triple::amdgcn && LocalMemorySize == 0) - LocalMemorySize = 32768; - - AddressableLocalMemorySize = LocalMemorySize; + if (TT.getArch() == Triple::amdgcn && AddressableLocalMemorySize == 0) + AddressableLocalMemorySize = 32768; + LocalMemorySize = AddressableLocalMemorySize; if (AMDGPU::isGFX10Plus(*this) && !getFeatureBits().test(AMDGPU::FeatureCuMode)) LocalMemorySize *= 2; diff --git a/llvm/lib/Target/AMDGPU/R600Processors.td b/llvm/lib/Target/AMDGPU/R600Processors.td index 8cf8edd1254fe8..0265a976c9825f 100644 --- a/llvm/lib/Target/AMDGPU/R600Processors.td +++ b/llvm/lib/Target/AMDGPU/R600Processors.td @@ -53,13 +53,13 @@ def FeatureR700 : R600SubtargetFeatureGeneration<"R700", "r700", >; def FeatureEvergreen : R600SubtargetFeatureGeneration<"EVERGREEN", "evergreen", - [FeatureFetchLimit16, FeatureLocalMemorySize32768] + [FeatureFetchLimit16, FeatureAddressableLocalMemorySize32768] >; def FeatureNorthernIslands : R600SubtargetFeatureGeneration<"NORTHERN_ISLANDS", "northern-islands", [FeatureFetchLimit16, FeatureWavefrontSize64, - FeatureLocalMemorySize32768] + FeatureAddressableLocalMemorySize32768] >; diff --git a/llvm/lib/Target/AMDGPU/R600Subtarget.cpp b/llvm/lib/Target/AMDGPU/R600Subtarget.cpp index e5a8c5cf3baf6f..fd5a87999cf81b 100644 --- a/llvm/lib/Target/AMDGPU/R600Subtarget.cpp +++ b/llvm/lib/Target/AMDGPU/R600Subtarget.cpp @@ -29,7 +29,7 @@ R600Subtarget::R600Subtarget(const Triple &TT, StringRef GPU, StringRef FS, FrameLowering(TargetFrameLowering::StackGrowsUp, getStackAlignment(), 0), TLInfo(TM, initializeSubtargetDependencies(TT, GPU, FS)), InstrItins(getInstrItineraryForCPU(GPU)) { - AddressableLocalMemorySize = LocalMemorySize; + LocalMemorySize = AddressableLocalMemorySize; } R600Subtarget &R600Subtarget::initializeSubtargetDependencies(const Triple &TT, diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp index 8901e4a50bab94..feec7b47ae294b 100644 --- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp +++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp @@ -911,9 +911,9 @@ unsigned getLocalMemorySize(const MCSubtargetInfo *STI) { } unsigned getAddressableLocalMemorySize(const MCSubtargetInfo *STI) { - if (STI->getFeatureBits().test(FeatureLocalMemorySize32768)) + if (STI->getFeatureBits().test(FeatureAddressableLocalMemorySize32768)) return 32768; - if (STI->getFeatureBits().test(FeatureLocalMemorySize65536)) + if (STI->getFeatureBits().test(FeatureAddressableLocalMemorySize65536)) return 65536; return 0; }