This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU : Recalculate SGPRs when trap handler is supported
ClosedPublic

Authored by kzhuravl on Feb 13 2017, 2:04 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

wdng created this revision.Feb 13 2017, 2:04 PM
tony-tye added inline comments.Feb 14 2017, 2:44 PM
lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
215–222

Should check if MinNumSGPRs is less than TRAP_NUM_SGPRS, and perform the rounding after the subtraction? If so then replace with:

unsigned MinNumSGPRs = getTotalNumSGPRs(Features) / (WavesPerEU + 1);
if (Features.test(FeatureTrapHandler))
  MinNumSGPRs -= std::min(MinNumSGPRs, TRAP_NUM_SGPRS);
MinNumSGPRs = alignDown(MinNumSGPRs, getSGPRAllocGranule(Features)) + 1;
return std::min(MinNumSGPRs, getAddressableNumSGPRs(Features));
228–237

Should check if MaxNumSGPRs is less than TRAP_NUM_SGPRS? If so then replace with:

IsaVersion Version = getIsaVersion(Features);
unsigned AddressableNumSGPRs = getAddressableNumSGPRs(Features);
if (Version.Major >= 8 && !Addressable)
  AddressableNumSGPRs = 112;
unsigned MaxNumSGPRs = getTotalNumSGPRs(Features) / WavesPerEU;
if (Features.test(FeatureTrapHandler))
  MaxNumSGPRs -= std::min(MaxNumSGPRs, TRAP_NUM_SGPRS) ;
MaxNumSGPRs = alignDown(MaxNumSGPRs, getSGPRAllocGranule(Features));
return std::min(MaxNumSGPRs, AddressableNumSGPRs);
229–235

Why is this needed? Why is getAddressableNumSGPRs not returning the correct value for each target?

kzhuravl added inline comments.Feb 15 2017, 1:33 PM
lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
229–235

I talked to Tony offline about this. I will do relevant changes after this change lands.

wdng updated this revision to Diff 88860.Feb 16 2017, 10:59 PM

Address code reviews. Thank you Tony for such detailed comments!

tony-tye edited reviewers, added: t-tye; removed: tony-tye.Mar 22 2017, 6:07 PM
kzhuravl commandeered this revision.May 15 2018, 2:29 PM
kzhuravl edited reviewers, added: wdng; removed: kzhuravl.
kzhuravl updated this revision to Diff 146918.May 15 2018, 2:30 PM
kzhuravl retitled this revision from AMDGPU : Recalculate SGPRs when trap handler is supported. to AMDGPU : Recalculate SGPRs when trap handler is supported.
kzhuravl edited the summary of this revision. (Show Details)

Rebase + add test

t-tye accepted this revision.May 15 2018, 3:16 PM

LGTM

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

Remove space before ;

This revision is now accepted and ready to land.May 15 2018, 3:16 PM
This revision was automatically updated to reflect the committed changes.
kzhuravl marked an inline comment as done.