This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU/GlobalISel: Fix flat_scratch_init handling for shaders
ClosedPublic

Authored by arsenm on Jan 18 2022, 3:13 PM.

Details

Summary

I don't think this is actually defined for mesa, but this is what we
were doing on the DAG path.

Diff Detail

Event Timeline

arsenm created this revision.Jan 18 2022, 3:13 PM
arsenm requested review of this revision.Jan 18 2022, 3:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2022, 3:13 PM
Herald added a subscriber: wdng. · View Herald Transcript
sebastian-ne added inline comments.Jan 19 2022, 1:36 AM
llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
505–509

Isn’t this already handled here for HSA?
I didn’t hear of mesa using flat scratch (and we don’t have any flat-scratch+mesa test), so should we update the dag code instead? I wonder why we are calling allocateHSAUserSGPRs for non-HSA platforms in the SDAG.

arsenm added inline comments.Jan 19 2022, 7:04 AM
llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
505–509

The GISel version is factored a bit differently with a cleaner break between the kernel and non-kernel handling. allocateHSAUserSGPRs isn't called on the shader path (it's a bit ugly that it is for the DAG and it happens to work out).

Mesa should have some kind of ABI definition for flat scratch, but in the absence of one, we still need to produce something. This matches the DAG behavior. Alternatively I could switch mesa to follow what PAL does, but that would be a separate potentially breaking change

sebastian-ne added inline comments.Jan 20 2022, 7:14 AM
llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
505–509

I’d prefer to change the SDAG to do the same for mesa as is done for PAL.
Duplicating the HSA init code for mesa seems wrong to me. I don’t think this would work correctly nor does the code look particularly appealing.
From what I can see, mesa still does not use flat scratch.

arsenm added inline comments.Jan 20 2022, 7:20 AM
llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
505–509

I'm not attempting to address mesa's flat usage. if that change goes ahead, both would update in the future. For now gisel should just match behavior

sebastian-ne accepted this revision.Jan 27 2022, 2:42 AM
This revision is now accepted and ready to land.Jan 27 2022, 2:42 AM