@@ -92,9 +92,23 @@ static const std::pair<StringRef, StringRef>
92
92
W32FS = {" +wavefrontsize32" , " w32" },
93
93
W64FS = {" +wavefrontsize64" , " w64" };
94
94
95
- static void testGPRLimits (
96
- const char *RegName, bool TestW32W64,
97
- std::function<bool (std::stringstream &, unsigned , GCNSubtarget &)> test) {
95
+ using TestFuncTy =
96
+ function_ref<bool (std::stringstream &, unsigned , const GCNSubtarget &)>;
97
+
98
+ static bool testAndRecord (std::stringstream &Table, const GCNSubtarget &ST,
99
+ TestFuncTy test) {
100
+ bool Success = true ;
101
+ unsigned MaxOcc = ST.getMaxWavesPerEU ();
102
+ for (unsigned Occ = MaxOcc; Occ > 0 ; --Occ) {
103
+ Table << std::right << std::setw (3 ) << Occ << " " ;
104
+ Success = test (Table, Occ, ST) && Success;
105
+ Table << ' \n ' ;
106
+ }
107
+ return Success;
108
+ }
109
+
110
+ static void testGPRLimits (const char *RegName, bool TestW32W64,
111
+ TestFuncTy test) {
98
112
SmallVector<StringRef> CPUs;
99
113
AMDGPU::fillValidArchListAMDGCN (CPUs);
100
114
@@ -117,13 +131,7 @@ static void testGPRLimits(
117
131
FS = &W32FS;
118
132
119
133
std::stringstream Table;
120
- bool Success = true ;
121
- unsigned MaxOcc = ST.getMaxWavesPerEU ();
122
- for (unsigned Occ = MaxOcc; Occ > 0 ; --Occ) {
123
- Table << std::right << std::setw (3 ) << Occ << " " ;
124
- Success = test (Table, Occ, ST) && Success;
125
- Table << ' \n ' ;
126
- }
134
+ bool Success = testAndRecord (Table, ST, test);
127
135
if (!Success || PrintCpuRegLimits)
128
136
TablePerCPUs[Table.str ()].push_back ((CanonCPUName + FS->second ).str ());
129
137
@@ -145,13 +153,14 @@ static void testGPRLimits(
145
153
}
146
154
147
155
TEST (AMDGPU, TestVGPRLimitsPerOccupancy) {
148
- testGPRLimits (" VGPR" , true , [](std::stringstream &OS, unsigned Occ,
149
- GCNSubtarget &ST) {
156
+ auto test = [](std::stringstream &OS, unsigned Occ, const GCNSubtarget &ST) {
150
157
unsigned MaxVGPRNum = ST.getAddressableNumVGPRs ();
151
158
return checkMinMax (
152
159
OS, Occ, ST.getOccupancyWithNumVGPRs (MaxVGPRNum), ST.getMaxWavesPerEU (),
153
160
[&](unsigned NumGPRs) { return ST.getOccupancyWithNumVGPRs (NumGPRs); },
154
161
[&](unsigned Occ) { return ST.getMinNumVGPRs (Occ); },
155
162
[&](unsigned Occ) { return ST.getMaxNumVGPRs (Occ); });
156
- });
163
+ };
164
+
165
+ testGPRLimits (" VGPR" , true , test);
157
166
}
0 commit comments