Skip to content

Commit 6f956e3

Browse files
authored
[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.
1 parent b8c974f commit 6f956e3

File tree

7 files changed

+30
-21
lines changed

7 files changed

+30
-21
lines changed

llvm/lib/Target/AMDGPU/AMDGPU.td

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ class GCNSubtargetFeatureGeneration <string Value,
11181118

11191119
def FeatureSouthernIslands : GCNSubtargetFeatureGeneration<"SOUTHERN_ISLANDS",
11201120
"southern-islands",
1121-
[FeatureFP64, FeatureLocalMemorySize32768, FeatureMIMG_R128,
1121+
[FeatureFP64, FeatureAddressableLocalMemorySize32768, FeatureMIMG_R128,
11221122
FeatureWavefrontSize64, FeatureSMemTimeInst, FeatureMadMacF32Insts,
11231123
FeatureDsSrc2Insts, FeatureLDSBankCount32, FeatureMovrel,
11241124
FeatureTrigReducedRange, FeatureExtendedImageInsts, FeatureImageInsts,
@@ -1130,7 +1130,7 @@ def FeatureSouthernIslands : GCNSubtargetFeatureGeneration<"SOUTHERN_ISLANDS",
11301130

11311131
def FeatureSeaIslands : GCNSubtargetFeatureGeneration<"SEA_ISLANDS",
11321132
"sea-islands",
1133-
[FeatureFP64, FeatureLocalMemorySize65536, FeatureMIMG_R128,
1133+
[FeatureFP64, FeatureAddressableLocalMemorySize65536, FeatureMIMG_R128,
11341134
FeatureWavefrontSize64, FeatureFlatAddressSpace,
11351135
FeatureCIInsts, FeatureMovrel, FeatureTrigReducedRange,
11361136
FeatureGFX7GFX8GFX9Insts, FeatureSMemTimeInst, FeatureMadMacF32Insts,
@@ -1144,7 +1144,7 @@ def FeatureSeaIslands : GCNSubtargetFeatureGeneration<"SEA_ISLANDS",
11441144

11451145
def FeatureVolcanicIslands : GCNSubtargetFeatureGeneration<"VOLCANIC_ISLANDS",
11461146
"volcanic-islands",
1147-
[FeatureFP64, FeatureLocalMemorySize65536, FeatureMIMG_R128,
1147+
[FeatureFP64, FeatureAddressableLocalMemorySize65536, FeatureMIMG_R128,
11481148
FeatureWavefrontSize64, FeatureFlatAddressSpace,
11491149
FeatureGCN3Encoding, FeatureCIInsts, Feature16BitInsts,
11501150
FeatureSMemRealTime, FeatureVGPRIndexMode, FeatureMovrel,
@@ -1160,7 +1160,7 @@ def FeatureVolcanicIslands : GCNSubtargetFeatureGeneration<"VOLCANIC_ISLANDS",
11601160

11611161
def FeatureGFX9 : GCNSubtargetFeatureGeneration<"GFX9",
11621162
"gfx9",
1163-
[FeatureFP64, FeatureLocalMemorySize65536,
1163+
[FeatureFP64, FeatureAddressableLocalMemorySize65536,
11641164
FeatureWavefrontSize64, FeatureFlatAddressSpace,
11651165
FeatureGCN3Encoding, FeatureCIInsts, Feature16BitInsts,
11661166
FeatureSMemRealTime, FeatureScalarStores, FeatureInv2PiInlineImm,
@@ -1179,7 +1179,7 @@ def FeatureGFX9 : GCNSubtargetFeatureGeneration<"GFX9",
11791179

11801180
def FeatureGFX10 : GCNSubtargetFeatureGeneration<"GFX10",
11811181
"gfx10",
1182-
[FeatureFP64, FeatureLocalMemorySize65536, FeatureMIMG_R128,
1182+
[FeatureFP64, FeatureAddressableLocalMemorySize65536, FeatureMIMG_R128,
11831183
FeatureFlatAddressSpace,
11841184
FeatureCIInsts, Feature16BitInsts,
11851185
FeatureSMemRealTime, FeatureInv2PiInlineImm,
@@ -1203,7 +1203,7 @@ def FeatureGFX10 : GCNSubtargetFeatureGeneration<"GFX10",
12031203

12041204
def FeatureGFX11 : GCNSubtargetFeatureGeneration<"GFX11",
12051205
"gfx11",
1206-
[FeatureFP64, FeatureLocalMemorySize65536, FeatureMIMG_R128,
1206+
[FeatureFP64, FeatureAddressableLocalMemorySize65536, FeatureMIMG_R128,
12071207
FeatureFlatAddressSpace, Feature16BitInsts,
12081208
FeatureInv2PiInlineImm, FeatureApertureRegs,
12091209
FeatureCIInsts, FeatureGFX8Insts, FeatureGFX9Insts, FeatureGFX10Insts,
@@ -1226,7 +1226,7 @@ def FeatureGFX11 : GCNSubtargetFeatureGeneration<"GFX11",
12261226

12271227
def FeatureGFX12 : GCNSubtargetFeatureGeneration<"GFX12",
12281228
"gfx12",
1229-
[FeatureFP64, FeatureLocalMemorySize65536, FeatureMIMG_R128,
1229+
[FeatureFP64, FeatureAddressableLocalMemorySize65536, FeatureMIMG_R128,
12301230
FeatureFlatAddressSpace, Feature16BitInsts,
12311231
FeatureInv2PiInlineImm, FeatureApertureRegs,
12321232
FeatureCIInsts, FeatureGFX8Insts, FeatureGFX9Insts, FeatureGFX10Insts,

llvm/lib/Target/AMDGPU/AMDGPUFeatures.td

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@ def FeatureFMA : SubtargetFeature<"fmaf",
1818
"Enable single precision FMA (not as fast as mul+add, but fused)"
1919
>;
2020

21-
class SubtargetFeatureLocalMemorySize <int Value> : SubtargetFeature<
22-
"localmemorysize"#Value,
23-
"LocalMemorySize",
21+
// Addressable local memory size is the maximum number of bytes of LDS that can
22+
// be allocated to a single workgroup.
23+
class SubtargetFeatureAddressableLocalMemorySize <int Value> : SubtargetFeature<
24+
"addressablelocalmemorysize"#Value,
25+
"AddressableLocalMemorySize",
2426
!cast<string>(Value),
2527
"The size of local memory in bytes"
2628
>;
2729

28-
def FeatureLocalMemorySize32768 : SubtargetFeatureLocalMemorySize<32768>;
29-
def FeatureLocalMemorySize65536 : SubtargetFeatureLocalMemorySize<65536>;
30+
def FeatureAddressableLocalMemorySize32768 : SubtargetFeatureAddressableLocalMemorySize<32768>;
31+
def FeatureAddressableLocalMemorySize65536 : SubtargetFeatureAddressableLocalMemorySize<65536>;
3032

3133
class SubtargetFeatureWavefrontSize <int ValueLog2> : SubtargetFeature<
3234
"wavefrontsize"#!shl(1, ValueLog2),

llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,18 @@ class AMDGPUSubtarget {
226226
return WavefrontSizeLog2;
227227
}
228228

229+
/// Return the maximum number of bytes of LDS available for all workgroups
230+
/// running on the same WGP or CU.
231+
/// For GFX10-GFX12 in WGP mode this is 128k even though each workgroup is
232+
/// limited to 64k.
229233
unsigned getLocalMemorySize() const {
230234
return LocalMemorySize;
231235
}
232236

237+
/// Return the maximum number of bytes of LDS that can be allocated to a
238+
/// single workgroup.
239+
/// For GFX10-GFX12 in WGP mode this is limited to 64k even though the WGP has
240+
/// 128k in total.
233241
unsigned getAddressableLocalMemorySize() const {
234242
return AddressableLocalMemorySize;
235243
}

llvm/lib/Target/AMDGPU/GCNSubtarget.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,10 @@ GCNSubtarget &GCNSubtarget::initializeSubtargetDependencies(const Triple &TT,
143143
if (LDSBankCount == 0)
144144
LDSBankCount = 32;
145145

146-
if (TT.getArch() == Triple::amdgcn && LocalMemorySize == 0)
147-
LocalMemorySize = 32768;
148-
149-
AddressableLocalMemorySize = LocalMemorySize;
146+
if (TT.getArch() == Triple::amdgcn && AddressableLocalMemorySize == 0)
147+
AddressableLocalMemorySize = 32768;
150148

149+
LocalMemorySize = AddressableLocalMemorySize;
151150
if (AMDGPU::isGFX10Plus(*this) &&
152151
!getFeatureBits().test(AMDGPU::FeatureCuMode))
153152
LocalMemorySize *= 2;

llvm/lib/Target/AMDGPU/R600Processors.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ def FeatureR700 : R600SubtargetFeatureGeneration<"R700", "r700",
5353
>;
5454

5555
def FeatureEvergreen : R600SubtargetFeatureGeneration<"EVERGREEN", "evergreen",
56-
[FeatureFetchLimit16, FeatureLocalMemorySize32768]
56+
[FeatureFetchLimit16, FeatureAddressableLocalMemorySize32768]
5757
>;
5858

5959
def FeatureNorthernIslands : R600SubtargetFeatureGeneration<"NORTHERN_ISLANDS",
6060
"northern-islands",
6161
[FeatureFetchLimit16, FeatureWavefrontSize64,
62-
FeatureLocalMemorySize32768]
62+
FeatureAddressableLocalMemorySize32768]
6363
>;
6464

6565

llvm/lib/Target/AMDGPU/R600Subtarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ R600Subtarget::R600Subtarget(const Triple &TT, StringRef GPU, StringRef FS,
2929
FrameLowering(TargetFrameLowering::StackGrowsUp, getStackAlignment(), 0),
3030
TLInfo(TM, initializeSubtargetDependencies(TT, GPU, FS)),
3131
InstrItins(getInstrItineraryForCPU(GPU)) {
32-
AddressableLocalMemorySize = LocalMemorySize;
32+
LocalMemorySize = AddressableLocalMemorySize;
3333
}
3434

3535
R600Subtarget &R600Subtarget::initializeSubtargetDependencies(const Triple &TT,

llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -911,9 +911,9 @@ unsigned getLocalMemorySize(const MCSubtargetInfo *STI) {
911911
}
912912

913913
unsigned getAddressableLocalMemorySize(const MCSubtargetInfo *STI) {
914-
if (STI->getFeatureBits().test(FeatureLocalMemorySize32768))
914+
if (STI->getFeatureBits().test(FeatureAddressableLocalMemorySize32768))
915915
return 32768;
916-
if (STI->getFeatureBits().test(FeatureLocalMemorySize65536))
916+
if (STI->getFeatureBits().test(FeatureAddressableLocalMemorySize65536))
917917
return 65536;
918918
return 0;
919919
}

0 commit comments

Comments
 (0)