Skip to content

Add WaveActiveBitOr tests#973

Merged
bob80905 merged 11 commits intollvm:mainfrom
bob80905:add_waveactivebitor_tests
Mar 26, 2026
Merged

Add WaveActiveBitOr tests#973
bob80905 merged 11 commits intollvm:mainfrom
bob80905:add_waveactivebitor_tests

Conversation

@bob80905
Copy link
Copy Markdown
Contributor

@bob80905 bob80905 commented Mar 13, 2026

This PR adds tests for WaveActiveBitOr.
WaveActiveBitOr only accepts uint and uint64 types.
The PR also adds a control flow test, since this operation is convergent.
Fixes #92
Assisted by: Claude Opus 4.6

Comment on lines +10 to +11
void main(uint3 tid : SV_GroupThreadID)
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should generally try to stick to LLVM's C++ style for the HLSL in these tests unless we have a good reason not to.

Suggested change
void main(uint3 tid : SV_GroupThreadID)
{
void main(uint3 TID : SV_GroupThreadID) {

Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1,1,1]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Whitespace between list elements helps readability

Suggested change
DispatchSize: [1,1,1]
DispatchSize: [1, 1, 1]

Comment on lines +44 to +49
Data: [
3,0,0,0,
5,0,0,0,
6,0,0,0,
9,0,0,0
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Similarly

Suggested change
Data: [
3,0,0,0,
5,0,0,0,
6,0,0,0,
9,0,0,0
]
Data: [
3, 0, 0, 0,
5, 0, 0, 0,
6, 0, 0, 0,
9, 0, 0, 0
]


- Name: In
Format: UInt32
Stride: 16
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a reason that In is StructuredBuffer<uint4> rather than StructuredBuffer<uint>? We only ever access the x element.

- Name: ExpectedOut2
Format: UInt32
Stride: 4
Data: [0, 0, 15, 15]
Copy link
Copy Markdown
Contributor

@bogner bogner Mar 25, 2026

Choose a reason for hiding this comment

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

This is checking that we're getting the result of just 9 | 6, which is 0xf, but the values we're using are kind of unfortunate, since if we did or that with 3 | 5 we wouldn't set any extra bits. Should we adjust the input values a bit so it's more obvious exactly which ones are being or'd together?

- Name: ExpectedOut3
Format: UInt32
Stride: 4
Data: [15, 15, 15, 15]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Case in point, this is an or of all four values, but it's indistinguishable from an or of the last two threads only.

Comment on lines +25 to +26
for (uint i = 0; i < 2; i++)
r = WaveActiveBitOr(r);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All lanes are active on every iteration, right? What is this testing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The important part is the loop construct, which introduces some different control flow.
You'll notice the XFAIL here: llvm/llvm-project#188323
This loop created a situation where spirv-val complains. The semantics of the code aren't really important, the fact that a loop exists tests whether the compiler handles different control flow scenarios well.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there an argument for a loop case that has some divergence as well?

Comment on lines +42 to +47
Data: [
17,2,4,8,
16,32,64,128,
256,512,1024,2048,
4096,8192,16384,32768
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since we're using or here, I think specifying the inputs and outputs in hex will be clearer.

Copy link
Copy Markdown
Contributor

@bogner bogner left a comment

Choose a reason for hiding this comment

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

A lot of the variables in the tests aren’t following the llvm capitalization conventions (TID, V, R rather than tid, v, r), so it would be nice to make that consistent. Otherwise, LGTM!

@bob80905 bob80905 merged commit 86cdcc1 into llvm:main Mar 26, 2026
11 of 12 checks passed
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.

Add test for WaveActiveBitOr

3 participants