Skip to content

Add WaveGetLaneCount tests - #1541

Merged
bob80905 merged 2 commits into
llvm:mainfrom
bob80905:add_wavegetlanecount_tests
Sep 29, 2026
Merged

bob80905 merged 2 commits into
llvm:mainfrom
bob80905:add_wavegetlanecount_tests

Conversation

@bob80905

Copy link
Copy Markdown
Contributor

This PR adds offload tests for the WaveGetLaneCount builtin function.
There is currently a clang-vk failure, but since the rest of it was already implemented, we test for all other targets.
Also I thought about checking for powers of 2, but even if the DirectX / Vulkan backends specify wave size will always be a power of 2, the HLSL doc says we must expect 4 <= return <= 128.
For the unknown backend that has a non-power-of-two wave size, we leave that check off of this test.

Fixes #898
Assisted by: Github Copilot

[numthreads(1, 1, 1)]
void main() {
uint LaneCount = WaveGetLaneCount();
Out[0] = LaneCount >= 4 && LaneCount <= 128 ? 1 : 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.

Suggested change
Out[0] = LaneCount >= 4 && LaneCount <= 128 ? 1 : 0;
Out[0] = LaneCount >= 4 && LaneCount <= 128 && countbits(LaneCount) == 1 ? 1 : 0;

We could be a bit extra here, and also use countbits to make sure this is a power of two (also required).

@llvm-beanz llvm-beanz left a comment

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.

take or leave my suggestion

@damyanp
damyanp requested a review from spall September 29, 2026 17:27
# XFAIL: Clang && Vulkan

# RUN: split-file %s %t
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl

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.

this is supported from sm 6.0 and later; is there a reason you chose to use 6.5?

@bob80905 bob80905 Sep 29, 2026 •

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.

No particular reason, maybe because some of the other offload tests are 6.5 / copy paste.
Dropped it to 6.0.

@bob80905
bob80905 merged commit 8fcb029 into llvm:main Sep 29, 2026
26 of 32 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 WaveGetLaneCount

3 participants