Page MenuHomePhabricator

[AMDGPU] Prevent backend override of WGP when using PAL
AbandonedPublic

Authored by dstuttard on Fri, Jun 21, 2:35 AM.

Details

Reviewers
tpr
rampitec
Summary

Backend defaults to setting WGP mode to 0 or 1 depending on the cumode
feature. For PAL clients we want PAL to set this mode.
Adding check to prevent the backend overriding whatever the front end has set.

Diff Detail

Event Timeline

dstuttard created this revision.Fri, Jun 21, 2:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptFri, Jun 21, 2:35 AM

Needs test

lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
970–974

This seems like a workaround. Why isn't PAL setting what it wants initially and overriding it later?

arsenm added inline comments.Fri, Jun 21, 6:40 AM
lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
970–974

I'm also thinking this should be an attribute rather than a sub target feature

dstuttard marked an inline comment as done.Fri, Jun 21, 7:10 AM
dstuttard added inline comments.
lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
970–974

Not sure what you're getting at here.
Currently PAL does set the value in the ComputePGMRSrc1 register. Policy is to OR any changes into the control registers that are input - but in this case that only works if you happen to enable CuMode (the default for the backend is to not be in CuMode, so WGP is always set to 1).

We could work around this by always setting the CuMode sub target feature in any PAL front-end - then the value passed in from PAL would always be honoured, but that seems more hacky to me.

We can change CuMode to be an attribute rather than sub target feature as a separate change, but that pre-exists this work.

I'll put a test together if we can agree an approach.

nhaehnle added inline comments.Tue, Jul 16, 4:04 AM
lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
970–974

Always setting the subtarget feature does seem like the right approach to me.

Changing it to a target attribute may be something to consider. It's one of those non-trivial things because it would have to be added to all functions, not just the kernel entry point, but...

arsenm added inline comments.Tue, Jul 16, 7:53 AM
lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
970–974

This seems like something we should handle consistently for all OS types, not just AMDPAL

dstuttard marked an inline comment as done.Wed, Jul 17, 1:27 AM
dstuttard added inline comments.
lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
970–974

I think I'll go with always setting the sub target feature for now, so I'll abandon this change.

dstuttard abandoned this revision.Wed, Jul 17, 1:29 AM

I might revisit this one - setting cumode seems messy to enable driver control of the WGP setting, but seems the most pragmatic at the moment.