Skip to content

[AMDGPU] Print workgroup_processor_mode metadata field as a boolean #135627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/lib/BinaryFormat/AMDGPUMetadataVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ bool MetadataVerifier::verifyKernel(msgpack::DocNode &Node) {
if (!verifyScalarEntry(KernelMap, ".uses_dynamic_stack", false,
msgpack::Type::Boolean))
return false;
if (!verifyIntegerEntry(KernelMap, ".workgroup_processor_mode", false))
if (!verifyScalarEntry(KernelMap, ".workgroup_processor_mode", false,
msgpack::Type::Boolean))
return false;
if (!verifyIntegerEntry(KernelMap, ".kernarg_segment_align", true))
return false;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ MetadataStreamerMsgPackV4::getHSAKernelProps(const MachineFunction &MF,

if (CodeObjectVersion >= AMDGPU::AMDHSA_COV5 && STM.supportsWGP())
Kern[".workgroup_processor_mode"] =
Kern.getDocument()->getNode(ProgramInfo.WgpMode);
Kern.getDocument()->getNode((bool)ProgramInfo.WgpMode);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the explicit cast needed here? Does it really make a difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The cast makes this a call to Document::getNode(bool) instead of Document::getNode(int), which returns a DocNode with the Type::Boolean type instead of the Type::Int type. That gets printed as false/true instead of 0/1.

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't WgpMode be defined as a boolean in SIProgramInfo directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I think so too, but all other boolean metadata fields are also stored as uint32_t in SIProgramInfo. I thought perhaps there was an underlying reason for this I did not see, in any case I did not want to create an exception for this field. If there is really no reason these can all be changed to bool in a future PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

probably should just change this, I don't see why we would want this to be a particular type


// FIXME: The metadata treats the minimum as 16?
Kern[".kernarg_segment_align"] =
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/AMDGPU/hsa-generic-target-features.ll
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
; Checks 10.1, 10.3 and 11 generic targets allow cumode/wave64.

; NOCU: .amdhsa_workgroup_processor_mode 0
; NOCU: .workgroup_processor_mode: 0
; NOCU: .workgroup_processor_mode: false
; CU: .amdhsa_workgroup_processor_mode 1
; CU: .workgroup_processor_mode: 1
; CU: .workgroup_processor_mode: true

; W64: .amdhsa_wavefront_size32 0
; W32: .amdhsa_wavefront_size32 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 < %s | FileCheck -check-prefix=GFX10-CU %s

; GFX10: .amdhsa_workgroup_processor_mode 0
; GFX10: .workgroup_processor_mode: 0
; GFX10: .workgroup_processor_mode: false
; GFX10-CU: .amdhsa_workgroup_processor_mode 1
; GFX10-CU: .workgroup_processor_mode: 1
; GFX10-CU: .workgroup_processor_mode: true

define amdgpu_kernel void @wavefrontsize() {
entry:
Expand Down
Loading