Skip to content

Conversation

jayfoad
Copy link
Contributor

@jayfoad jayfoad commented Jan 22, 2024

Rework the architected SGPRs implementation such that workgroup id
values (which live in TTMP registers) are available in all functions and
do not rely on calling allocateSystemSGPRs to set them up.

Rework the architected SGPRs implementation such that workgroup id
values (which live in TTMP registers) are available in all functions and
do not rely on calling allocateSystemSGPRs to set them up.
@jayfoad jayfoad requested review from arsenm and cdevadas January 22, 2024 16:21
if (!AMDGPU::isGraphics(CC) ||
(CC == CallingConv::AMDGPU_CS && ST.hasArchitectedSGPRs())) {
if (!AMDGPU::isGraphics(CC) || CC == CallingConv::AMDGPU_CS ||
ST.hasArchitectedSGPRs()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks redundant as this patch always allocate the TTMP* for subtargets with architectedSGPR enabled.
This was initially added with 2171f04.
You can revert this check to just have only !AMDGPU::isGraphics(CC)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I need WorkGroupIDZ to be set correctly when architected SGPRs are enabled. It is used below, line 177.

; GCN: s_mov_b64 s[4:5], s[0:1]
; GCN: buffer_store_dword v{{[0-9]+}}, off, s[4:7], 0 offset:4
; GCN: s_mov_b64 s[8:9], s[0:1]
; GCN: buffer_store_dword v{{[0-9]+}}, off, s[8:11], 0 offset:4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I guess I've broken something.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following change? It now enables workgroup IDs for AMDGPU_CS always.
SIMachineFunctionInfo.cpp:110

  • if (!AMDGPU::isGraphics(CC) ||
  • (CC == CallingConv::AMDGPU_CS && ST.hasArchitectedSGPRs())) {
  • if (!AMDGPU::isGraphics(CC) || CC == CallingConv::AMDGPU_CS ||
  • ST.hasArchitectedSGPRs()) {

@cdevadas
Copy link
Collaborator

The WaveID support is missing. Hope that will be coming in a separate patch.

ArgDescriptor PrivateSegmentWaveByteOffset;

// System TTMPs.
ArgDescriptor ArchitectedWorkGroupIDX;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these really need to be tracked in ArgumentUsageInfo; they aren't arguments anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I started again from scratch: #79120

}

if (STI->hasArchitectedSGPRs()) {
ArgInfo.ArchitectedWorkGroupIDX =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's OK for the lowering to directly consume the hardcoded register numbers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean not go via these ArgDescriptors? I'm only using them because they handle the shifting and masking.

@jayfoad jayfoad closed this Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants